Imported Upstream version 0.5
authorCharles Plessy <plessy@debian.org>
Wed, 8 Jun 2011 10:40:41 +0000 (19:40 +0900)
committerCharles Plessy <plessy@debian.org>
Wed, 8 Jun 2011 10:40:41 +0000 (19:40 +0900)
83 files changed:
MANIFEST.in
PKG-INFO
pysam.egg-info/PKG-INFO
pysam.egg-info/SOURCES.txt
pysam.egg-info/not-zip-safe [new file with mode: 0644]
pysam.egg-info/top_level.txt
pysam/Pileup.py
pysam/TabProxies.c [new file with mode: 0644]
pysam/TabProxies.pxd [new file with mode: 0644]
pysam/TabProxies.pyx [new file with mode: 0644]
pysam/VCF.py [new file with mode: 0644]
pysam/__init__.py
pysam/csamtools.c
pysam/csamtools.pxd
pysam/csamtools.pyx
pysam/ctabix.c
pysam/ctabix.pxd
pysam/ctabix.pyx
pysam/cvcf.c [new file with mode: 0644]
pysam/cvcf.pxd [new file with mode: 0644]
pysam/cvcf.pyx [new file with mode: 0644]
pysam/pysam_util.c
pysam/version.py
samtools/bam.c.pysam.c
samtools/bam.h
samtools/bam2bcf.c.pysam.c
samtools/bam2bcf.h
samtools/bam2bcf_indel.c.pysam.c
samtools/bam2depth.c.pysam.c [new file with mode: 0644]
samtools/bam_aux.c.pysam.c
samtools/bam_cat.c.pysam.c [new file with mode: 0644]
samtools/bam_import.c.pysam.c
samtools/bam_index.c.pysam.c
samtools/bam_maqcns.c.pysam.c
samtools/bam_md.c.pysam.c
samtools/bam_plcmd.c.pysam.c
samtools/bam_sort.c.pysam.c
samtools/bam_stat.c.pysam.c
samtools/bam_tview.c.pysam.c
samtools/bcftools/bcf.c.pysam.c
samtools/bcftools/bcf.h
samtools/bcftools/bcf2qcall.c.pysam.c
samtools/bcftools/bcfutils.c.pysam.c
samtools/bcftools/call1.c.pysam.c
samtools/bcftools/em.c.pysam.c [new file with mode: 0644]
samtools/bcftools/fet.c.pysam.c
samtools/bcftools/kmin.c.pysam.c [new file with mode: 0644]
samtools/bcftools/kmin.h [new file with mode: 0644]
samtools/bcftools/ld.c.pysam.c [deleted file]
samtools/bcftools/prob1.c.pysam.c
samtools/bcftools/prob1.h
samtools/bcftools/vcf.c.pysam.c
samtools/bedidx.c.pysam.c [new file with mode: 0644]
samtools/bgzf.c.pysam.c
samtools/bgzf.h
samtools/cut_target.c.pysam.c [new file with mode: 0644]
samtools/errmod.h
samtools/faidx.c.pysam.c
samtools/khash.h
samtools/knetfile.c.pysam.c
samtools/kstring.c.pysam.c
samtools/kstring.h
samtools/misc/md5.c.pysam.c [new file with mode: 0644]
samtools/misc/md5.h [new file with mode: 0644]
samtools/msvc_compat.h [new file with mode: 0644]
samtools/phase.c.pysam.c [new file with mode: 0644]
samtools/sam.c.pysam.c
samtools/sam_header.c.pysam.c
samtools/sam_view.c.pysam.c
samtools/sample.c.pysam.c
setup.cfg
setup.py
tabix/bedidx.c.pysam.c [new file with mode: 0644]
tabix/bgzf.c.pysam.c
tabix/bgzf.h
tabix/index.c.pysam.c
tabix/kseq.h [new file with mode: 0644]
tabix/msvc_compat.h [new file with mode: 0644]
tabix/tabix.h
tests/example.gtf.gz
tests/example.gtf.gz.tbi
tests/pysam_test.py
tests/tabix_test.py

index 01405490cdbdf434723389deb6b435b969db846e..efb1d3e36438ffad56c8a88dec07b712ec6a545b 100644 (file)
@@ -15,6 +15,12 @@ include pysam/csamtools.c
 include pysam/ctabix.pxd
 include pysam/ctabix.c
 include pysam/ctabix.pyx
+include pysam/TabProxies.c
+include pysam/TabProxies.pyx
+include pysam/TabProxies.pxd
+include pysam/cvcf.pyx
+include pysam/cvcf.pxd
+include pysam/cvcf.c
 include pysam/pysam_util.h
 include samtools/*.h
 include samtools/*/*.h
index f14bb9cd9dac2f229f0395ad2f06ee26e055e6ad..c90139fb55ade84c9847aff21305dc3f8301070c 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysam
-Version: 0.4.1
+Version: 0.5
 Summary: pysam
 Home-page: http://code.google.com/p/pysam/
 Author: Andreas Heger
index f14bb9cd9dac2f229f0395ad2f06ee26e055e6ad..c90139fb55ade84c9847aff21305dc3f8301070c 100644 (file)
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysam
-Version: 0.4.1
+Version: 0.5
 Summary: pysam
 Home-page: http://code.google.com/p/pysam/
 Author: Andreas Heger
index 69d23268bf6e823cb76c1d3159a7cc824c10dc8b..6f8ca43c3ff766feb62846754803ec4f991333db 100644 (file)
@@ -7,6 +7,10 @@ ez_setup.py
 setup.cfg
 setup.py
 pysam/Pileup.py
+pysam/TabProxies.c
+pysam/TabProxies.pxd
+pysam/TabProxies.pyx
+pysam/VCF.py
 pysam/__init__.py
 pysam/csamtools.c
 pysam/csamtools.pxd
@@ -14,6 +18,9 @@ pysam/csamtools.pyx
 pysam/ctabix.c
 pysam/ctabix.pxd
 pysam/ctabix.pyx
+pysam/cvcf.c
+pysam/cvcf.pxd
+pysam/cvcf.pyx
 pysam/namedtuple.py
 pysam/pysam_util.c
 pysam/pysam_util.h
@@ -22,6 +29,7 @@ pysam/version.py
 pysam.egg-info/PKG-INFO
 pysam.egg-info/SOURCES.txt
 pysam.egg-info/dependency_links.txt
+pysam.egg-info/not-zip-safe
 pysam.egg-info/requires.txt
 pysam.egg-info/top_level.txt
 samtools/bam.c.pysam.c
@@ -29,7 +37,9 @@ samtools/bam.h
 samtools/bam2bcf.c.pysam.c
 samtools/bam2bcf.h
 samtools/bam2bcf_indel.c.pysam.c
+samtools/bam2depth.c.pysam.c
 samtools/bam_aux.c.pysam.c
+samtools/bam_cat.c.pysam.c
 samtools/bam_color.c.pysam.c
 samtools/bam_endian.h
 samtools/bam_import.c.pysam.c
@@ -46,8 +56,10 @@ samtools/bam_rmdupse.c.pysam.c
 samtools/bam_sort.c.pysam.c
 samtools/bam_stat.c.pysam.c
 samtools/bam_tview.c.pysam.c
+samtools/bedidx.c.pysam.c
 samtools/bgzf.c.pysam.c
 samtools/bgzf.h
+samtools/cut_target.c.pysam.c
 samtools/errmod.c.pysam.c
 samtools/errmod.h
 samtools/faidx.c.pysam.c
@@ -66,6 +78,8 @@ samtools/kseq.h
 samtools/ksort.h
 samtools/kstring.c.pysam.c
 samtools/kstring.h
+samtools/msvc_compat.h
+samtools/phase.c.pysam.c
 samtools/pysam.h
 samtools/razf.c.pysam.c
 samtools/razf.h
@@ -81,17 +95,22 @@ samtools/bcftools/bcf.h
 samtools/bcftools/bcf2qcall.c.pysam.c
 samtools/bcftools/bcfutils.c.pysam.c
 samtools/bcftools/call1.c.pysam.c
+samtools/bcftools/em.c.pysam.c
 samtools/bcftools/fet.c.pysam.c
 samtools/bcftools/index.c.pysam.c
 samtools/bcftools/kfunc.c.pysam.c
-samtools/bcftools/ld.c.pysam.c
+samtools/bcftools/kmin.c.pysam.c
+samtools/bcftools/kmin.h
 samtools/bcftools/prob1.c.pysam.c
 samtools/bcftools/prob1.h
 samtools/bcftools/vcf.c.pysam.c
+samtools/misc/md5.c.pysam.c
+samtools/misc/md5.h
 samtools/win32/xcurses.h
 samtools/win32/zconf.h
 samtools/win32/zlib.h
 tabix/bam_endian.h
+tabix/bedidx.c.pysam.c
 tabix/bgzf.c.pysam.c
 tabix/bgzf.h
 tabix/bgzip.c.pysam.c
@@ -99,9 +118,11 @@ tabix/index.c.pysam.c
 tabix/khash.h
 tabix/knetfile.c.pysam.c
 tabix/knetfile.h
+tabix/kseq.h
 tabix/ksort.h
 tabix/kstring.c.pysam.c
 tabix/kstring.h
+tabix/msvc_compat.h
 tabix/pysam.h
 tabix/tabix.h
 tests/00README.txt
diff --git a/pysam.egg-info/not-zip-safe b/pysam.egg-info/not-zip-safe
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
index acdcd2cba61cddf7c3c57b2bc18f58649f83a78e..a57e36cbde7270af96355c934cea8d8aba073e9f 100644 (file)
@@ -2,5 +2,7 @@ pysam/namedtuple
 ctabix
 pysam/Pileup
 csamtools
+cvcf
+TabProxies
 pysam/version
 pysam/__init__
index e182689c6a116df1dafd714655ac5124696cd9f1..998127b03bf0eee14ebeebb14dd628c21698b6f7 100644 (file)
@@ -58,3 +58,214 @@ def iterate( infile ):
                 yield PileupSubstitution( *[x(y) for x,y in zip(conv_subst,d) ] )
             except TypeError:
                 raise pysam.SamtoolsError( "parsing error in line: `%s`" % line)
+
+ENCODE_GENOTYPE = {
+    'A': 'A', 'C': 'C', 'G': 'G', 'T': 'T',
+    'AA': 'A', 'CC': 'C', 'GG': 'G', 'TT': 'T', 'UU': 'U',
+    'AG': 'r', 'GA': 'R',
+    'CT': 'y', 'TC': 'Y',
+    'AC': 'm', 'CA': 'M',
+    'GT': 'k', 'TG': 'K',
+    'CG': 's', 'GC': 'S',
+    'AT': 'w', 'TA': 'W',
+    }        
+
+DECODE_GENOTYPE = {
+    'A': 'AA',
+    'C': 'CC',
+    'G': 'GG',
+    'T': 'TT',
+    'r': 'AG', 'R': 'AG',
+    'y': 'CT', 'Y': 'CT',
+    'm': 'AC', 'M': 'AC',
+    'k': 'GT', 'K': 'GT',
+    's': 'CG', 'S': 'CG',
+    'w': 'AT', 'W': 'AT',
+    }
+
+##------------------------------------------------------------
+def encodeGenotype( code ):
+    '''encode genotypes like GG, GA into a one-letter code.
+    The returned code is lower case if code[0] < code[1], otherwise
+    it is uppercase.
+    '''
+    return ENCODE_GENOTYPE[ code.upper() ]
+
+def decodeGenotype( code ):
+    '''decode single letter genotypes like m, M into two letters.
+    This is the reverse operation to :meth:`encodeGenotype`.
+    '''
+    return DECODE_GENOTYPE[ code ] 
+
+def translateIndelGenotypeFromVCF( vcf_genotypes, ref ):
+    '''translate indel from vcf to pileup format.'''
+
+    # indels
+    def getPrefix( s1, s2 ):
+        '''get common prefix of strings s1 and s2.'''
+        n = min( len( s1), len( s2 ) )
+        for x in range( n ):
+            if s1[x] != s2[x]: return s1[:x]
+        return s1[:n]
+
+    def getSuffix( s1, s2 ):
+        '''get common sufix of strings s1 and s2.'''
+        n = min( len( s1), len( s2 ) )
+        if s1[-1] != s2[-1]: return ""
+        for x in range( -2, -n - 1, -1 ):
+            if s1[x] != s2[x]: return s1[x+1:]
+        return s1[-n:]
+
+    def getGenotype( variant, ref ):
+
+        if variant == ref: return "*", 0
+        
+        if len(ref) > len(variant):
+            # is a deletion
+            if ref.startswith(variant):
+                return "-%s" % ref[len(variant):], len(variant) - 1
+            elif ref.endswith( variant ):
+                return "-%s" % ref[:-len(variant)], -1
+            else:
+                prefix = getPrefix( ref, variant )
+                suffix = getSuffix( ref, variant )
+                shared = len(prefix) + len(suffix) - len(variant) 
+                # print "-", prefix, suffix, ref, variant, shared, len(prefix), len(suffix), len(ref)
+                if shared < 0:
+                    raise ValueError()
+                return "-%s" % ref[len(prefix):-(len(suffix)-shared)], len(prefix) - 1
+
+        elif len(ref) < len(variant):
+            # is an insertion
+            if variant.startswith(ref):
+                return "+%s" % variant[len(ref):], len(ref) - 1
+            elif variant.endswith(ref):
+                return "+%s" % variant[:len(ref)], 0
+            else:
+                prefix = getPrefix( ref, variant )
+                suffix = getSuffix( ref, variant )
+                shared = len(prefix) + len(suffix) - len(ref) 
+                if shared < 0:
+                    raise ValueError()
+
+                return "+%s" % variant[len(prefix):-(len(suffix)-shared)], len(prefix)
+        else:
+            assert 0, "snp?"
+
+    # in pileup, the position refers to the base
+    # after the coordinate, hence subtract 1
+            #pos -= 1
+
+    genotypes, offsets = [], []
+    is_error = True
+
+    for variant in vcf_genotypes:
+        try:
+            g, offset = getGenotype( variant, ref ) 
+        except ValueError:
+            break
+
+        genotypes.append( g )
+        if g != "*":  offsets.append( offset )
+        
+    else: 
+        is_error = False
+
+    if is_error: 
+        raise ValueError()
+
+    assert len(set(offsets )) == 1, "multiple offsets for indel"
+    offset = offsets[0]
+
+    genotypes = "/".join( genotypes )
+    return genotypes, offset
+
+def vcf2pileup( vcf, sample ):
+    '''convert vcf record to pileup record.'''
+    
+    chromosome = vcf.contig
+    pos = vcf.pos
+    reference = vcf.ref
+    allelles = [reference] + vcf.alt
+
+    data = vcf[sample]
+
+    # get genotype
+    genotypes = data["GT"]
+    if len(genotypes) > 1:
+        raise ValueError( "only single genotype per position, %s" % (str(vcf)))
+
+    genotypes = genotypes[0]
+
+    # not a variant
+    if genotypes[0] == ".": return None
+
+    genotypes = [ allelles[int(x)] for x in genotypes if x != "/" ]
+
+    # snp_quality is "genotype quality"
+    snp_quality = consensus_quality = data.get( "GQ", [0])[0]
+    mapping_quality = vcf.info.get( "MQ", [0])[0]
+    coverage = data.get( "DP", 0)
+
+    if len(reference) > 1 or max([len(x) for x in vcf.alt] ) > 1:
+        # indel
+        genotype, offset = translateIndelGenotypeFromVCF( genotypes, reference )
+
+        return PileupIndel( chromosome, 
+                            pos + offset,
+                            "*",
+                            genotype,
+                            consensus_quality,
+                            snp_quality,
+                            mapping_quality,
+                            coverage,
+                            genotype,
+                            "<" * len(genotype),
+                            0, 
+                            0,
+                            0 )
+        
+    else:
+
+        genotype = encodeGenotype( "".join(genotypes) )
+
+        
+        read_bases = ""
+        base_qualities = ""
+
+        return PileupSubstitution( chromosome, pos, reference, 
+                                   genotype,
+                                   consensus_quality, 
+                                   snp_quality, 
+                                   mapping_quality,
+                                   coverage, read_bases, base_qualities ) 
+
+
+def iterate_from_vcf( infile, sample ):
+    '''iterate over a vcf-formatted file.
+
+    *infile* can be any iterator over a lines.
+
+    The function yields named tuples of the type :class:`pysam.Pileup.PileupSubstitution`
+    or :class:`pysam.Pileup.PileupIndel`.
+
+    Positions without a snp will be skipped. 
+
+    This method is wasteful and written to support same
+    legacy code that expects samtools pileup output.
+
+    Better use the vcf parser directly.
+
+    '''
+
+    
+    vcf = pysam.VCF()
+    vcf.connect( infile )
+
+    if sample not in vcf.getsamples():
+        raise KeyErorr( "sample %s not vcf file" )
+
+    for row in vcf.fetch():
+        result = vcf2pileup( row, sample )
+        if result: yield result
+    
diff --git a/pysam/TabProxies.c b/pysam/TabProxies.c
new file mode 100644 (file)
index 0000000..dc9e21c
--- /dev/null
@@ -0,0 +1,9919 @@
+/* Generated by Cython 0.13 on Thu May  5 14:57:52 2011 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#else
+
+#include <stddef.h> /* For offsetof */
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
+  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
+  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
+#endif
+
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+     void *buf;
+     PyObject *obj;
+     Py_ssize_t len;
+     Py_ssize_t itemsize;
+     int readonly;
+     int ndim;
+     char *format;
+     Py_ssize_t *shape;
+     Py_ssize_t *strides;
+     Py_ssize_t *suboffsets;
+     void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+
+#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+
+#if PY_VERSION_HEX < 0x02060000
+  #define PyBytesObject                PyStringObject
+  #define PyBytes_Type                 PyString_Type
+  #define PyBytes_Check                PyString_Check
+  #define PyBytes_CheckExact           PyString_CheckExact
+  #define PyBytes_FromString           PyString_FromString
+  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
+  #define PyBytes_FromFormat           PyString_FromFormat
+  #define PyBytes_DecodeEscape         PyString_DecodeEscape
+  #define PyBytes_AsString             PyString_AsString
+  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
+  #define PyBytes_Size                 PyString_Size
+  #define PyBytes_AS_STRING            PyString_AS_STRING
+  #define PyBytes_GET_SIZE             PyString_GET_SIZE
+  #define PyBytes_Repr                 PyString_Repr
+  #define PyBytes_Concat               PyString_Concat
+  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
+  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
+  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
+#endif
+
+#ifndef PySet_CheckExact
+#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject PyLongObject
+#endif
+
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
+#endif
+
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#define __PYX_HAVE_API__TabProxies
+#include "stdlib.h"
+#include "string.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "pythread.h"
+
+/* inline attribute */
+#ifndef CYTHON_INLINE
+  #if defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE 
+  #endif
+#endif
+
+/* unused attribute */
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__)) 
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || defined(__INTEL_COMPILER)
+#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
+# else
+#   define CYTHON_UNUSED 
+# endif
+#endif
+
+typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
+
+
+/* Type Conversion Predeclarations */
+
+#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
+#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+
+#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "TabProxies.pyx",
+  "bool.pxd",
+};
+
+/* Type declarations */
+
+/* "pysam/TabProxies.pxd":42
+ *   ctypedef int uint64_t
+ * 
+ * cdef class TupleProxy:             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_TupleProxy {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtab;
+  char *data;
+  char **fields;
+  int nfields;
+  int index;
+  int nbytes;
+  int offset;
+  int is_modified;
+};
+
+/* "pysam/TabProxies.pxd":77
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+
+struct __pyx_obj_10TabProxies_NamedTupleProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+};
+
+/* "pysam/TabProxies.pxd":91
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_VCFProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t pos;
+};
+
+/* "pysam/TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_GTFProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+  char *contig;
+  char *source;
+  char *feature;
+  uint32_t start;
+  uint32_t end;
+  char *score;
+  char *strand;
+  char *frame;
+  char *attributes;
+  int hasOwnAttributes;
+};
+
+/* "pysam/TabProxies.pxd":80
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_BedProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t start;
+  uint32_t end;
+  int bedfields;
+};
+
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":20
+ *      return not (buffer <= p < buffer + nbytes )
+ * 
+ * cdef class TupleProxy:             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to parsed row as a tuple.
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_TupleProxy {
+  int (*getMaxFields)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t);
+  PyObject *(*take)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*present)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*copy)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*update)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+};
+static struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtabptr_10TabProxies_TupleProxy;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":488
+ *         self.fromDict( r )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy ):             # <<<<<<<<<<<<<<
+ * 
+ *     map_key2field = {}
+ */
+
+struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":573
+ *         TupleProxy._setindex(self, idx, str(value) )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to VCF fields.
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_VCFProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_VCFProxy *__pyx_vtabptr_10TabProxies_VCFProxy;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":507
+ *         return f( self.fields[idx] )
+ * 
+ * cdef class BedProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to Bed fields.
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_BedProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_BedProxy *__pyx_vtabptr_10TabProxies_BedProxy;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":231
+ *         return str(v)
+ * 
+ * cdef class GTFProxy( TupleProxy ):             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to GTF fields.
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_GTFProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_GTFProxy *__pyx_vtabptr_10TabProxies_GTFProxy;
+
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+  end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+  }
+  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
+#else
+  #define __Pyx_RefNannySetupContext(name)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
+#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
+    const char* function_name, int kw_allowed); /*proto*/
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name, PyObject* kw_name); /*proto*/
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
+
+static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
+static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
+    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
+}
+
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+
+
+#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+            PyObject *r = PyList_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+
+#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
+        r = PySequence_GetItem(o, i);
+    }
+    else {
+        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+    }
+    return r;
+}
+
+static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
+
+#define __Pyx_PyObject_AsDouble(obj) \
+    ((likely(PyFloat_CheckExact(obj))) ? \
+     PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
+static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
+static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
+
+static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);
+
+static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *);
+
+static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
+
+static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
+
+static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
+
+static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
+
+static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
+
+static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
+
+static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
+
+static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
+
+static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
+
+static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
+
+static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
+
+static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
+
+static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
+
+static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
+
+static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
+
+static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
+
+static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+
+static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+/* Module declarations from cpython.version */
+
+/* Module declarations from cpython.ref */
+
+/* Module declarations from cpython.exc */
+
+/* Module declarations from cpython.module */
+
+/* Module declarations from cpython.mem */
+
+/* Module declarations from cpython.tuple */
+
+/* Module declarations from cpython.list */
+
+/* Module declarations from libc.stdio */
+
+/* Module declarations from cpython.object */
+
+/* Module declarations from cpython.sequence */
+
+/* Module declarations from cpython.mapping */
+
+/* Module declarations from cpython.iterator */
+
+/* Module declarations from cpython.type */
+
+/* Module declarations from cpython.number */
+
+/* Module declarations from cpython.int */
+
+/* Module declarations from __builtin__ */
+
+/* Module declarations from cpython.bool */
+
+static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
+/* Module declarations from cpython.long */
+
+/* Module declarations from cpython.float */
+
+/* Module declarations from cpython.complex */
+
+/* Module declarations from cpython.string */
+
+/* Module declarations from cpython.unicode */
+
+/* Module declarations from cpython.dict */
+
+/* Module declarations from cpython.instance */
+
+/* Module declarations from cpython.function */
+
+/* Module declarations from cpython.method */
+
+/* Module declarations from cpython.weakref */
+
+/* Module declarations from cpython.getargs */
+
+/* Module declarations from cpython.pythread */
+
+/* Module declarations from cpython.cobject */
+
+/* Module declarations from cpython.oldbuffer */
+
+/* Module declarations from cpython.set */
+
+/* Module declarations from cpython.buffer */
+
+/* Module declarations from cpython.bytes */
+
+/* Module declarations from cpython.pycapsule */
+
+/* Module declarations from cpython */
+
+/* Module declarations from TabProxies */
+
+static PyTypeObject *__pyx_ptype_10TabProxies_TupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_GTFProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_NamedTupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_BedProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_VCFProxy = 0;
+static char *__pyx_f_10TabProxies_nextItem(char *); /*proto*/
+static char *__pyx_f_10TabProxies_StrOrEmpty(char *); /*proto*/
+static int __pyx_f_10TabProxies_isNew(char *, char *, size_t); /*proto*/
+#define __Pyx_MODULE_NAME "TabProxies"
+int __pyx_module_is_main_TabProxies = 0;
+
+/* Implementation of TabProxies */
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_builtin_IndexError;
+static PyObject *__pyx_builtin_StopIteration;
+static PyObject *__pyx_builtin_xrange;
+static PyObject *__pyx_builtin_TypeError;
+static PyObject *__pyx_builtin_AttributeError;
+static PyObject *__pyx_builtin_KeyError;
+static char __pyx_k_1[] = "malformatted entry at %s";
+static char __pyx_k_2[] = "";
+static char __pyx_k_3[] = "out of memory";
+static char __pyx_k_4[] = "incomplete line at %s";
+static char __pyx_k_5[] = "row too large - more than %i fields";
+static char __pyx_k_6[] = "list index out of range";
+static char __pyx_k_7[] = "\t";
+static char __pyx_k_8[] = ".";
+static char __pyx_k_9[] = "\"%s\"";
+static char __pyx_k_10[] = ";";
+static char __pyx_k_11[] = " ";
+static char __pyx_k_12[] = "\"";
+static char __pyx_k_13[] = "%s \"%s\"";
+static char __pyx_k_14[] = "%s %s";
+static char __pyx_k_15[] = "; ";
+static char __pyx_k_16[] = "'GTFProxy' has no attribute '%s'";
+static char __pyx_k_17[] = "field %s not set";
+static char __pyx_k_18[] = "bed format requires at least three columns";
+static char __pyx_k_19[] = "contig of feature.";
+static char __pyx_k_20[] = "feature name.";
+static char __pyx_k_21[] = "feature source.";
+static char __pyx_k_22[] = "feature start (in 0-based open/closed coordinates).";
+static char __pyx_k_23[] = "feature end (in 0-based open/closed coordinates).";
+static char __pyx_k_24[] = "feature score.";
+static char __pyx_k_25[] = "feature strand.";
+static char __pyx_k_26[] = "feature frame.";
+static char __pyx_k_27[] = "feature attributes (as a string).";
+static char __pyx_k_28[] = "TupleProxy._setindex (line 154)";
+static char __pyx_k_29[] = "TupleProxy.__setitem__ (line 177)";
+static char __pyx_k_30[] = "TupleProxy.__next__ (line 192)";
+static char __pyx_k_31[] = "TupleProxy.__str__ (line 202)";
+static char __pyx_k_32[] = "toDot (line 219)";
+static char __pyx_k_33[] = "quote (line 224)";
+static char __pyx_k_34[] = "GTFProxy.asDict (line 350)";
+static char __pyx_k_35[] = "GTFProxy.fromDict (line 385)";
+static char __pyx_k_36[] = "GTFProxy.invert (line 430)";
+static char __pyx_k_37[] = "GTFProxy.keys (line 441)";
+static char __pyx_k_38[] = "GTFProxy.__getattr__ (line 449)";
+static char __pyx_k_39[] = "GTFProxy.setAttribute (line 482)";
+static char __pyx_k_40[] = "NamedTupleProxy.__setattr__ (line 492)";
+static char __pyx_k_41[] = "BedProxy.__setattr__ (line 564)";
+static char __pyx_k_42[] = "VCFProxy.__setattr__ (line 608)";
+static char __pyx_k__id[] = "id";
+static char __pyx_k__alt[] = "alt";
+static char __pyx_k__end[] = "end";
+static char __pyx_k__pos[] = "pos";
+static char __pyx_k__ref[] = "ref";
+static char __pyx_k__data[] = "data";
+static char __pyx_k__info[] = "info";
+static char __pyx_k__join[] = "join";
+static char __pyx_k__keys[] = "keys";
+static char __pyx_k__name[] = "name";
+static char __pyx_k__qual[] = "qual";
+static char __pyx_k__frame[] = "frame";
+static char __pyx_k__index[] = "index";
+static char __pyx_k__items[] = "items";
+static char __pyx_k__quote[] = "quote";
+static char __pyx_k__range[] = "range";
+static char __pyx_k__score[] = "score";
+static char __pyx_k__split[] = "split";
+static char __pyx_k__start[] = "start";
+static char __pyx_k__strip[] = "strip";
+static char __pyx_k__toDot[] = "toDot";
+static char __pyx_k__types[] = "types";
+static char __pyx_k__value[] = "value";
+static char __pyx_k__asDict[] = "asDict";
+static char __pyx_k__contig[] = "contig";
+static char __pyx_k__fields[] = "fields";
+static char __pyx_k__filter[] = "filter";
+static char __pyx_k__format[] = "format";
+static char __pyx_k__invert[] = "invert";
+static char __pyx_k__nbytes[] = "nbytes";
+static char __pyx_k__offset[] = "offset";
+static char __pyx_k__source[] = "source";
+static char __pyx_k__strand[] = "strand";
+static char __pyx_k__update[] = "update";
+static char __pyx_k__xrange[] = "xrange";
+static char __pyx_k____str__[] = "__str__";
+static char __pyx_k__feature[] = "feature";
+static char __pyx_k__itemRGB[] = "itemRGB";
+static char __pyx_k__nfields[] = "nfields";
+static char __pyx_k__BedProxy[] = "BedProxy";
+static char __pyx_k__GTFProxy[] = "GTFProxy";
+static char __pyx_k__KeyError[] = "KeyError";
+static char __pyx_k__VCFProxy[] = "VCFProxy";
+static char __pyx_k____main__[] = "__main__";
+static char __pyx_k____next__[] = "__next__";
+static char __pyx_k____test__[] = "__test__";
+static char __pyx_k__fromDict[] = "fromDict";
+static char __pyx_k__thickEnd[] = "thickEnd";
+static char __pyx_k__TypeError[] = "TypeError";
+static char __pyx_k___setindex[] = "_setindex";
+static char __pyx_k__bedfields[] = "bedfields";
+static char __pyx_k__IndexError[] = "IndexError";
+static char __pyx_k__StringType[] = "StringType";
+static char __pyx_k__TupleProxy[] = "TupleProxy";
+static char __pyx_k__ValueError[] = "ValueError";
+static char __pyx_k__attributes[] = "attributes";
+static char __pyx_k__blockCount[] = "blockCount";
+static char __pyx_k__blockSizes[] = "blockSizes";
+static char __pyx_k__thickStart[] = "thickStart";
+static char __pyx_k__StringTypes[] = "StringTypes";
+static char __pyx_k____getattr__[] = "__getattr__";
+static char __pyx_k____setattr__[] = "__setattr__";
+static char __pyx_k____setitem__[] = "__setitem__";
+static char __pyx_k__blockStarts[] = "blockStarts";
+static char __pyx_k__is_modified[] = "is_modified";
+static char __pyx_k__getMaxFields[] = "getMaxFields";
+static char __pyx_k__setAttribute[] = "setAttribute";
+static char __pyx_k__StopIteration[] = "StopIteration";
+static char __pyx_k__map_key2field[] = "map_key2field";
+static char __pyx_k__AttributeError[] = "AttributeError";
+static char __pyx_k__NamedTupleProxy[] = "NamedTupleProxy";
+static char __pyx_k__hasOwnAttributes[] = "hasOwnAttributes";
+static PyObject *__pyx_kp_s_1;
+static PyObject *__pyx_kp_s_10;
+static PyObject *__pyx_kp_s_11;
+static PyObject *__pyx_kp_s_12;
+static PyObject *__pyx_kp_s_13;
+static PyObject *__pyx_kp_s_14;
+static PyObject *__pyx_kp_s_15;
+static PyObject *__pyx_kp_s_16;
+static PyObject *__pyx_kp_s_17;
+static PyObject *__pyx_kp_s_18;
+static PyObject *__pyx_kp_s_2;
+static PyObject *__pyx_kp_u_28;
+static PyObject *__pyx_kp_u_29;
+static PyObject *__pyx_kp_s_3;
+static PyObject *__pyx_kp_u_30;
+static PyObject *__pyx_kp_u_31;
+static PyObject *__pyx_kp_u_32;
+static PyObject *__pyx_kp_u_33;
+static PyObject *__pyx_kp_u_34;
+static PyObject *__pyx_kp_u_35;
+static PyObject *__pyx_kp_u_36;
+static PyObject *__pyx_kp_u_37;
+static PyObject *__pyx_kp_u_38;
+static PyObject *__pyx_kp_u_39;
+static PyObject *__pyx_kp_s_4;
+static PyObject *__pyx_kp_u_40;
+static PyObject *__pyx_kp_u_41;
+static PyObject *__pyx_kp_u_42;
+static PyObject *__pyx_kp_s_5;
+static PyObject *__pyx_kp_s_6;
+static PyObject *__pyx_kp_s_7;
+static PyObject *__pyx_kp_s_8;
+static PyObject *__pyx_kp_s_9;
+static PyObject *__pyx_n_s__AttributeError;
+static PyObject *__pyx_n_s__BedProxy;
+static PyObject *__pyx_n_s__GTFProxy;
+static PyObject *__pyx_n_s__IndexError;
+static PyObject *__pyx_n_s__KeyError;
+static PyObject *__pyx_n_s__NamedTupleProxy;
+static PyObject *__pyx_n_s__StopIteration;
+static PyObject *__pyx_n_s__StringType;
+static PyObject *__pyx_n_s__StringTypes;
+static PyObject *__pyx_n_s__TupleProxy;
+static PyObject *__pyx_n_s__TypeError;
+static PyObject *__pyx_n_s__VCFProxy;
+static PyObject *__pyx_n_s__ValueError;
+static PyObject *__pyx_n_s____getattr__;
+static PyObject *__pyx_n_s____main__;
+static PyObject *__pyx_n_s____next__;
+static PyObject *__pyx_n_s____setattr__;
+static PyObject *__pyx_n_s____setitem__;
+static PyObject *__pyx_n_s____str__;
+static PyObject *__pyx_n_s____test__;
+static PyObject *__pyx_n_s___setindex;
+static PyObject *__pyx_n_s__alt;
+static PyObject *__pyx_n_s__asDict;
+static PyObject *__pyx_n_s__attributes;
+static PyObject *__pyx_n_s__bedfields;
+static PyObject *__pyx_n_s__blockCount;
+static PyObject *__pyx_n_s__blockSizes;
+static PyObject *__pyx_n_s__blockStarts;
+static PyObject *__pyx_n_s__contig;
+static PyObject *__pyx_n_s__data;
+static PyObject *__pyx_n_s__end;
+static PyObject *__pyx_n_s__feature;
+static PyObject *__pyx_n_s__fields;
+static PyObject *__pyx_n_s__filter;
+static PyObject *__pyx_n_s__format;
+static PyObject *__pyx_n_s__frame;
+static PyObject *__pyx_n_s__fromDict;
+static PyObject *__pyx_n_s__getMaxFields;
+static PyObject *__pyx_n_s__hasOwnAttributes;
+static PyObject *__pyx_n_s__id;
+static PyObject *__pyx_n_s__index;
+static PyObject *__pyx_n_s__info;
+static PyObject *__pyx_n_s__invert;
+static PyObject *__pyx_n_s__is_modified;
+static PyObject *__pyx_n_s__itemRGB;
+static PyObject *__pyx_n_s__items;
+static PyObject *__pyx_n_s__join;
+static PyObject *__pyx_n_s__keys;
+static PyObject *__pyx_n_s__map_key2field;
+static PyObject *__pyx_n_s__name;
+static PyObject *__pyx_n_s__nbytes;
+static PyObject *__pyx_n_s__nfields;
+static PyObject *__pyx_n_s__offset;
+static PyObject *__pyx_n_s__pos;
+static PyObject *__pyx_n_s__qual;
+static PyObject *__pyx_n_s__quote;
+static PyObject *__pyx_n_s__range;
+static PyObject *__pyx_n_s__ref;
+static PyObject *__pyx_n_s__score;
+static PyObject *__pyx_n_s__setAttribute;
+static PyObject *__pyx_n_s__source;
+static PyObject *__pyx_n_s__split;
+static PyObject *__pyx_n_s__start;
+static PyObject *__pyx_n_s__strand;
+static PyObject *__pyx_n_s__strip;
+static PyObject *__pyx_n_s__thickEnd;
+static PyObject *__pyx_n_s__thickStart;
+static PyObject *__pyx_n_s__toDot;
+static PyObject *__pyx_n_s__types;
+static PyObject *__pyx_n_s__update;
+static PyObject *__pyx_n_s__value;
+static PyObject *__pyx_n_s__xrange;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_2;
+static PyObject *__pyx_int_3;
+static PyObject *__pyx_int_4;
+static PyObject *__pyx_int_5;
+static PyObject *__pyx_int_6;
+static PyObject *__pyx_int_7;
+static PyObject *__pyx_int_8;
+static PyObject *__pyx_int_9;
+static PyObject *__pyx_int_10;
+static PyObject *__pyx_int_11;
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":4
+ * from cpython cimport PyString_FromStringAndSize, PyString_AsString, PyString_AS_STRING
+ * 
+ * cdef char * nextItem( char * buffer ):             # <<<<<<<<<<<<<<
+ *     cdef char * pos
+ *     pos = strchr( buffer, '\t' )
+ */
+
+static  char *__pyx_f_10TabProxies_nextItem(char *__pyx_v_buffer) {
+  char *__pyx_v_pos;
+  char *__pyx_r;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("nextItem");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":6
+ * cdef char * nextItem( char * buffer ):
+ *     cdef char * pos
+ *     pos = strchr( buffer, '\t' )             # <<<<<<<<<<<<<<
+ *     if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
+ *     pos[0] = '\0'
+ */
+  __pyx_v_pos = strchr(__pyx_v_buffer, '\t');
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":7
+ *     cdef char * pos
+ *     pos = strchr( buffer, '\t' )
+ *     if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
+ *     pos[0] = '\0'
+ *     pos += 1
+ */
+  __pyx_t_1 = (__pyx_v_pos == NULL);
+  if (__pyx_t_1) {
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __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 = 7; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":8
+ *     pos = strchr( buffer, '\t' )
+ *     if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
+ *     pos[0] = '\0'             # <<<<<<<<<<<<<<
+ *     pos += 1
+ *     return pos
+ */
+  (__pyx_v_pos[0]) = '\x00';
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":9
+ *     if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
+ *     pos[0] = '\0'
+ *     pos += 1             # <<<<<<<<<<<<<<
+ *     return pos
+ * 
+ */
+  __pyx_v_pos += 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":10
+ *     pos[0] = '\0'
+ *     pos += 1
+ *     return pos             # <<<<<<<<<<<<<<
+ * 
+ * cdef char *StrOrEmpty( char * buffer ):
+ */
+  __pyx_r = __pyx_v_pos;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_WriteUnraisable("TabProxies.nextItem");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":12
+ *     return pos
+ * 
+ * cdef char *StrOrEmpty( char * buffer ):             # <<<<<<<<<<<<<<
+ *      if buffer == NULL: return ""
+ *      else: return buffer
+ */
+
+static  char *__pyx_f_10TabProxies_StrOrEmpty(char *__pyx_v_buffer) {
+  char *__pyx_r;
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("StrOrEmpty");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":13
+ * 
+ * cdef char *StrOrEmpty( char * buffer ):
+ *      if buffer == NULL: return ""             # <<<<<<<<<<<<<<
+ *      else: return buffer
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_buffer == NULL);
+  if (__pyx_t_1) {
+    __pyx_r = __pyx_k_2;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":14
+ * cdef char *StrOrEmpty( char * buffer ):
+ *      if buffer == NULL: return ""
+ *      else: return buffer             # <<<<<<<<<<<<<<
+ * 
+ * cdef int isNew( char * p, char * buffer, size_t nbytes ):
+ */
+    __pyx_r = __pyx_v_buffer;
+    goto __pyx_L0;
+  }
+  __pyx_L3:;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":16
+ *      else: return buffer
+ * 
+ * cdef int isNew( char * p, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *      if p == NULL: return 0
+ *      return not (buffer <= p < buffer + nbytes )
+ */
+
+static  int __pyx_f_10TabProxies_isNew(char *__pyx_v_p, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  int __pyx_r;
+  int __pyx_t_1;
+  __Pyx_RefNannySetupContext("isNew");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":17
+ * 
+ * cdef int isNew( char * p, char * buffer, size_t nbytes ):
+ *      if p == NULL: return 0             # <<<<<<<<<<<<<<
+ *      return not (buffer <= p < buffer + nbytes )
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_p == NULL);
+  if (__pyx_t_1) {
+    __pyx_r = 0;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":18
+ * cdef int isNew( char * p, char * buffer, size_t nbytes ):
+ *      if p == NULL: return 0
+ *      return not (buffer <= p < buffer + nbytes )             # <<<<<<<<<<<<<<
+ * 
+ * cdef class TupleProxy:
+ */
+  __pyx_t_1 = (__pyx_v_buffer <= __pyx_v_p);
+  if (__pyx_t_1) {
+    __pyx_t_1 = (__pyx_v_p < (__pyx_v_buffer + __pyx_v_nbytes));
+  }
+  __pyx_r = (!__pyx_t_1);
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":30
+ *     '''
+ * 
+ *     def __cinit__(self ):             # <<<<<<<<<<<<<<
+ *         self.data = NULL
+ *         self.fields = NULL
+ */
+
+static int __pyx_pf_10TabProxies_10TupleProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_10TabProxies_10TupleProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("__cinit__");
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":31
+ * 
+ *     def __cinit__(self ):
+ *         self.data = NULL             # <<<<<<<<<<<<<<
+ *         self.fields = NULL
+ *         self.index = 0
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data = NULL;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":32
+ *     def __cinit__(self ):
+ *         self.data = NULL
+ *         self.fields = NULL             # <<<<<<<<<<<<<<
+ *         self.index = 0
+ *         self.nbytes = 0
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields = NULL;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":33
+ *         self.data = NULL
+ *         self.fields = NULL
+ *         self.index = 0             # <<<<<<<<<<<<<<
+ *         self.nbytes = 0
+ *         self.is_modified = 0
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->index = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":34
+ *         self.fields = NULL
+ *         self.index = 0
+ *         self.nbytes = 0             # <<<<<<<<<<<<<<
+ *         self.is_modified = 0
+ *         self.nfields = 0
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":35
+ *         self.index = 0
+ *         self.nbytes = 0
+ *         self.is_modified = 0             # <<<<<<<<<<<<<<
+ *         self.nfields = 0
+ *         # start counting at field offset
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->is_modified = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":36
+ *         self.nbytes = 0
+ *         self.is_modified = 0
+ *         self.nfields = 0             # <<<<<<<<<<<<<<
+ *         # start counting at field offset
+ *         self.offset = 0
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":38
+ *         self.nfields = 0
+ *         # start counting at field offset
+ *         self.offset = 0             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->offset = 0;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":40
+ *         self.offset = 0
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         cdef int x
+ *         if self.is_modified:
+ */
+
+static void __pyx_pf_10TabProxies_10TupleProxy___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_10TabProxies_10TupleProxy___dealloc__(PyObject *__pyx_v_self) {
+  int __pyx_v_x;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  __Pyx_RefNannySetupContext("__dealloc__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":42
+ *     def __dealloc__(self):
+ *         cdef int x
+ *         if self.is_modified:             # <<<<<<<<<<<<<<
+ *             for x from 0 <= x < self.nfields:
+ *                 if isNew( self.fields[x], self.data, self.nbytes ):
+ */
+  if (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->is_modified) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":43
+ *         cdef int x
+ *         if self.is_modified:
+ *             for x from 0 <= x < self.nfields:             # <<<<<<<<<<<<<<
+ *                 if isNew( self.fields[x], self.data, self.nbytes ):
+ *                     free( self.fields[x] )
+ */
+    __pyx_t_1 = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields;
+    for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_1; __pyx_v_x++) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":44
+ *         if self.is_modified:
+ *             for x from 0 <= x < self.nfields:
+ *                 if isNew( self.fields[x], self.data, self.nbytes ):             # <<<<<<<<<<<<<<
+ *                     free( self.fields[x] )
+ *                     self.fields[x] = NULL
+ */
+      __pyx_t_2 = __pyx_f_10TabProxies_isNew((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_x]), ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data, ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes);
+      if (__pyx_t_2) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":45
+ *             for x from 0 <= x < self.nfields:
+ *                 if isNew( self.fields[x], self.data, self.nbytes ):
+ *                     free( self.fields[x] )             # <<<<<<<<<<<<<<
+ *                     self.fields[x] = NULL
+ * 
+ */
+        free((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_x]));
+
+        /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":46
+ *                 if isNew( self.fields[x], self.data, self.nbytes ):
+ *                     free( self.fields[x] )
+ *                     self.fields[x] = NULL             # <<<<<<<<<<<<<<
+ * 
+ *         if self.data != NULL: free(self.data)
+ */
+        (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_x]) = NULL;
+        goto __pyx_L8;
+      }
+      __pyx_L8:;
+    }
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":48
+ *                     self.fields[x] = NULL
+ * 
+ *         if self.data != NULL: free(self.data)             # <<<<<<<<<<<<<<
+ *         if self.fields != NULL: free( self.fields )
+ * 
+ */
+  __pyx_t_3 = (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data != NULL);
+  if (__pyx_t_3) {
+    free(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data);
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":49
+ * 
+ *         if self.data != NULL: free(self.data)
+ *         if self.fields != NULL: free( self.fields )             # <<<<<<<<<<<<<<
+ * 
+ *     cdef take( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_t_3 = (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields != NULL);
+  if (__pyx_t_3) {
+    free(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields);
+    goto __pyx_L10;
+  }
+  __pyx_L10:;
+
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":51
+ *         if self.fields != NULL: free( self.fields )
+ * 
+ *     cdef take( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''start presenting buffer.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_10TupleProxy_take(struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("take");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":56
+ *         Take ownership of the pointer.
+ *         '''
+ *         self.data = buffer             # <<<<<<<<<<<<<<
+ *         self.nbytes = nbytes
+ *         self.update( buffer, nbytes )
+ */
+  __pyx_v_self->data = __pyx_v_buffer;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":57
+ *         '''
+ *         self.data = buffer
+ *         self.nbytes = nbytes             # <<<<<<<<<<<<<<
+ *         self.update( buffer, nbytes )
+ * 
+ */
+  __pyx_v_self->nbytes = __pyx_v_nbytes;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":58
+ *         self.data = buffer
+ *         self.nbytes = nbytes
+ *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *     cdef present( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.take");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":60
+ *         self.update( buffer, nbytes )
+ * 
+ *     cdef present( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''start presenting buffer.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_10TupleProxy_present(struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("present");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":65
+ *         Do not take ownership of the pointer.
+ *         '''
+ *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *     cdef copy( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.present");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":67
+ *         self.update( buffer, nbytes )
+ * 
+ *     cdef copy( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''start presenting buffer.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_10TupleProxy_copy(struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  int __pyx_v_s;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("copy");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":74
+ *         cdef int s
+ *         # +1 for '\0'
+ *         s = sizeof(char) *  (nbytes + 1)             # <<<<<<<<<<<<<<
+ *         self.data = <char*>malloc( s )
+ *         if self.data == NULL:
+ */
+  __pyx_v_s = ((sizeof(char)) * (__pyx_v_nbytes + 1));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":75
+ *         # +1 for '\0'
+ *         s = sizeof(char) *  (nbytes + 1)
+ *         self.data = <char*>malloc( s )             # <<<<<<<<<<<<<<
+ *         if self.data == NULL:
+ *             raise ValueError("out of memory" )
+ */
+  __pyx_v_self->data = ((char *)malloc(__pyx_v_s));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":76
+ *         s = sizeof(char) *  (nbytes + 1)
+ *         self.data = <char*>malloc( s )
+ *         if self.data == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError("out of memory" )
+ *         self.nbytes = nbytes
+ */
+  __pyx_t_1 = (__pyx_v_self->data == NULL);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":77
+ *         self.data = <char*>malloc( s )
+ *         if self.data == NULL:
+ *             raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ *         self.nbytes = nbytes
+ *         memcpy( <char*>self.data, buffer, s )
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":78
+ *         if self.data == NULL:
+ *             raise ValueError("out of memory" )
+ *         self.nbytes = nbytes             # <<<<<<<<<<<<<<
+ *         memcpy( <char*>self.data, buffer, s )
+ *         self.update( self.data, nbytes )
+ */
+  __pyx_v_self->nbytes = __pyx_v_nbytes;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":79
+ *             raise ValueError("out of memory" )
+ *         self.nbytes = nbytes
+ *         memcpy( <char*>self.data, buffer, s )             # <<<<<<<<<<<<<<
+ *         self.update( self.data, nbytes )
+ * 
+ */
+  memcpy(__pyx_v_self->data, __pyx_v_buffer, __pyx_v_s);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":80
+ *         self.nbytes = nbytes
+ *         memcpy( <char*>self.data, buffer, s )
+ *         self.update( self.data, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ */
+  __pyx_t_3 = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_self->data, __pyx_v_nbytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.copy");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":82
+ *         self.update( self.data, nbytes )
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''initialize fields.'''
+ *         return nbytes / 2
+ */
+
+static  int __pyx_f_10TabProxies_10TupleProxy_getMaxFields(struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_self, size_t __pyx_v_nbytes) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("getMaxFields");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":84
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ *         '''initialize fields.'''
+ *         return nbytes / 2             # <<<<<<<<<<<<<<
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_r = (__pyx_v_nbytes / 2);
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":86
+ *         return nbytes / 2
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''update internal data.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_10TupleProxy_update(struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  char *__pyx_v_pos;
+  char *__pyx_v_old_pos;
+  int __pyx_v_field;
+  int __pyx_v_max_fields;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  __Pyx_RefNannySetupContext("update");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":101
+ *         cdef int max_fields, x
+ * 
+ *         if buffer[nbytes] != 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "incomplete line at %s" % buffer )
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_buffer[__pyx_v_nbytes]) != 0);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":102
+ * 
+ *         if buffer[nbytes] != 0:
+ *             raise ValueError( "incomplete line at %s" % buffer )             # <<<<<<<<<<<<<<
+ * 
+ *         #################################
+ */
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __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 = 102; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":106
+ *         #################################
+ *         # clear data
+ *         if self.fields != NULL: free(self.fields)             # <<<<<<<<<<<<<<
+ * 
+ *         for field from 0 <= field < self.nfields:
+ */
+  __pyx_t_1 = (__pyx_v_self->fields != NULL);
+  if (__pyx_t_1) {
+    free(__pyx_v_self->fields);
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":108
+ *         if self.fields != NULL: free(self.fields)
+ * 
+ *         for field from 0 <= field < self.nfields:             # <<<<<<<<<<<<<<
+ *             if isNew( self.fields[field], self.data, self.nbytes ):
+ *                 free( self.fields[field] )
+ */
+  __pyx_t_4 = __pyx_v_self->nfields;
+  for (__pyx_v_field = 0; __pyx_v_field < __pyx_t_4; __pyx_v_field++) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":109
+ * 
+ *         for field from 0 <= field < self.nfields:
+ *             if isNew( self.fields[field], self.data, self.nbytes ):             # <<<<<<<<<<<<<<
+ *                 free( self.fields[field] )
+ * 
+ */
+    __pyx_t_5 = __pyx_f_10TabProxies_isNew((__pyx_v_self->fields[__pyx_v_field]), __pyx_v_self->data, __pyx_v_self->nbytes);
+    if (__pyx_t_5) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":110
+ *         for field from 0 <= field < self.nfields:
+ *             if isNew( self.fields[field], self.data, self.nbytes ):
+ *                 free( self.fields[field] )             # <<<<<<<<<<<<<<
+ * 
+ *         self.is_modified = self.nfields = 0
+ */
+      free((__pyx_v_self->fields[__pyx_v_field]));
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":112
+ *                 free( self.fields[field] )
+ * 
+ *         self.is_modified = self.nfields = 0             # <<<<<<<<<<<<<<
+ * 
+ *         #################################
+ */
+  __pyx_v_self->is_modified = 0;
+  __pyx_v_self->nfields = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":116
+ *         #################################
+ *         # allocate new
+ *         max_fields = self.getMaxFields( nbytes )             # <<<<<<<<<<<<<<
+ *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
+ *         if self.fields == NULL:
+ */
+  __pyx_v_max_fields = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_self->__pyx_vtab)->getMaxFields(__pyx_v_self, __pyx_v_nbytes);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":117
+ *         # allocate new
+ *         max_fields = self.getMaxFields( nbytes )
+ *         self.fields = <char **>calloc( max_fields, sizeof(char *) )             # <<<<<<<<<<<<<<
+ *         if self.fields == NULL:
+ *             raise ValueError("out of memory" )
+ */
+  __pyx_v_self->fields = ((char **)calloc(__pyx_v_max_fields, (sizeof(char *))));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":118
+ *         max_fields = self.getMaxFields( nbytes )
+ *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
+ *         if self.fields == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError("out of memory" )
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_self->fields == NULL);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":119
+ *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
+ *         if self.fields == NULL:
+ *             raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ * 
+ *         #################################
+ */
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":123
+ *         #################################
+ *         # start filling
+ *         field = 0             # <<<<<<<<<<<<<<
+ *         self.fields[field] = pos = buffer
+ *         field += 1
+ */
+  __pyx_v_field = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":124
+ *         # start filling
+ *         field = 0
+ *         self.fields[field] = pos = buffer             # <<<<<<<<<<<<<<
+ *         field += 1
+ *         old_pos = pos
+ */
+  (__pyx_v_self->fields[__pyx_v_field]) = __pyx_v_buffer;
+  __pyx_v_pos = __pyx_v_buffer;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":125
+ *         field = 0
+ *         self.fields[field] = pos = buffer
+ *         field += 1             # <<<<<<<<<<<<<<
+ *         old_pos = pos
+ * 
+ */
+  __pyx_v_field += 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":126
+ *         self.fields[field] = pos = buffer
+ *         field += 1
+ *         old_pos = pos             # <<<<<<<<<<<<<<
+ * 
+ *         while 1:
+ */
+  __pyx_v_old_pos = __pyx_v_pos;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":128
+ *         old_pos = pos
+ * 
+ *         while 1:             # <<<<<<<<<<<<<<
+ * 
+ *             pos = <char*>memchr( pos, '\t', nbytes )
+ */
+  while (1) {
+    if (!1) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":130
+ *         while 1:
+ * 
+ *             pos = <char*>memchr( pos, '\t', nbytes )             # <<<<<<<<<<<<<<
+ *             if pos == NULL: break
+ *             pos[0] = '\0'
+ */
+    __pyx_v_pos = ((char *)memchr(__pyx_v_pos, '\t', __pyx_v_nbytes));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":131
+ * 
+ *             pos = <char*>memchr( pos, '\t', nbytes )
+ *             if pos == NULL: break             # <<<<<<<<<<<<<<
+ *             pos[0] = '\0'
+ *             pos += 1
+ */
+    __pyx_t_1 = (__pyx_v_pos == NULL);
+    if (__pyx_t_1) {
+      goto __pyx_L10_break;
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":132
+ *             pos = <char*>memchr( pos, '\t', nbytes )
+ *             if pos == NULL: break
+ *             pos[0] = '\0'             # <<<<<<<<<<<<<<
+ *             pos += 1
+ *             self.fields[field] = pos
+ */
+    (__pyx_v_pos[0]) = '\x00';
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":133
+ *             if pos == NULL: break
+ *             pos[0] = '\0'
+ *             pos += 1             # <<<<<<<<<<<<<<
+ *             self.fields[field] = pos
+ *             field += 1
+ */
+    __pyx_v_pos += 1;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":134
+ *             pos[0] = '\0'
+ *             pos += 1
+ *             self.fields[field] = pos             # <<<<<<<<<<<<<<
+ *             field += 1
+ *             if field >= max_fields:
+ */
+    (__pyx_v_self->fields[__pyx_v_field]) = __pyx_v_pos;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":135
+ *             pos += 1
+ *             self.fields[field] = pos
+ *             field += 1             # <<<<<<<<<<<<<<
+ *             if field >= max_fields:
+ *                 raise ValueError("row too large - more than %i fields" % max_fields )
+ */
+    __pyx_v_field += 1;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":136
+ *             self.fields[field] = pos
+ *             field += 1
+ *             if field >= max_fields:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("row too large - more than %i fields" % max_fields )
+ *             nbytes -= pos - old_pos
+ */
+    __pyx_t_1 = (__pyx_v_field >= __pyx_v_max_fields);
+    if (__pyx_t_1) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":137
+ *             field += 1
+ *             if field >= max_fields:
+ *                 raise ValueError("row too large - more than %i fields" % max_fields )             # <<<<<<<<<<<<<<
+ *             nbytes -= pos - old_pos
+ *             if nbytes < 0: break
+ */
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_max_fields); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __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 = 137; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L12;
+    }
+    __pyx_L12:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":138
+ *             if field >= max_fields:
+ *                 raise ValueError("row too large - more than %i fields" % max_fields )
+ *             nbytes -= pos - old_pos             # <<<<<<<<<<<<<<
+ *             if nbytes < 0: break
+ *             old_pos = pos
+ */
+    __pyx_v_nbytes -= (__pyx_v_pos - __pyx_v_old_pos);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":139
+ *                 raise ValueError("row too large - more than %i fields" % max_fields )
+ *             nbytes -= pos - old_pos
+ *             if nbytes < 0: break             # <<<<<<<<<<<<<<
+ *             old_pos = pos
+ * 
+ */
+    __pyx_t_1 = (__pyx_v_nbytes < 0);
+    if (__pyx_t_1) {
+      goto __pyx_L10_break;
+      goto __pyx_L13;
+    }
+    __pyx_L13:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":140
+ *             nbytes -= pos - old_pos
+ *             if nbytes < 0: break
+ *             old_pos = pos             # <<<<<<<<<<<<<<
+ * 
+ *         self.nfields = field
+ */
+    __pyx_v_old_pos = __pyx_v_pos;
+  }
+  __pyx_L10_break:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":142
+ *             old_pos = pos
+ * 
+ *         self.nfields = field             # <<<<<<<<<<<<<<
+ * 
+ *     def __getitem__( self, key ):
+ */
+  __pyx_v_self->nfields = __pyx_v_field;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.update");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":144
+ *         self.nfields = field
+ * 
+ *     def __getitem__( self, key ):             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int i = key
+ */
+
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
+  int __pyx_v_i;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("__getitem__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":146
+ *     def __getitem__( self, key ):
+ * 
+ *         cdef int i = key             # <<<<<<<<<<<<<<
+ *         if i < 0: i += self.nfields
+ *         if i < 0: raise IndexError( "list index out of range" )
+ */
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_key); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_i = __pyx_t_1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":147
+ * 
+ *         cdef int i = key
+ *         if i < 0: i += self.nfields             # <<<<<<<<<<<<<<
+ *         if i < 0: raise IndexError( "list index out of range" )
+ *         i += self.offset
+ */
+  __pyx_t_2 = (__pyx_v_i < 0);
+  if (__pyx_t_2) {
+    __pyx_v_i += ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":148
+ *         cdef int i = key
+ *         if i < 0: i += self.nfields
+ *         if i < 0: raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
+ *         i += self.offset
+ *         if i >= self.nfields:
+ */
+  __pyx_t_2 = (__pyx_v_i < 0);
+  if (__pyx_t_2) {
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":149
+ *         if i < 0: i += self.nfields
+ *         if i < 0: raise IndexError( "list index out of range" )
+ *         i += self.offset             # <<<<<<<<<<<<<<
+ *         if i >= self.nfields:
+ *             raise IndexError( "list index out of range" )
+ */
+  __pyx_v_i += ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->offset;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":150
+ *         if i < 0: raise IndexError( "list index out of range" )
+ *         i += self.offset
+ *         if i >= self.nfields:             # <<<<<<<<<<<<<<
+ *             raise IndexError( "list index out of range" )
+ *         return self.fields[i]
+ */
+  __pyx_t_2 = (__pyx_v_i >= ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":151
+ *         i += self.offset
+ *         if i >= self.nfields:
+ *             raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
+ *         return self.fields[i]
+ * 
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":152
+ *         if i >= self.nfields:
+ *             raise IndexError( "list index out of range" )
+ *         return self.fields[i]             # <<<<<<<<<<<<<<
+ * 
+ *     def _setindex( self, index, value ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = PyBytes_FromString((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_r = ((PyObject *)__pyx_t_3);
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.__getitem__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":154
+ *         return self.fields[i]
+ * 
+ *     def _setindex( self, index, value ):             # <<<<<<<<<<<<<<
+ *         '''set item at idx index.'''
+ *         cdef int idx = index
+ */
+
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy__setindex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_10TabProxies_10TupleProxy__setindex[] = "set item at idx index.";
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy__setindex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_index = 0;
+  PyObject *__pyx_v_value = 0;
+  int __pyx_v_idx;
+  char *__pyx_v_tmp;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  char *__pyx_t_5;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__index,&__pyx_n_s__value,0};
+  __Pyx_RefNannySetupContext("_setindex");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__index);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_setindex", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_setindex") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_index = values[0];
+    __pyx_v_value = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_index = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_setindex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("TabProxies.TupleProxy._setindex");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":156
+ *     def _setindex( self, index, value ):
+ *         '''set item at idx index.'''
+ *         cdef int idx = index             # <<<<<<<<<<<<<<
+ *         if idx < 0: raise IndexError( "list index out of range" )
+ *         if idx >= self.nfields:
+ */
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_idx = __pyx_t_1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":157
+ *         '''set item at idx index.'''
+ *         cdef int idx = index
+ *         if idx < 0: raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
+ *         if idx >= self.nfields:
+ *             raise IndexError( "list index out of range" )
+ */
+  __pyx_t_2 = (__pyx_v_idx < 0);
+  if (__pyx_t_2) {
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":158
+ *         cdef int idx = index
+ *         if idx < 0: raise IndexError( "list index out of range" )
+ *         if idx >= self.nfields:             # <<<<<<<<<<<<<<
+ *             raise IndexError( "list index out of range" )
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_idx >= ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":159
+ *         if idx < 0: raise IndexError( "list index out of range" )
+ *         if idx >= self.nfields:
+ *             raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
+ * 
+ *         if isNew( self.fields[idx], self.data, self.nbytes ):
+ */
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":161
+ *             raise IndexError( "list index out of range" )
+ * 
+ *         if isNew( self.fields[idx], self.data, self.nbytes ):             # <<<<<<<<<<<<<<
+ *             free( self.fields[idx] )
+ * 
+ */
+  __pyx_t_1 = __pyx_f_10TabProxies_isNew((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]), ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data, ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":162
+ * 
+ *         if isNew( self.fields[idx], self.data, self.nbytes ):
+ *             free( self.fields[idx] )             # <<<<<<<<<<<<<<
+ * 
+ *         self.is_modified = 1
+ */
+    free((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]));
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":164
+ *             free( self.fields[idx] )
+ * 
+ *         self.is_modified = 1             # <<<<<<<<<<<<<<
+ * 
+ *         if value == None:
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":166
+ *         self.is_modified = 1
+ * 
+ *         if value == None:             # <<<<<<<<<<<<<<
+ *             self.fields[idx] = NULL
+ *             return
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":167
+ * 
+ *         if value == None:
+ *             self.fields[idx] = NULL             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+    (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]) = NULL;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":168
+ *         if value == None:
+ *             self.fields[idx] = NULL
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         # conversion with error checking
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":171
+ * 
+ *         # conversion with error checking
+ *         cdef char * tmp = PyString_AsString( value )             # <<<<<<<<<<<<<<
+ *         self.fields[idx] = <char*>malloc( (strlen( tmp ) + 1) * sizeof(char) )
+ *         if self.fields[idx] == NULL:
+ */
+  __pyx_t_5 = PyString_AsString(__pyx_v_value); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_tmp = __pyx_t_5;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":172
+ *         # conversion with error checking
+ *         cdef char * tmp = PyString_AsString( value )
+ *         self.fields[idx] = <char*>malloc( (strlen( tmp ) + 1) * sizeof(char) )             # <<<<<<<<<<<<<<
+ *         if self.fields[idx] == NULL:
+ *             raise ValueError("out of memory" )
+ */
+  (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]) = ((char *)malloc(((strlen(__pyx_v_tmp) + 1) * (sizeof(char)))));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":173
+ *         cdef char * tmp = PyString_AsString( value )
+ *         self.fields[idx] = <char*>malloc( (strlen( tmp ) + 1) * sizeof(char) )
+ *         if self.fields[idx] == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError("out of memory" )
+ *         strcpy( self.fields[idx], tmp )
+ */
+  __pyx_t_2 = ((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]) == NULL);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":174
+ *         self.fields[idx] = <char*>malloc( (strlen( tmp ) + 1) * sizeof(char) )
+ *         if self.fields[idx] == NULL:
+ *             raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ *         strcpy( self.fields[idx], tmp )
+ * 
+ */
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L10;
+  }
+  __pyx_L10:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":175
+ *         if self.fields[idx] == NULL:
+ *             raise ValueError("out of memory" )
+ *         strcpy( self.fields[idx], tmp )             # <<<<<<<<<<<<<<
+ * 
+ *     def __setitem__(self, index, value ):
+ */
+  strcpy((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_idx]), __pyx_v_tmp);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("TabProxies.TupleProxy._setindex");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":177
+ *         strcpy( self.fields[idx], tmp )
+ * 
+ *     def __setitem__(self, index, value ):             # <<<<<<<<<<<<<<
+ *         '''set item at *index* to *value*'''
+ *         cdef int i = index
+ */
+
+static int __pyx_pf_10TabProxies_10TupleProxy___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
+static char __pyx_doc_10TabProxies_10TupleProxy___setitem__[] = "set item at *index* to *value*";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_10TupleProxy___setitem__;
+static int __pyx_pf_10TabProxies_10TupleProxy___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
+  int __pyx_v_i;
+  int __pyx_r;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_RefNannySetupContext("__setitem__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":179
+ *     def __setitem__(self, index, value ):
+ *         '''set item at *index* to *value*'''
+ *         cdef int i = index             # <<<<<<<<<<<<<<
+ *         if i < 0: i += self.nfields
+ *         i += self.offset
+ */
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_i = __pyx_t_1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":180
+ *         '''set item at *index* to *value*'''
+ *         cdef int i = index
+ *         if i < 0: i += self.nfields             # <<<<<<<<<<<<<<
+ *         i += self.offset
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_i < 0);
+  if (__pyx_t_2) {
+    __pyx_v_i += ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":181
+ *         cdef int i = index
+ *         if i < 0: i += self.nfields
+ *         i += self.offset             # <<<<<<<<<<<<<<
+ * 
+ *         self._setindex( i, value )
+ */
+  __pyx_v_i += ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->offset;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":183
+ *         i += self.offset
+ * 
+ *         self._setindex( i, value )             # <<<<<<<<<<<<<<
+ * 
+ *     def __len__(self):
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___setindex); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __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);
+  __Pyx_INCREF(__pyx_v_value);
+  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.__setitem__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":185
+ *         self._setindex( i, value )
+ * 
+ *     def __len__(self):             # <<<<<<<<<<<<<<
+ *         return self.nfields
+ * 
+ */
+
+static Py_ssize_t __pyx_pf_10TabProxies_10TupleProxy___len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pf_10TabProxies_10TupleProxy___len__(PyObject *__pyx_v_self) {
+  Py_ssize_t __pyx_r;
+  __Pyx_RefNannySetupContext("__len__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":186
+ * 
+ *     def __len__(self):
+ *         return self.nfields             # <<<<<<<<<<<<<<
+ * 
+ *     def __iter__(self):
+ */
+  __pyx_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":188
+ *         return self.nfields
+ * 
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         self.index = 0
+ *         return self
+ */
+
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannySetupContext("__iter__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":189
+ * 
+ *     def __iter__(self):
+ *         self.index = 0             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->index = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":190
+ *     def __iter__(self):
+ *         self.index = 0
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     def __next__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":192
+ *         return self
+ * 
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
+ *         """
+ */
+
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_10TabProxies_10TupleProxy___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_10TupleProxy___next__;
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___next__(PyObject *__pyx_v_self) {
+  char *__pyx_v_retval;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("__next__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":195
+ *         """python version of next().
+ *         """
+ *         if self.index >= self.nfields:             # <<<<<<<<<<<<<<
+ *             raise StopIteration
+ *         cdef char * retval = self.fields[self.index]
+ */
+  __pyx_t_1 = (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->index >= ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":196
+ *         """
+ *         if self.index >= self.nfields:
+ *             raise StopIteration             # <<<<<<<<<<<<<<
+ *         cdef char * retval = self.fields[self.index]
+ *         self.index += 1
+ */
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":197
+ *         if self.index >= self.nfields:
+ *             raise StopIteration
+ *         cdef char * retval = self.fields[self.index]             # <<<<<<<<<<<<<<
+ *         self.index += 1
+ *         if retval == NULL: return None
+ */
+  __pyx_v_retval = (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->index]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":198
+ *             raise StopIteration
+ *         cdef char * retval = self.fields[self.index]
+ *         self.index += 1             # <<<<<<<<<<<<<<
+ *         if retval == NULL: return None
+ *         else: return retval
+ */
+  ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->index += 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":199
+ *         cdef char * retval = self.fields[self.index]
+ *         self.index += 1
+ *         if retval == NULL: return None             # <<<<<<<<<<<<<<
+ *         else: return retval
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_retval == NULL);
+  if (__pyx_t_1) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":200
+ *         self.index += 1
+ *         if retval == NULL: return None
+ *         else: return retval             # <<<<<<<<<<<<<<
+ * 
+ *     def __str__(self):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_retval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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_L6:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.__next__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":202
+ *         else: return retval
+ * 
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ *         '''return original data'''
+ *         # copy and replace \0 bytes with \t characters
+ */
+
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___str__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_10TabProxies_10TupleProxy___str__[] = "return original data";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_10TupleProxy___str__;
+static PyObject *__pyx_pf_10TabProxies_10TupleProxy___str__(PyObject *__pyx_v_self) {
+  char *__pyx_v_cpy;
+  long __pyx_v_x;
+  PyObject *__pyx_v_result;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  long __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  __Pyx_RefNannySetupContext("__str__");
+  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":205
+ *         '''return original data'''
+ *         # copy and replace \0 bytes with \t characters
+ *         if self.is_modified:             # <<<<<<<<<<<<<<
+ *             # todo: treat NULL values
+ *             return "\t".join( [StrOrEmpty( self.fields[x]) for x in xrange(0, self.nfields ) ] )
+ */
+  if (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->is_modified) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":207
+ *         if self.is_modified:
+ *             # todo: treat NULL values
+ *             return "\t".join( [StrOrEmpty( self.fields[x]) for x in xrange(0, self.nfields ) ] )             # <<<<<<<<<<<<<<
+ *         else:
+ *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nfields;
+    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+      __pyx_v_x = __pyx_t_4;
+      __pyx_t_5 = PyBytes_FromString(__pyx_f_10TabProxies_StrOrEmpty((((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->fields[__pyx_v_x]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+      if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_t_2));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __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_5); __pyx_t_5 = 0;
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":209
+ *             return "\t".join( [StrOrEmpty( self.fields[x]) for x in xrange(0, self.nfields ) ] )
+ *         else:
+ *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )             # <<<<<<<<<<<<<<
+ *             if cpy == NULL:
+ *                 raise ValueError("out of memory" )
+ */
+    __pyx_v_cpy = ((char *)calloc((sizeof(char)), (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes + 1)));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":210
+ *         else:
+ *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
+ *             if cpy == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("out of memory" )
+ *             memcpy( cpy, self.data, self.nbytes+1)
+ */
+    __pyx_t_6 = (__pyx_v_cpy == NULL);
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":211
+ *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
+ *             if cpy == NULL:
+ *                 raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ *             memcpy( cpy, self.data, self.nbytes+1)
+ *             for x from 0 <= x < self.nbytes:
+ */
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":212
+ *             if cpy == NULL:
+ *                 raise ValueError("out of memory" )
+ *             memcpy( cpy, self.data, self.nbytes+1)             # <<<<<<<<<<<<<<
+ *             for x from 0 <= x < self.nbytes:
+ *                 if cpy[x] == '\0': cpy[x] = '\t'
+ */
+    memcpy(__pyx_v_cpy, ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->data, (((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes + 1));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":213
+ *                 raise ValueError("out of memory" )
+ *             memcpy( cpy, self.data, self.nbytes+1)
+ *             for x from 0 <= x < self.nbytes:             # <<<<<<<<<<<<<<
+ *                 if cpy[x] == '\0': cpy[x] = '\t'
+ *             result = PyString_FromStringAndSize(cpy, self.nbytes)
+ */
+    __pyx_t_3 = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes;
+    for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":214
+ *             memcpy( cpy, self.data, self.nbytes+1)
+ *             for x from 0 <= x < self.nbytes:
+ *                 if cpy[x] == '\0': cpy[x] = '\t'             # <<<<<<<<<<<<<<
+ *             result = PyString_FromStringAndSize(cpy, self.nbytes)
+ *             free(cpy)
+ */
+      __pyx_t_6 = ((__pyx_v_cpy[__pyx_v_x]) == '\x00');
+      if (__pyx_t_6) {
+        (__pyx_v_cpy[__pyx_v_x]) = '\t';
+        goto __pyx_L11;
+      }
+      __pyx_L11:;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":215
+ *             for x from 0 <= x < self.nbytes:
+ *                 if cpy[x] == '\0': cpy[x] = '\t'
+ *             result = PyString_FromStringAndSize(cpy, self.nbytes)             # <<<<<<<<<<<<<<
+ *             free(cpy)
+ *             return result
+ */
+    __pyx_t_5 = PyString_FromStringAndSize(__pyx_v_cpy, ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self)->nbytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_v_result);
+    __pyx_v_result = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":216
+ *                 if cpy[x] == '\0': cpy[x] = '\t'
+ *             result = PyString_FromStringAndSize(cpy, self.nbytes)
+ *             free(cpy)             # <<<<<<<<<<<<<<
+ *             return result
+ * 
+ */
+    free(__pyx_v_cpy);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":217
+ *             result = PyString_FromStringAndSize(cpy, self.nbytes)
+ *             free(cpy)
+ *             return result             # <<<<<<<<<<<<<<
+ * 
+ * def toDot( v ):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_result);
+    __pyx_r = __pyx_v_result;
+    goto __pyx_L0;
+  }
+  __pyx_L5:;
+
+  __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_5);
+  __Pyx_AddTraceback("TabProxies.TupleProxy.__str__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_result);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":219
+ *             return result
+ * 
+ * def toDot( v ):             # <<<<<<<<<<<<<<
+ *     '''convert value to '.' if None'''
+ *     if v == None: return "."
+ */
+
+static PyObject *__pyx_pf_10TabProxies_toDot(PyObject *__pyx_self, PyObject *__pyx_v_v); /*proto*/
+static char __pyx_doc_10TabProxies_toDot[] = "convert value to '.' if None";
+static PyObject *__pyx_pf_10TabProxies_toDot(PyObject *__pyx_self, PyObject *__pyx_v_v) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("toDot");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":221
+ * def toDot( v ):
+ *     '''convert value to '.' if None'''
+ *     if v == None: return "."             # <<<<<<<<<<<<<<
+ *     else: return str(v)
+ * 
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_v, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __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 = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+    __pyx_r = ((PyObject *)__pyx_kp_s_8);
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":222
+ *     '''convert value to '.' if None'''
+ *     if v == None: return "."
+ *     else: return str(v)             # <<<<<<<<<<<<<<
+ * 
+ * def quote( v ):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_v);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_v);
+    __Pyx_GIVEREF(__pyx_v_v);
+    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.toDot");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":224
+ *     else: return str(v)
+ * 
+ * def quote( v ):             # <<<<<<<<<<<<<<
+ *     '''return a quoted attribute.'''
+ *     if type(v) in types.StringTypes:
+ */
+
+static PyObject *__pyx_pf_10TabProxies_quote(PyObject *__pyx_self, PyObject *__pyx_v_v); /*proto*/
+static char __pyx_doc_10TabProxies_quote[] = "return a quoted attribute.";
+static PyObject *__pyx_pf_10TabProxies_quote(PyObject *__pyx_self, PyObject *__pyx_v_v) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  __Pyx_RefNannySetupContext("quote");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":226
+ * def quote( v ):
+ *     '''return a quoted attribute.'''
+ *     if type(v) in types.StringTypes:             # <<<<<<<<<<<<<<
+ *         return '"%s"' % v
+ *     else:
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__StringTypes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = ((PySequence_Contains(__pyx_t_2, ((PyObject *)Py_TYPE(__pyx_v_v))))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":227
+ *     '''return a quoted attribute.'''
+ *     if type(v) in types.StringTypes:
+ *         return '"%s"' % v             # <<<<<<<<<<<<<<
+ *     else:
+ *         return str(v)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_v); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __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;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":229
+ *         return '"%s"' % v
+ *     else:
+ *         return str(v)             # <<<<<<<<<<<<<<
+ * 
+ * cdef class GTFProxy( TupleProxy ):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_v);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_v);
+    __Pyx_GIVEREF(__pyx_v_v);
+    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L5:;
+
+  __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("TabProxies.quote");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":245
+ *     '''
+ * 
+ *     def __cinit__(self ):             # <<<<<<<<<<<<<<
+ *         # automatically calls TupleProxy.__cinit__
+ *         self.hasOwnAttributes = False
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("__cinit__");
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":247
+ *     def __cinit__(self ):
+ *         # automatically calls TupleProxy.__cinit__
+ *         self.hasOwnAttributes = False             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->hasOwnAttributes = 0;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":249
+ *         self.hasOwnAttributes = False
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         # automatically calls TupleProxy.__dealloc__
+ *         if self.hasOwnAttributes:
+ */
+
+static void __pyx_pf_10TabProxies_8GTFProxy___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_10TabProxies_8GTFProxy___dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_RefNannySetupContext("__dealloc__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":251
+ *     def __dealloc__(self):
+ *         # automatically calls TupleProxy.__dealloc__
+ *         if self.hasOwnAttributes:             # <<<<<<<<<<<<<<
+ *             free(self.attributes)
+ * 
+ */
+  if (((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->hasOwnAttributes) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":252
+ *         # automatically calls TupleProxy.__dealloc__
+ *         if self.hasOwnAttributes:
+ *             free(self.attributes)             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ */
+    free(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":254
+ *             free(self.attributes)
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''return max number of fields.'''
+ *         return 9
+ */
+
+static  int __pyx_f_10TabProxies_8GTFProxy_getMaxFields(struct __pyx_obj_10TabProxies_GTFProxy *__pyx_v_self, size_t __pyx_v_nbytes) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("getMaxFields");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":256
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ *         '''return max number of fields.'''
+ *         return 9             # <<<<<<<<<<<<<<
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_r = 9;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":258
+ *         return 9
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''update internal data.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_8GTFProxy_update(struct __pyx_obj_10TabProxies_GTFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  char *__pyx_v_cstart;
+  char *__pyx_v_cend;
+  char *__pyx_v_pos;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  char *__pyx_t_4;
+  __Pyx_RefNannySetupContext("update");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":265
+ *         cdef int end
+ *         cdef char * cstart, * cend, * cscore
+ *         self.contig = buffer             # <<<<<<<<<<<<<<
+ *         cdef char * pos
+ * 
+ */
+  __pyx_v_self->contig = __pyx_v_buffer;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":268
+ *         cdef char * pos
+ * 
+ *         if buffer[nbytes] != 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "incomplete line at %s" % buffer )
+ * 
+ */
+  __pyx_t_1 = ((__pyx_v_buffer[__pyx_v_nbytes]) != 0);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":269
+ * 
+ *         if buffer[nbytes] != 0:
+ *             raise ValueError( "incomplete line at %s" % buffer )             # <<<<<<<<<<<<<<
+ * 
+ *         self.source = pos = nextItem( buffer )
+ */
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __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 = 269; __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_ValueError, __pyx_t_2, NULL); 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_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":271
+ *             raise ValueError( "incomplete line at %s" % buffer )
+ * 
+ *         self.source = pos = nextItem( buffer )             # <<<<<<<<<<<<<<
+ *         self.feature = pos = nextItem( pos )
+ *         cstart = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_buffer);
+  __pyx_v_self->source = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":272
+ * 
+ *         self.source = pos = nextItem( buffer )
+ *         self.feature = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         cstart = pos = nextItem( pos )
+ *         cend = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_self->feature = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":273
+ *         self.source = pos = nextItem( buffer )
+ *         self.feature = pos = nextItem( pos )
+ *         cstart = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         cend = pos = nextItem( pos )
+ *         self.score = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_cstart = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":274
+ *         self.feature = pos = nextItem( pos )
+ *         cstart = pos = nextItem( pos )
+ *         cend = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         self.score = pos = nextItem( pos )
+ *         self.strand = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_cend = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":275
+ *         cstart = pos = nextItem( pos )
+ *         cend = pos = nextItem( pos )
+ *         self.score = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         self.strand = pos = nextItem( pos )
+ *         self.frame = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_self->score = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":276
+ *         cend = pos = nextItem( pos )
+ *         self.score = pos = nextItem( pos )
+ *         self.strand = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         self.frame = pos = nextItem( pos )
+ *         self.attributes = pos = nextItem( pos )
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_self->strand = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":277
+ *         self.score = pos = nextItem( pos )
+ *         self.strand = pos = nextItem( pos )
+ *         self.frame = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ *         self.attributes = pos = nextItem( pos )
+ * 
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_self->frame = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":278
+ *         self.strand = pos = nextItem( pos )
+ *         self.frame = pos = nextItem( pos )
+ *         self.attributes = pos = nextItem( pos )             # <<<<<<<<<<<<<<
+ * 
+ *         self.start = atoi( cstart ) - 1
+ */
+  __pyx_t_4 = __pyx_f_10TabProxies_nextItem(__pyx_v_pos);
+  __pyx_v_self->attributes = __pyx_t_4;
+  __pyx_v_pos = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":280
+ *         self.attributes = pos = nextItem( pos )
+ * 
+ *         self.start = atoi( cstart ) - 1             # <<<<<<<<<<<<<<
+ *         self.end = atoi( cend )
+ * 
+ */
+  __pyx_v_self->start = (atoi(__pyx_v_cstart) - 1);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":281
+ * 
+ *         self.start = atoi( cstart ) - 1
+ *         self.end = atoi( cend )             # <<<<<<<<<<<<<<
+ * 
+ *     property contig:
+ */
+  __pyx_v_self->end = atoi(__pyx_v_cend);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.update");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":285
+ *     property contig:
+ *        '''contig of feature.'''
+ *        def __get__( self ): return self.contig             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6contig___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6contig___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->contig); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __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("TabProxies.GTFProxy.contig.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":286
+ *        '''contig of feature.'''
+ *        def __get__( self ): return self.contig
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.contig = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_6contig___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_6contig___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":287
+ *        def __get__( self ): return self.contig
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.contig = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":288
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.contig = value             # <<<<<<<<<<<<<<
+ * 
+ *     property feature:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->contig = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.contig.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":292
+ *     property feature:
+ *        '''feature name.'''
+ *        def __get__( self ): return self.feature             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_7feature___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_7feature___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __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("TabProxies.GTFProxy.feature.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":293
+ *        '''feature name.'''
+ *        def __get__( self ): return self.feature
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.feature = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_7feature___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_7feature___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":294
+ *        def __get__( self ): return self.feature
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.feature = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":295
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.feature = value             # <<<<<<<<<<<<<<
+ * 
+ *     property source:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->feature = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.feature.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":299
+ *     property source:
+ *        '''feature source.'''
+ *        def __get__( self ): return self.source             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6source___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6source___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->source); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __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("TabProxies.GTFProxy.source.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":300
+ *        '''feature source.'''
+ *        def __get__( self ): return self.source
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.source = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_6source___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_6source___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":301
+ *        def __get__( self ): return self.source
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.source = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":302
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.source = value             # <<<<<<<<<<<<<<
+ * 
+ *     property start:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->source = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.source.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":306
+ *     property start:
+ *        '''feature start (in 0-based open/closed coordinates).'''
+ *        def __get__( self ): return self.start             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5start___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5start___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __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("TabProxies.GTFProxy.start.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":307
+ *        '''feature start (in 0-based open/closed coordinates).'''
+ *        def __get__( self ): return self.start
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.start = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_5start___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_5start___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  uint32_t __pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":308
+ *        def __get__( self ): return self.start
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.start = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":309
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.start = value             # <<<<<<<<<<<<<<
+ * 
+ *     property end:
+ */
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.start.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":313
+ *     property end:
+ *        '''feature end (in 0-based open/closed coordinates).'''
+ *        def __get__( self ): return self.end             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_3end___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_3end___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __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("TabProxies.GTFProxy.end.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":314
+ *        '''feature end (in 0-based open/closed coordinates).'''
+ *        def __get__( self ): return self.end
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.end = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_3end___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_3end___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  uint32_t __pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":315
+ *        def __get__( self ): return self.end
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.end = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":316
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.end = value             # <<<<<<<<<<<<<<
+ * 
+ *     property score:
+ */
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.end.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":320
+ *     property score:
+ *        '''feature score.'''
+ *        def __get__( self ):             # <<<<<<<<<<<<<<
+ *            if self.score[0] == '.' and self.score[1] == '\0' :
+ *                return None
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5score___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5score___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":321
+ *        '''feature score.'''
+ *        def __get__( self ):
+ *            if self.score[0] == '.' and self.score[1] == '\0' :             # <<<<<<<<<<<<<<
+ *                return None
+ *            else:
+ */
+  __pyx_t_1 = ((((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->score[0]) == '.');
+  if (__pyx_t_1) {
+    __pyx_t_2 = ((((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->score[1]) == '\x00');
+    __pyx_t_3 = __pyx_t_2;
+  } else {
+    __pyx_t_3 = __pyx_t_1;
+  }
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":322
+ *        def __get__( self ):
+ *            if self.score[0] == '.' and self.score[1] == '\0' :
+ *                return None             # <<<<<<<<<<<<<<
+ *            else:
+ *                return atof(self.score)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":324
+ *                return None
+ *            else:
+ *                return atof(self.score)             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = PyFloat_FromDouble(atof(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->score)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __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_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.score.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":325
+ *            else:
+ *                return atof(self.score)
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.score = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_5score___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_5score___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":326
+ *                return atof(self.score)
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.score = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":327
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.score = value             # <<<<<<<<<<<<<<
+ * 
+ *     property strand:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->score = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.score.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":331
+ *     property strand:
+ *        '''feature strand.'''
+ *        def __get__( self ): return self.strand             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6strand___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_6strand___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __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("TabProxies.GTFProxy.strand.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":332
+ *        '''feature strand.'''
+ *        def __get__( self ): return self.strand
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.strand = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_6strand___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_6strand___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":333
+ *        def __get__( self ): return self.strand
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.strand = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":334
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.strand = value             # <<<<<<<<<<<<<<
+ * 
+ *     property frame:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->strand = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.strand.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":338
+ *     property frame:
+ *        '''feature frame.'''
+ *        def __get__( self ): return self.frame             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5frame___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_5frame___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __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("TabProxies.GTFProxy.frame.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":339
+ *        '''feature frame.'''
+ *        def __get__( self ): return self.frame
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.frame = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_5frame___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_5frame___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":340
+ *        def __get__( self ): return self.frame
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.frame = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":341
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.frame = value             # <<<<<<<<<<<<<<
+ * 
+ *     property attributes:
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->frame = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.frame.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":345
+ *     property attributes:
+ *        '''feature attributes (as a string).'''
+ *        def __get__( self ): return self.attributes             # <<<<<<<<<<<<<<
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_10attributes___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_10attributes___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __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("TabProxies.GTFProxy.attributes.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":346
+ *        '''feature attributes (as a string).'''
+ *        def __get__( self ): return self.attributes
+ *        def __set__( self, value ):             # <<<<<<<<<<<<<<
+ *            self.is_modified = True
+ *            self.attributes = value
+ */
+
+static int __pyx_pf_10TabProxies_8GTFProxy_10attributes___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_10TabProxies_8GTFProxy_10attributes___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  char *__pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":347
+ *        def __get__( self ): return self.attributes
+ *        def __set__( self, value ):
+ *            self.is_modified = True             # <<<<<<<<<<<<<<
+ *            self.attributes = value
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":348
+ *        def __set__( self, value ):
+ *            self.is_modified = True
+ *            self.attributes = value             # <<<<<<<<<<<<<<
+ * 
+ *     def asDict( self ):
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.attributes.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":350
+ *            self.attributes = value
+ * 
+ *     def asDict( self ):             # <<<<<<<<<<<<<<
+ *         """parse attributes - return as dict
+ *         """
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_asDict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy_asDict[] = "parse attributes - return as dict\n        ";
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_asDict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  char *__pyx_v_attributes;
+  PyObject *__pyx_v_fields;
+  PyObject *__pyx_v_result;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_v_d;
+  PyObject *__pyx_v_n;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_v_x;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  Py_ssize_t __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  double __pyx_t_11;
+  int __pyx_t_12;
+  __Pyx_RefNannySetupContext("asDict");
+  __pyx_v_fields = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_d = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":355
+ * 
+ *         # remove comments
+ *         attributes = self.attributes             # <<<<<<<<<<<<<<
+ * 
+ *         # separate into fields
+ */
+  __pyx_v_attributes = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":358
+ * 
+ *         # separate into fields
+ *         fields = [ x.strip() for x in attributes.split(";")[:-1]]             # <<<<<<<<<<<<<<
+ * 
+ *         result = {}
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_3 = PyBytes_FromString(__pyx_v_attributes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __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 = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_10));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
+  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PySequence_GetSlice(__pyx_t_5, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
+    __pyx_t_2 = 0; __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_2 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
+    } else {
+      __pyx_t_3 = PyIter_Next(__pyx_t_5);
+      if (!__pyx_t_3) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    __Pyx_DECREF(__pyx_v_x);
+    __pyx_v_x = __pyx_t_3;
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_INCREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_fields));
+  __pyx_v_fields = __pyx_t_1;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":360
+ *         fields = [ x.strip() for x in attributes.split(";")[:-1]]
+ * 
+ *         result = {}             # <<<<<<<<<<<<<<
+ * 
+ *         for f in fields:
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_result));
+  __pyx_v_result = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":362
+ *         result = {}
+ * 
+ *         for f in fields:             # <<<<<<<<<<<<<<
+ * 
+ *             d = [ x.strip() for x in f.split(" ")]
+ */
+  if (likely(((PyObject *)__pyx_v_fields) != Py_None)) {
+    __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields); __Pyx_INCREF(__pyx_t_1);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  for (;;) {
+    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":364
+ *         for f in fields:
+ * 
+ *             d = [ x.strip() for x in f.split(" ")]             # <<<<<<<<<<<<<<
+ * 
+ *             n,v = d[0], d[1]
+ */
+    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_11));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
+    __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
+      __pyx_t_6 = 0; __pyx_t_3 = __pyx_t_7; __Pyx_INCREF(__pyx_t_3);
+    } else {
+      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
+      } else {
+        __pyx_t_7 = PyIter_Next(__pyx_t_3);
+        if (!__pyx_t_7) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_7);
+      }
+      __Pyx_DECREF(__pyx_v_x);
+      __pyx_v_x = __pyx_t_7;
+      __pyx_t_7 = 0;
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_4 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (unlikely(PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_INCREF(((PyObject *)__pyx_t_5));
+    __Pyx_DECREF(((PyObject *)__pyx_v_d));
+    __pyx_v_d = __pyx_t_5;
+    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":366
+ *             d = [ x.strip() for x in f.split(" ")]
+ * 
+ *             n,v = d[0], d[1]             # <<<<<<<<<<<<<<
+ *             if len(d) > 2: v = d[1:]
+ * 
+ */
+    __pyx_t_5 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_d), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_d), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_v_n);
+    __pyx_v_n = __pyx_t_5;
+    __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_v_v);
+    __pyx_v_v = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":367
+ * 
+ *             n,v = d[0], d[1]
+ *             if len(d) > 2: v = d[1:]             # <<<<<<<<<<<<<<
+ * 
+ *             if v[0] == '"' and v[-1] == '"':
+ */
+    if (unlikely(__pyx_v_d == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    }
+    __pyx_t_6 = PyList_GET_SIZE(((PyObject *)__pyx_v_d)); 
+    __pyx_t_8 = (__pyx_t_6 > 2);
+    if (__pyx_t_8) {
+      __pyx_t_3 = PySequence_GetSlice(((PyObject *)__pyx_v_d), 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = ((PyObject *)__pyx_t_3);
+      __pyx_t_3 = 0;
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":369
+ *             if len(d) > 2: v = d[1:]
+ * 
+ *             if v[0] == '"' and v[-1] == '"':             # <<<<<<<<<<<<<<
+ *                 v = v[1:-1]
+ *             else:
+ */
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_v, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_kp_s_12), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_8) {
+      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_v, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_kp_s_12), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_10 = __pyx_t_9;
+    } else {
+      __pyx_t_10 = __pyx_t_8;
+    }
+    if (__pyx_t_10) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":370
+ * 
+ *             if v[0] == '"' and v[-1] == '"':
+ *                 v = v[1:-1]             # <<<<<<<<<<<<<<
+ *             else:
+ *                 ## try to convert to a value
+ */
+      __pyx_t_3 = PySequence_GetSlice(__pyx_v_v, 1, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_3;
+      __pyx_t_3 = 0;
+      goto __pyx_L12;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":373
+ *             else:
+ *                 ## try to convert to a value
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     v = float( v )
+ *                     v = int( v )
+ */
+      {
+        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+        __Pyx_XGOTREF(__pyx_save_exc_type);
+        __Pyx_XGOTREF(__pyx_save_exc_value);
+        __Pyx_XGOTREF(__pyx_save_exc_tb);
+        /*try:*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":374
+ *                 ## try to convert to a value
+ *                 try:
+ *                     v = float( v )             # <<<<<<<<<<<<<<
+ *                     v = int( v )
+ *                 except ValueError:
+ */
+          __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_v_v); if (unlikely(__pyx_t_11 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __pyx_t_3 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_v_v);
+          __pyx_v_v = __pyx_t_3;
+          __pyx_t_3 = 0;
+
+          /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":375
+ *                 try:
+ *                     v = float( v )
+ *                     v = int( v )             # <<<<<<<<<<<<<<
+ *                 except ValueError:
+ *                     pass
+ */
+          __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_INCREF(__pyx_v_v);
+          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_v);
+          __Pyx_GIVEREF(__pyx_v_v);
+          __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_DECREF(__pyx_v_v);
+          __pyx_v_v = __pyx_t_5;
+          __pyx_t_5 = 0;
+        }
+        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+        goto __pyx_L20_try_end;
+        __pyx_L13_error:;
+        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":376
+ *                     v = float( v )
+ *                     v = int( v )
+ *                 except ValueError:             # <<<<<<<<<<<<<<
+ *                     pass
+ *                 except TypeError:
+ */
+        __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+        if (__pyx_t_12) {
+          PyErr_Restore(0,0,0);
+          goto __pyx_L14_exception_handled;
+        }
+
+        /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":378
+ *                 except ValueError:
+ *                     pass
+ *                 except TypeError:             # <<<<<<<<<<<<<<
+ *                     pass
+ * 
+ */
+        __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
+        if (__pyx_t_12) {
+          PyErr_Restore(0,0,0);
+          goto __pyx_L14_exception_handled;
+        }
+        __Pyx_XGIVEREF(__pyx_save_exc_type);
+        __Pyx_XGIVEREF(__pyx_save_exc_value);
+        __Pyx_XGIVEREF(__pyx_save_exc_tb);
+        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+        goto __pyx_L1_error;
+        __pyx_L14_exception_handled:;
+        __Pyx_XGIVEREF(__pyx_save_exc_type);
+        __Pyx_XGIVEREF(__pyx_save_exc_value);
+        __Pyx_XGIVEREF(__pyx_save_exc_tb);
+        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+        __pyx_L20_try_end:;
+      }
+    }
+    __pyx_L12:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":381
+ *                     pass
+ * 
+ *             result[n] = v             # <<<<<<<<<<<<<<
+ * 
+ *         return result
+ */
+    if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_n, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":383
+ *             result[n] = v
+ * 
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ *     def fromDict( self, d ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_result));
+  __pyx_r = ((PyObject *)__pyx_v_result);
+  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_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.asDict");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_fields);
+  __Pyx_DECREF(__pyx_v_result);
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_DECREF(__pyx_v_d);
+  __Pyx_DECREF(__pyx_v_n);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_DECREF(__pyx_v_x);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":385
+ *         return result
+ * 
+ *     def fromDict( self, d ):             # <<<<<<<<<<<<<<
+ *         '''set attributes from a dictionary.'''
+ *         cdef char * p
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_fromDict(PyObject *__pyx_v_self, PyObject *__pyx_v_d); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy_fromDict[] = "set attributes from a dictionary.";
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_fromDict(PyObject *__pyx_v_self, PyObject *__pyx_v_d) {
+  char *__pyx_v_p;
+  int __pyx_v_l;
+  PyObject *__pyx_v_aa;
+  PyObject *__pyx_v_k;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_v_a;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  char *__pyx_t_9;
+  __Pyx_RefNannySetupContext("fromDict");
+  __pyx_v_aa = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":391
+ * 
+ *         # clean up if this field is set twice
+ *         if self.hasOwnAttributes:             # <<<<<<<<<<<<<<
+ *             free(self.attributes)
+ * 
+ */
+  if (((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->hasOwnAttributes) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":392
+ *         # clean up if this field is set twice
+ *         if self.hasOwnAttributes:
+ *             free(self.attributes)             # <<<<<<<<<<<<<<
+ * 
+ *         aa = []
+ */
+    free(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":394
+ *             free(self.attributes)
+ * 
+ *         aa = []             # <<<<<<<<<<<<<<
+ *         for k,v in d.items():
+ *             if type(v) == types.StringType:
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_aa));
+  __pyx_v_aa = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":395
+ * 
+ *         aa = []
+ *         for k,v in d.items():             # <<<<<<<<<<<<<<
+ *             if type(v) == types.StringType:
+ *                 aa.append( '%s "%s"' % (k,v) )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_d, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __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 = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
+    __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1);
+  } else {
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
+    } else {
+      __pyx_t_3 = PyIter_Next(__pyx_t_1);
+      if (!__pyx_t_3) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
+      PyObject* tuple = __pyx_t_3;
+      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
+      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_v_k);
+      __pyx_v_k = __pyx_t_4;
+      __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_5;
+      __pyx_t_5 = 0;
+    } else {
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_v_k);
+      __pyx_v_k = __pyx_t_4;
+      __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_5;
+      __pyx_t_5 = 0;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":396
+ *         aa = []
+ *         for k,v in d.items():
+ *             if type(v) == types.StringType:             # <<<<<<<<<<<<<<
+ *                 aa.append( '%s "%s"' % (k,v) )
+ *             else:
+ */
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__StringType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_v)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (__pyx_t_7) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":397
+ *         for k,v in d.items():
+ *             if type(v) == types.StringType:
+ *                 aa.append( '%s "%s"' % (k,v) )             # <<<<<<<<<<<<<<
+ *             else:
+ *                 aa.append( '%s %s' % (k,str(v)) )
+ */
+      if (unlikely(__pyx_v_aa == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __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 = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_k);
+      __Pyx_GIVEREF(__pyx_v_k);
+      __Pyx_INCREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_v);
+      __Pyx_GIVEREF(__pyx_v_v);
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_aa), ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+      goto __pyx_L8;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":399
+ *                 aa.append( '%s "%s"' % (k,v) )
+ *             else:
+ *                 aa.append( '%s %s' % (k,str(v)) )             # <<<<<<<<<<<<<<
+ * 
+ *         a = "; ".join( aa ) + ";"
+ */
+      if (unlikely(__pyx_v_aa == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __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 = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_v);
+      __Pyx_GIVEREF(__pyx_v_v);
+      __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_k);
+      __Pyx_GIVEREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_aa), ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    }
+    __pyx_L8:;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":401
+ *                 aa.append( '%s %s' % (k,str(v)) )
+ * 
+ *         a = "; ".join( aa ) + ";"             # <<<<<<<<<<<<<<
+ *         p = a
+ *         l = len(a)
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_15), __pyx_n_s__join); 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_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_v_aa));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_aa));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_aa));
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_v_a);
+  __pyx_v_a = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":402
+ * 
+ *         a = "; ".join( aa ) + ";"
+ *         p = a             # <<<<<<<<<<<<<<
+ *         l = len(a)
+ *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
+ */
+  __pyx_t_9 = PyBytes_AsString(__pyx_v_a); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_p = __pyx_t_9;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":403
+ *         a = "; ".join( aa ) + ";"
+ *         p = a
+ *         l = len(a)             # <<<<<<<<<<<<<<
+ *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
+ *         if self.attributes == NULL:
+ */
+  __pyx_t_2 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_l = __pyx_t_2;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":404
+ *         p = a
+ *         l = len(a)
+ *         self.attributes = <char *>calloc( l + 1, sizeof(char) )             # <<<<<<<<<<<<<<
+ *         if self.attributes == NULL:
+ *             raise ValueError("out of memory" )
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes = ((char *)calloc((__pyx_v_l + 1), (sizeof(char))));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":405
+ *         l = len(a)
+ *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
+ *         if self.attributes == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError("out of memory" )
+ *         memcpy( self.attributes, p, l )
+ */
+  __pyx_t_7 = (((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes == NULL);
+  if (__pyx_t_7) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":406
+ *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
+ *         if self.attributes == NULL:
+ *             raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ *         memcpy( self.attributes, p, l )
+ * 
+ */
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_5, 0, 0);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":407
+ *         if self.attributes == NULL:
+ *             raise ValueError("out of memory" )
+ *         memcpy( self.attributes, p, l )             # <<<<<<<<<<<<<<
+ * 
+ *         self.hasOwnAttributes = True
+ */
+  memcpy(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes, __pyx_v_p, __pyx_v_l);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":409
+ *         memcpy( self.attributes, p, l )
+ * 
+ *         self.hasOwnAttributes = True             # <<<<<<<<<<<<<<
+ *         self.is_modified = True
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->hasOwnAttributes = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":410
+ * 
+ *         self.hasOwnAttributes = True
+ *         self.is_modified = True             # <<<<<<<<<<<<<<
+ * 
+ *     def __str__(self):
+ */
+  ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified = 1;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.fromDict");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_aa);
+  __Pyx_DECREF(__pyx_v_k);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_DECREF(__pyx_v_a);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":412
+ *         self.is_modified = True
+ * 
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ *         cdef char * cpy
+ *         cdef int x
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___str__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  __Pyx_RefNannySetupContext("__str__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":416
+ *         cdef int x
+ * 
+ *         if self.is_modified:             # <<<<<<<<<<<<<<
+ *             return "\t".join(
+ *                 (self.contig,
+ */
+  if (((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->__pyx_base.is_modified) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":417
+ * 
+ *         if self.is_modified:
+ *             return "\t".join(             # <<<<<<<<<<<<<<
+ *                 (self.contig,
+ *                  self.source,
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":418
+ *         if self.is_modified:
+ *             return "\t".join(
+ *                 (self.contig,             # <<<<<<<<<<<<<<
+ *                  self.source,
+ *                  self.feature,
+ */
+    __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->contig); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":419
+ *             return "\t".join(
+ *                 (self.contig,
+ *                  self.source,             # <<<<<<<<<<<<<<
+ *                  self.feature,
+ *                  str(self.start+1),
+ */
+    __pyx_t_3 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->source); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":420
+ *                 (self.contig,
+ *                  self.source,
+ *                  self.feature,             # <<<<<<<<<<<<<<
+ *                  str(self.start+1),
+ *                  str(self.end),
+ */
+    __pyx_t_4 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->feature); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":421
+ *                  self.source,
+ *                  self.feature,
+ *                  str(self.start+1),             # <<<<<<<<<<<<<<
+ *                  str(self.end),
+ *                  toDot(self.score),
+ */
+    __pyx_t_5 = PyInt_FromLong((((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":422
+ *                  self.feature,
+ *                  str(self.start+1),
+ *                  str(self.end),             # <<<<<<<<<<<<<<
+ *                  toDot(self.score),
+ *                  self.strand,
+ */
+    __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_6);
+    __pyx_t_6 = 0;
+    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":423
+ *                  str(self.start+1),
+ *                  str(self.end),
+ *                  toDot(self.score),             # <<<<<<<<<<<<<<
+ *                  self.strand,
+ *                  self.frame,
+ */
+    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__toDot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->score); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __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 = 423; __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_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __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_9); __pyx_t_9 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":424
+ *                  str(self.end),
+ *                  toDot(self.score),
+ *                  self.strand,             # <<<<<<<<<<<<<<
+ *                  self.frame,
+ *                  self.attributes ) )
+ */
+    __pyx_t_9 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->strand); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":425
+ *                  toDot(self.score),
+ *                  self.strand,
+ *                  self.frame,             # <<<<<<<<<<<<<<
+ *                  self.attributes ) )
+ *         else:
+ */
+    __pyx_t_7 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->frame); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":426
+ *                  self.strand,
+ *                  self.frame,
+ *                  self.attributes ) )             # <<<<<<<<<<<<<<
+ *         else:
+ *             return TupleProxy.__str__(self)
+ */
+    __pyx_t_10 = PyBytes_FromString(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+    __pyx_t_11 = PyTuple_New(9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    PyTuple_SET_ITEM(__pyx_t_11, 1, ((PyObject *)__pyx_t_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+    PyTuple_SET_ITEM(__pyx_t_11, 2, ((PyObject *)__pyx_t_4));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_8);
+    __Pyx_GIVEREF(__pyx_t_8);
+    PyTuple_SET_ITEM(__pyx_t_11, 6, ((PyObject *)__pyx_t_9));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
+    PyTuple_SET_ITEM(__pyx_t_11, 7, ((PyObject *)__pyx_t_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+    PyTuple_SET_ITEM(__pyx_t_11, 8, ((PyObject *)__pyx_t_10));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
+    __pyx_t_2 = 0;
+    __pyx_t_3 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_8 = 0;
+    __pyx_t_9 = 0;
+    __pyx_t_7 = 0;
+    __pyx_t_10 = 0;
+    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
+    __Pyx_GIVEREF(__pyx_t_11);
+    __pyx_t_11 = 0;
+    __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_r = __pyx_t_11;
+    __pyx_t_11 = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":428
+ *                  self.attributes ) )
+ *         else:
+ *             return TupleProxy.__str__(self)             # <<<<<<<<<<<<<<
+ * 
+ *     def invert( self, int lcontig ):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_11 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), __pyx_n_s____str__); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_INCREF(__pyx_v_self);
+    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_self);
+    __Pyx_GIVEREF(__pyx_v_self);
+    __pyx_t_1 = PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L5:;
+
+  __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_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.__str__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":430
+ *             return TupleProxy.__str__(self)
+ * 
+ *     def invert( self, int lcontig ):             # <<<<<<<<<<<<<<
+ *         '''invert coordinates to negative strand coordinates
+ * 
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_invert(PyObject *__pyx_v_self, PyObject *__pyx_arg_lcontig); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy_invert[] = "invert coordinates to negative strand coordinates\n        \n        This method will only act if the feature is on the\n        negative strand.";
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_invert(PyObject *__pyx_v_self, PyObject *__pyx_arg_lcontig) {
+  int __pyx_v_lcontig;
+  PyObject *__pyx_v_start;
+  PyObject *__pyx_v_end;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  uint32_t __pyx_t_2;
+  uint32_t __pyx_t_3;
+  uint32_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  __Pyx_RefNannySetupContext("invert");
+  assert(__pyx_arg_lcontig); {
+    __pyx_v_lcontig = __Pyx_PyInt_AsInt(__pyx_arg_lcontig); if (unlikely((__pyx_v_lcontig == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.invert");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_start = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_end = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":436
+ *         negative strand.'''
+ * 
+ *         if self.strand[0] == '-':             # <<<<<<<<<<<<<<
+ *             start = min(self.start, self.end)
+ *             end = max(self.start, self.end)
+ */
+  __pyx_t_1 = ((((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->strand[0]) == '-');
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":437
+ * 
+ *         if self.strand[0] == '-':
+ *             start = min(self.start, self.end)             # <<<<<<<<<<<<<<
+ *             end = max(self.start, self.end)
+ *             self.start, self.end = lcontig - end, lcontig - start
+ */
+    __pyx_t_2 = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end;
+    __pyx_t_3 = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start;
+    if ((__pyx_t_2 < __pyx_t_3)) {
+      __pyx_t_4 = __pyx_t_2;
+    } else {
+      __pyx_t_4 = __pyx_t_3;
+    }
+    __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_v_start);
+    __pyx_v_start = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":438
+ *         if self.strand[0] == '-':
+ *             start = min(self.start, self.end)
+ *             end = max(self.start, self.end)             # <<<<<<<<<<<<<<
+ *             self.start, self.end = lcontig - end, lcontig - start
+ * 
+ */
+    __pyx_t_4 = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end;
+    __pyx_t_2 = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start;
+    if ((__pyx_t_4 > __pyx_t_2)) {
+      __pyx_t_3 = __pyx_t_4;
+    } else {
+      __pyx_t_3 = __pyx_t_2;
+    }
+    __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_v_end);
+    __pyx_v_end = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":439
+ *             start = min(self.start, self.end)
+ *             end = max(self.start, self.end)
+ *             self.start, self.end = lcontig - end, lcontig - start             # <<<<<<<<<<<<<<
+ * 
+ *     def keys( self ):
+ */
+    __pyx_t_5 = PyInt_FromLong(__pyx_v_lcontig); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyNumber_Subtract(__pyx_t_5, __pyx_v_end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_3 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_3 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = PyInt_FromLong(__pyx_v_lcontig); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_v_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_4 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_5); if (unlikely((__pyx_t_4 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->start = __pyx_t_3;
+    ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->end = __pyx_t_4;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.invert");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_start);
+  __Pyx_DECREF(__pyx_v_end);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":441
+ *             self.start, self.end = lcontig - end, lcontig - start
+ * 
+ *     def keys( self ):             # <<<<<<<<<<<<<<
+ *         '''return a list of attributes defined in this entry.'''
+ *         r = self.attributes
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy_keys[] = "return a list of attributes defined in this entry.";
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  char *__pyx_v_r;
+  PyObject *__pyx_v_x;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("keys");
+  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":443
+ *     def keys( self ):
+ *         '''return a list of attributes defined in this entry.'''
+ *         r = self.attributes             # <<<<<<<<<<<<<<
+ *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
+ * 
+ */
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":444
+ *         '''return a list of attributes defined in this entry.'''
+ *         r = self.attributes
+ *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]             # <<<<<<<<<<<<<<
+ * 
+ *     def __getitem__(self, item):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_3 = PyBytes_FromString(__pyx_v_r); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __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 = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_10));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
+  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
+    __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_5; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
+    } else {
+      __pyx_t_5 = PyIter_Next(__pyx_t_3);
+      if (!__pyx_t_5) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_5);
+    }
+    __Pyx_DECREF(__pyx_v_x);
+    __pyx_v_x = __pyx_t_5;
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, ((PyObject *)__pyx_kp_s_2), Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_6) {
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __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 = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_11));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
+      __pyx_t_7 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_7, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_INCREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __Pyx_DECREF(((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_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.keys");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_x);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":446
+ *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
+ * 
+ *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
+ *         return self.__getattr__( item )
+ * 
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("__getitem__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":447
+ * 
+ *     def __getitem__(self, item):
+ *         return self.__getattr__( item )             # <<<<<<<<<<<<<<
+ * 
+ *     def __getattr__(self, item ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_item);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_item);
+  __Pyx_GIVEREF(__pyx_v_item);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __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_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 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_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.__getitem__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":449
+ *         return self.__getattr__( item )
+ * 
+ *     def __getattr__(self, item ):             # <<<<<<<<<<<<<<
+ *         """Generic lookup of attribute from GFF/GTF attributes
+ *         Only called if there *isn't* an attribute with this name
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy___getattr__[] = "Generic lookup of attribute from GFF/GTF attributes \n        Only called if there *isn't* an attribute with this name\n        ";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_8GTFProxy___getattr__;
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
+  char *__pyx_v_start;
+  char *__pyx_v_query;
+  char *__pyx_v_cpy;
+  char *__pyx_v_end;
+  int __pyx_v_l;
+  char *__pyx_v_result;
+  PyObject *__pyx_r = NULL;
+  char *__pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  __Pyx_RefNannySetupContext("__getattr__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":458
+ *         cdef char * end
+ *         cdef int l
+ *         query = item             # <<<<<<<<<<<<<<
+ * 
+ *         start = strstr( self.attributes, query)
+ */
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_item); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_query = __pyx_t_1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":460
+ *         query = item
+ * 
+ *         start = strstr( self.attributes, query)             # <<<<<<<<<<<<<<
+ *         if start == NULL:
+ *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
+ */
+  __pyx_v_start = strstr(((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_v_self)->attributes, __pyx_v_query);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":461
+ * 
+ *         start = strstr( self.attributes, query)
+ *         if start == NULL:             # <<<<<<<<<<<<<<
+ *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_start == NULL);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":462
+ *         start = strstr( self.attributes, query)
+ *         if start == NULL:
+ *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )             # <<<<<<<<<<<<<<
+ * 
+ *         start += strlen(query) + 1
+ */
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), __pyx_v_item); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __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_AttributeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":464
+ *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
+ * 
+ *         start += strlen(query) + 1             # <<<<<<<<<<<<<<
+ *         # skip gaps before
+ *         while start[0] == " ": start += 1
+ */
+  __pyx_v_start += (strlen(__pyx_v_query) + 1);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":466
+ *         start += strlen(query) + 1
+ *         # skip gaps before
+ *         while start[0] == " ": start += 1             # <<<<<<<<<<<<<<
+ *         if start[0] == '"':
+ *             start += 1
+ */
+  while (1) {
+    __pyx_t_2 = ((__pyx_v_start[0]) == ' ');
+    if (!__pyx_t_2) break;
+    __pyx_v_start += 1;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":467
+ *         # skip gaps before
+ *         while start[0] == " ": start += 1
+ *         if start[0] == '"':             # <<<<<<<<<<<<<<
+ *             start += 1
+ *             end = start
+ */
+  __pyx_t_2 = ((__pyx_v_start[0]) == '"');
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":468
+ *         while start[0] == " ": start += 1
+ *         if start[0] == '"':
+ *             start += 1             # <<<<<<<<<<<<<<
+ *             end = start
+ *             while end[0] != '\0' and end[0] != '"': end += 1
+ */
+    __pyx_v_start += 1;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":469
+ *         if start[0] == '"':
+ *             start += 1
+ *             end = start             # <<<<<<<<<<<<<<
+ *             while end[0] != '\0' and end[0] != '"': end += 1
+ *             l = end - start + 1
+ */
+    __pyx_v_end = __pyx_v_start;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":470
+ *             start += 1
+ *             end = start
+ *             while end[0] != '\0' and end[0] != '"': end += 1             # <<<<<<<<<<<<<<
+ *             l = end - start + 1
+ *             cpy = <char*>calloc( l, sizeof(char ) )
+ */
+    while (1) {
+      __pyx_t_2 = ((__pyx_v_end[0]) != '\x00');
+      if (__pyx_t_2) {
+        __pyx_t_5 = ((__pyx_v_end[0]) != '"');
+        __pyx_t_6 = __pyx_t_5;
+      } else {
+        __pyx_t_6 = __pyx_t_2;
+      }
+      if (!__pyx_t_6) break;
+      __pyx_v_end += 1;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":471
+ *             end = start
+ *             while end[0] != '\0' and end[0] != '"': end += 1
+ *             l = end - start + 1             # <<<<<<<<<<<<<<
+ *             cpy = <char*>calloc( l, sizeof(char ) )
+ *             if cpy == NULL: raise ValueError("out of memory" )
+ */
+    __pyx_v_l = ((__pyx_v_end - __pyx_v_start) + 1);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":472
+ *             while end[0] != '\0' and end[0] != '"': end += 1
+ *             l = end - start + 1
+ *             cpy = <char*>calloc( l, sizeof(char ) )             # <<<<<<<<<<<<<<
+ *             if cpy == NULL: raise ValueError("out of memory" )
+ *             memcpy( cpy, start, l )
+ */
+    __pyx_v_cpy = ((char *)calloc(__pyx_v_l, (sizeof(char))));
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":473
+ *             l = end - start + 1
+ *             cpy = <char*>calloc( l, sizeof(char ) )
+ *             if cpy == NULL: raise ValueError("out of memory" )             # <<<<<<<<<<<<<<
+ *             memcpy( cpy, start, l )
+ *             cpy[l-1] = '\0'
+ */
+    __pyx_t_6 = (__pyx_v_cpy == NULL);
+    if (__pyx_t_6) {
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_4, 0, 0);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":474
+ *             cpy = <char*>calloc( l, sizeof(char ) )
+ *             if cpy == NULL: raise ValueError("out of memory" )
+ *             memcpy( cpy, start, l )             # <<<<<<<<<<<<<<
+ *             cpy[l-1] = '\0'
+ *             result = cpy
+ */
+    memcpy(__pyx_v_cpy, __pyx_v_start, __pyx_v_l);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":475
+ *             if cpy == NULL: raise ValueError("out of memory" )
+ *             memcpy( cpy, start, l )
+ *             cpy[l-1] = '\0'             # <<<<<<<<<<<<<<
+ *             result = cpy
+ *             free(cpy)
+ */
+    (__pyx_v_cpy[(__pyx_v_l - 1)]) = '\x00';
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":476
+ *             memcpy( cpy, start, l )
+ *             cpy[l-1] = '\0'
+ *             result = cpy             # <<<<<<<<<<<<<<
+ *             free(cpy)
+ *             return result
+ */
+    __pyx_v_result = __pyx_v_cpy;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":477
+ *             cpy[l-1] = '\0'
+ *             result = cpy
+ *             free(cpy)             # <<<<<<<<<<<<<<
+ *             return result
+ *         else:
+ */
+    free(__pyx_v_cpy);
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":478
+ *             result = cpy
+ *             free(cpy)
+ *             return result             # <<<<<<<<<<<<<<
+ *         else:
+ *             return start
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_r = ((PyObject *)__pyx_t_4);
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":480
+ *             return result
+ *         else:
+ *             return start             # <<<<<<<<<<<<<<
+ * 
+ *     def setAttribute( self, name, value ):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = PyBytes_FromString(__pyx_v_start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_r = ((PyObject *)__pyx_t_4);
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L8:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("TabProxies.GTFProxy.__getattr__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":482
+ *             return start
+ * 
+ *     def setAttribute( self, name, value ):             # <<<<<<<<<<<<<<
+ *         '''convenience method to set an attribute.'''
+ *         r = self.asDict()
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_setAttribute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_10TabProxies_8GTFProxy_setAttribute[] = "convenience method to set an attribute.";
+static PyObject *__pyx_pf_10TabProxies_8GTFProxy_setAttribute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_name = 0;
+  PyObject *__pyx_v_value = 0;
+  PyObject *__pyx_v_r;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__value,0};
+  __Pyx_RefNannySetupContext("setAttribute");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setAttribute", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setAttribute") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_name = values[0];
+    __pyx_v_value = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setAttribute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("TabProxies.GTFProxy.setAttribute");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_r = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":484
+ *     def setAttribute( self, name, value ):
+ *         '''convenience method to set an attribute.'''
+ *         r = self.asDict()             # <<<<<<<<<<<<<<
+ *         r[name] = value
+ *         self.fromDict( r )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__asDict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __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 = 484; __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_r);
+  __pyx_v_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":485
+ *         '''convenience method to set an attribute.'''
+ *         r = self.asDict()
+ *         r[name] = value             # <<<<<<<<<<<<<<
+ *         self.fromDict( r )
+ * 
+ */
+  if (PyObject_SetItem(__pyx_v_r, __pyx_v_name, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":486
+ *         r = self.asDict()
+ *         r[name] = value
+ *         self.fromDict( r )             # <<<<<<<<<<<<<<
+ * 
+ * cdef class NamedTupleProxy( TupleProxy ):
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__fromDict); 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_t_1 = PyTuple_New(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_INCREF(__pyx_v_r);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_r);
+  __Pyx_GIVEREF(__pyx_v_r);
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __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_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  __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("TabProxies.GTFProxy.setAttribute");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_r);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":492
+ *     map_key2field = {}
+ * 
+ *     def __setattr__(self, key, value ):             # <<<<<<<<<<<<<<
+ *         '''set attribute.'''
+ *         cdef int idx
+ */
+
+static int __pyx_pf_10TabProxies_15NamedTupleProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
+static char __pyx_doc_10TabProxies_15NamedTupleProxy___setattr__[] = "set attribute.";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_15NamedTupleProxy___setattr__;
+static int __pyx_pf_10TabProxies_15NamedTupleProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
+  int __pyx_v_idx;
+  PyObject *__pyx_v_f;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  __Pyx_RefNannySetupContext("__setattr__");
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":495
+ *         '''set attribute.'''
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]             # <<<<<<<<<<<<<<
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__map_key2field); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+    PyObject* tuple = __pyx_t_2;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_v_idx = __pyx_t_4;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+  } else {
+    __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_idx = __pyx_t_4;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":496
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]
+ *         if self.nfields < idx:             # <<<<<<<<<<<<<<
+ *             raise KeyError( "field %s not set" % key )
+ *         TupleProxy.__setitem__(self, idx, str(value) )
+ */
+  __pyx_t_6 = (((struct __pyx_obj_10TabProxies_NamedTupleProxy *)__pyx_v_self)->__pyx_base.nfields < __pyx_v_idx);
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":497
+ *         idx, f = self.map_key2field[key]
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )             # <<<<<<<<<<<<<<
+ *         TupleProxy.__setitem__(self, idx, str(value) )
+ * 
+ */
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":498
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )
+ *         TupleProxy.__setitem__(self, idx, str(value) )             # <<<<<<<<<<<<<<
+ * 
+ *     def __getattr__(self, key ):
+ */
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), __pyx_n_s____setitem__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __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 = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_value);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __pyx_t_3 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5);
+  __Pyx_AddTraceback("TabProxies.NamedTupleProxy.__setattr__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":500
+ *         TupleProxy.__setitem__(self, idx, str(value) )
+ * 
+ *     def __getattr__(self, key ):             # <<<<<<<<<<<<<<
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]
+ */
+
+static PyObject *__pyx_pf_10TabProxies_15NamedTupleProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_15NamedTupleProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
+  int __pyx_v_idx;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  __Pyx_RefNannySetupContext("__getattr__");
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":502
+ *     def __getattr__(self, key ):
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]             # <<<<<<<<<<<<<<
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__map_key2field); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+    PyObject* tuple = __pyx_t_2;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_v_idx = __pyx_t_4;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+  } else {
+    __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_idx = __pyx_t_4;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":503
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]
+ *         if self.nfields < idx:             # <<<<<<<<<<<<<<
+ *             raise KeyError( "field %s not set" % key )
+ *         return f( self.fields[idx] )
+ */
+  __pyx_t_6 = (((struct __pyx_obj_10TabProxies_NamedTupleProxy *)__pyx_v_self)->__pyx_base.nfields < __pyx_v_idx);
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":504
+ *         idx, f = self.map_key2field[key]
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )             # <<<<<<<<<<<<<<
+ *         return f( self.fields[idx] )
+ * 
+ */
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":505
+ *         if self.nfields < idx:
+ *             raise KeyError( "field %s not set" % key )
+ *         return f( self.fields[idx] )             # <<<<<<<<<<<<<<
+ * 
+ * cdef class BedProxy( NamedTupleProxy ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_10TabProxies_NamedTupleProxy *)__pyx_v_self)->__pyx_base.fields[__pyx_v_idx])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_v_f, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __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_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("TabProxies.NamedTupleProxy.__getattr__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":526
+ *         'blockStarts': (11,str), }
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''return max number of fields.'''
+ *         return 12
+ */
+
+static  int __pyx_f_10TabProxies_8BedProxy_getMaxFields(struct __pyx_obj_10TabProxies_BedProxy *__pyx_v_self, size_t __pyx_v_nbytes) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("getMaxFields");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":528
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ *         '''return max number of fields.'''
+ *         return 12             # <<<<<<<<<<<<<<
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):
+ */
+  __pyx_r = 12;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":530
+ *         return 12
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''update internal data.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_8BedProxy_update(struct __pyx_obj_10TabProxies_BedProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("update");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":535
+ *         nbytes does not include the terminal '\0'.
+ *         '''
+ *         TupleProxy.update( self, buffer, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *         if self.nfields < 3:
+ */
+  __pyx_t_1 = __pyx_vtabptr_10TabProxies_TupleProxy->update(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self), __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":537
+ *         TupleProxy.update( self, buffer, nbytes )
+ * 
+ *         if self.nfields < 3:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "bed format requires at least three columns" )
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_self->__pyx_base.__pyx_base.nfields < 3);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":538
+ * 
+ *         if self.nfields < 3:
+ *             raise ValueError( "bed format requires at least three columns" )             # <<<<<<<<<<<<<<
+ * 
+ *         # determines bed format
+ */
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_18));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":541
+ * 
+ *         # determines bed format
+ *         self.bedfields = self.nfields             # <<<<<<<<<<<<<<
+ * 
+ *         # do automatic conversion
+ */
+  __pyx_v_self->bedfields = __pyx_v_self->__pyx_base.__pyx_base.nfields;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":544
+ * 
+ *         # do automatic conversion
+ *         self.contig = self.fields[0]             # <<<<<<<<<<<<<<
+ *         self.start = atoi( self.fields[1] )
+ *         self.end = atoi( self.fields[2] )
+ */
+  __pyx_v_self->contig = (__pyx_v_self->__pyx_base.__pyx_base.fields[0]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":545
+ *         # do automatic conversion
+ *         self.contig = self.fields[0]
+ *         self.start = atoi( self.fields[1] )             # <<<<<<<<<<<<<<
+ *         self.end = atoi( self.fields[2] )
+ * 
+ */
+  __pyx_v_self->start = atoi((__pyx_v_self->__pyx_base.__pyx_base.fields[1]));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":546
+ *         self.contig = self.fields[0]
+ *         self.start = atoi( self.fields[1] )
+ *         self.end = atoi( self.fields[2] )             # <<<<<<<<<<<<<<
+ * 
+ *     # __setattr__ in base class seems to take precedence
+ */
+  __pyx_v_self->end = atoi((__pyx_v_self->__pyx_base.__pyx_base.fields[2]));
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.BedProxy.update");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":555
+ *     #    def __get__( self ): return self.end
+ * 
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int save_fields = self.nfields
+ */
+
+static PyObject *__pyx_pf_10TabProxies_8BedProxy___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_10TabProxies_8BedProxy___str__(PyObject *__pyx_v_self) {
+  int __pyx_v_save_fields;
+  PyObject *__pyx_v_retval;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("__str__");
+  __pyx_v_retval = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":557
+ *     def __str__(self):
+ * 
+ *         cdef int save_fields = self.nfields             # <<<<<<<<<<<<<<
+ *         # ensure fields to use correct format
+ *         self.nfields = self.bedfields
+ */
+  __pyx_v_save_fields = ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->__pyx_base.__pyx_base.nfields;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":559
+ *         cdef int save_fields = self.nfields
+ *         # ensure fields to use correct format
+ *         self.nfields = self.bedfields             # <<<<<<<<<<<<<<
+ *         retval = TupleProxy.__str__( self )
+ *         self.nfields = save_fields
+ */
+  ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->__pyx_base.__pyx_base.nfields = ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->bedfields;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":560
+ *         # ensure fields to use correct format
+ *         self.nfields = self.bedfields
+ *         retval = TupleProxy.__str__( self )             # <<<<<<<<<<<<<<
+ *         self.nfields = save_fields
+ *         return retval
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), __pyx_n_s____str__); 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_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_retval);
+  __pyx_v_retval = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":561
+ *         self.nfields = self.bedfields
+ *         retval = TupleProxy.__str__( self )
+ *         self.nfields = save_fields             # <<<<<<<<<<<<<<
+ *         return retval
+ * 
+ */
+  ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->__pyx_base.__pyx_base.nfields = __pyx_v_save_fields;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":562
+ *         retval = TupleProxy.__str__( self )
+ *         self.nfields = save_fields
+ *         return retval             # <<<<<<<<<<<<<<
+ * 
+ *     def __setattr__(self, key, value ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_retval);
+  __pyx_r = __pyx_v_retval;
+  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_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("TabProxies.BedProxy.__str__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_retval);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":564
+ *         return retval
+ * 
+ *     def __setattr__(self, key, value ):             # <<<<<<<<<<<<<<
+ *         '''set attribute.'''
+ *         if key == "start": self.start = value
+ */
+
+static int __pyx_pf_10TabProxies_8BedProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
+static char __pyx_doc_10TabProxies_8BedProxy___setattr__[] = "set attribute.";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_8BedProxy___setattr__;
+static int __pyx_pf_10TabProxies_8BedProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
+  int __pyx_v_idx;
+  PyObject *__pyx_v_f;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  uint32_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("__setattr__");
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":566
+ *     def __setattr__(self, key, value ):
+ *         '''set attribute.'''
+ *         if key == "start": self.start = value             # <<<<<<<<<<<<<<
+ *         elif key == "end": self.end = value
+ * 
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__start), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __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 = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __pyx_t_3 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_3 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->start = __pyx_t_3;
+    goto __pyx_L5;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":567
+ *         '''set attribute.'''
+ *         if key == "start": self.start = value
+ *         elif key == "end": self.end = value             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int idx
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__end), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __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 = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __pyx_t_3 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_3 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_v_self)->end = __pyx_t_3;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":570
+ * 
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]             # <<<<<<<<<<<<<<
+ *         TupleProxy._setindex(self, idx, str(value) )
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__map_key2field); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
+    PyObject* tuple = __pyx_t_4;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_v_idx = __pyx_t_6;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+  } else {
+    __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_v_idx = __pyx_t_6;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":571
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]
+ *         TupleProxy._setindex(self, idx, str(value) )             # <<<<<<<<<<<<<<
+ * 
+ * cdef class VCFProxy( NamedTupleProxy ):
+ */
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), __pyx_n_s___setindex); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_value);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  __pyx_t_5 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("TabProxies.BedProxy.__setattr__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":589
+ *         'format' : (8,str) }
+ * 
+ *     def __cinit__(self ):             # <<<<<<<<<<<<<<
+ *         # automatically calls TupleProxy.__cinit__
+ *         # start indexed access at genotypes
+ */
+
+static int __pyx_pf_10TabProxies_8VCFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_10TabProxies_8VCFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannySetupContext("__cinit__");
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":592
+ *         # automatically calls TupleProxy.__cinit__
+ *         # start indexed access at genotypes
+ *         self.offset = 9             # <<<<<<<<<<<<<<
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):
+ */
+  ((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_v_self)->__pyx_base.__pyx_base.offset = 9;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":594
+ *         self.offset = 9
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''update internal data.
+ * 
+ */
+
+static  PyObject *__pyx_f_10TabProxies_8VCFProxy_update(struct __pyx_obj_10TabProxies_VCFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("update");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":599
+ *         nbytes does not include the terminal '\0'.
+ *         '''
+ *         TupleProxy.update( self, buffer, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *         self.contig = self.fields[0]
+ */
+  __pyx_t_1 = __pyx_vtabptr_10TabProxies_TupleProxy->update(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self), __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":601
+ *         TupleProxy.update( self, buffer, nbytes )
+ * 
+ *         self.contig = self.fields[0]             # <<<<<<<<<<<<<<
+ *         # vcf counts from 1 - correct here
+ *         self.pos = atoi( self.fields[1] ) - 1
+ */
+  __pyx_v_self->contig = (__pyx_v_self->__pyx_base.__pyx_base.fields[0]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":603
+ *         self.contig = self.fields[0]
+ *         # vcf counts from 1 - correct here
+ *         self.pos = atoi( self.fields[1] ) - 1             # <<<<<<<<<<<<<<
+ * 
+ *     def __len__(self):
+ */
+  __pyx_v_self->pos = (atoi((__pyx_v_self->__pyx_base.__pyx_base.fields[1])) - 1);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("TabProxies.VCFProxy.update");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":605
+ *         self.pos = atoi( self.fields[1] ) - 1
+ * 
+ *     def __len__(self):             # <<<<<<<<<<<<<<
+ *         return max(0, self.nfields - 9)
+ * 
+ */
+
+static Py_ssize_t __pyx_pf_10TabProxies_8VCFProxy___len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pf_10TabProxies_8VCFProxy___len__(PyObject *__pyx_v_self) {
+  Py_ssize_t __pyx_r;
+  long __pyx_t_1;
+  long __pyx_t_2;
+  long __pyx_t_3;
+  __Pyx_RefNannySetupContext("__len__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":606
+ * 
+ *     def __len__(self):
+ *         return max(0, self.nfields - 9)             # <<<<<<<<<<<<<<
+ * 
+ *     def __setattr__(self, key, value ):
+ */
+  __pyx_t_1 = (((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_v_self)->__pyx_base.__pyx_base.nfields - 9);
+  __pyx_t_2 = 0;
+  if ((__pyx_t_1 > __pyx_t_2)) {
+    __pyx_t_3 = __pyx_t_1;
+  } else {
+    __pyx_t_3 = __pyx_t_2;
+  }
+  __pyx_r = __pyx_t_3;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":608
+ *         return max(0, self.nfields - 9)
+ * 
+ *     def __setattr__(self, key, value ):             # <<<<<<<<<<<<<<
+ *         '''set attribute.'''
+ *         if key == "pos":
+ */
+
+static int __pyx_pf_10TabProxies_8VCFProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
+static char __pyx_doc_10TabProxies_8VCFProxy___setattr__[] = "set attribute.";
+struct wrapperbase __pyx_wrapperbase_10TabProxies_8VCFProxy___setattr__;
+static int __pyx_pf_10TabProxies_8VCFProxy___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
+  int __pyx_v_idx;
+  PyObject *__pyx_v_f;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  uint32_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("__setattr__");
+  __Pyx_INCREF(__pyx_v_value);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":610
+ *     def __setattr__(self, key, value ):
+ *         '''set attribute.'''
+ *         if key == "pos":             # <<<<<<<<<<<<<<
+ *             self.pos = value
+ *             value += 1
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__pos), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __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 = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":611
+ *         '''set attribute.'''
+ *         if key == "pos":
+ *             self.pos = value             # <<<<<<<<<<<<<<
+ *             value += 1
+ * 
+ */
+    __pyx_t_3 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_3 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_v_self)->pos = __pyx_t_3;
+
+    /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":612
+ *         if key == "pos":
+ *             self.pos = value
+ *             value += 1             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int idx
+ */
+    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_value, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_value);
+    __pyx_v_value = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":615
+ * 
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]             # <<<<<<<<<<<<<<
+ *         TupleProxy._setindex(self, idx, str(value) )
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__map_key2field); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
+    PyObject* tuple = __pyx_t_4;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_v_idx = __pyx_t_6;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+  } else {
+    __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_v_idx = __pyx_t_6;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":616
+ *         cdef int idx
+ *         idx, f = self.map_key2field[key]
+ *         TupleProxy._setindex(self, idx, str(value) )             # <<<<<<<<<<<<<<
+ * 
+ */
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), __pyx_n_s___setindex); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_value);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  __pyx_t_5 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("TabProxies.VCFProxy.__setattr__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_DECREF(__pyx_v_value);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_vtable_10TabProxies_TupleProxy;
+
+static PyObject *__pyx_tp_new_10TabProxies_TupleProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_10TabProxies_TupleProxy *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_10TabProxies_TupleProxy *)o);
+  p->__pyx_vtab = __pyx_vtabptr_10TabProxies_TupleProxy;
+  if (__pyx_pf_10TabProxies_10TupleProxy___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_10TabProxies_TupleProxy(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_10TabProxies_10TupleProxy___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_sq_item_10TabProxies_TupleProxy(PyObject *o, Py_ssize_t i) {
+  PyObject *r;
+  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+  Py_DECREF(x);
+  return r;
+}
+
+static int __pyx_mp_ass_subscript_10TabProxies_TupleProxy(PyObject *o, PyObject *i, PyObject *v) {
+  if (v) {
+    return __pyx_pf_10TabProxies_10TupleProxy___setitem__(o, i, v);
+  }
+  else {
+    PyErr_Format(PyExc_NotImplementedError,
+      "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
+    return -1;
+  }
+}
+
+static PyMethodDef __pyx_methods_10TabProxies_TupleProxy[] = {
+  {__Pyx_NAMESTR("_setindex"), (PyCFunction)__pyx_pf_10TabProxies_10TupleProxy__setindex, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10TabProxies_10TupleProxy__setindex)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_10TabProxies_10TupleProxy___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_10TabProxies_10TupleProxy___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_TupleProxy = {
+  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_TupleProxy = {
+  __pyx_pf_10TabProxies_10TupleProxy___len__, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  __pyx_sq_item_10TabProxies_TupleProxy, /*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_TupleProxy = {
+  __pyx_pf_10TabProxies_10TupleProxy___len__, /*mp_length*/
+  __pyx_pf_10TabProxies_10TupleProxy___getitem__, /*mp_subscript*/
+  __pyx_mp_ass_subscript_10TabProxies_TupleProxy, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_TupleProxy = {
+  #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
+};
+
+PyTypeObject __pyx_type_10TabProxies_TupleProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("TabProxies.TupleProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_10TabProxies_TupleProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_10TabProxies_TupleProxy, /*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_TupleProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_TupleProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_TupleProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_10TabProxies_10TupleProxy___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_TupleProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("Proxy class for access to parsed row as a tuple.\n\n    This class represents a table row for fast read-access.\n\n    Access to individual fields is via the [] operator.\n    \n    Only read-only access is implemented.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_10TabProxies_10TupleProxy___iter__, /*tp_iter*/
+  __pyx_pf_10TabProxies_10TupleProxy___next__, /*tp_iternext*/
+  __pyx_methods_10TabProxies_TupleProxy, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_10TabProxies_TupleProxy, /*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_10TabProxies_GTFProxy __pyx_vtable_10TabProxies_GTFProxy;
+
+static PyObject *__pyx_tp_new_10TabProxies_GTFProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_10TabProxies_GTFProxy *p;
+  PyObject *o = __pyx_tp_new_10TabProxies_TupleProxy(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_10TabProxies_GTFProxy *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10TabProxies_TupleProxy*)__pyx_vtabptr_10TabProxies_GTFProxy;
+  if (__pyx_pf_10TabProxies_8GTFProxy___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_10TabProxies_GTFProxy(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_10TabProxies_8GTFProxy___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  __pyx_tp_dealloc_10TabProxies_TupleProxy(o);
+}
+static PyObject *__pyx_sq_item_10TabProxies_GTFProxy(PyObject *o, Py_ssize_t i) {
+  PyObject *r;
+  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+  Py_DECREF(x);
+  return r;
+}
+
+static PyObject *__pyx_tp_getattro_10TabProxies_GTFProxy(PyObject *o, PyObject *n) {
+  PyObject *v = PyObject_GenericGetAttr(o, n);
+  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+    PyErr_Clear();
+    v = __pyx_pf_10TabProxies_8GTFProxy___getattr__(o, n);
+  }
+  return v;
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_contig(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_6contig___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_contig(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_6contig___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_feature(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_7feature___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_feature(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_7feature___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_source(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_6source___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_source(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_6source___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_start(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_5start___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_start(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_5start___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_end(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_3end___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_end(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_3end___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_score(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_5score___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_score(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_5score___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_strand(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_6strand___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_strand(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_6strand___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_frame(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_5frame___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_frame(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_5frame___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_10TabProxies_8GTFProxy_attributes(PyObject *o, void *x) {
+  return __pyx_pf_10TabProxies_8GTFProxy_10attributes___get__(o);
+}
+
+static int __pyx_setprop_10TabProxies_8GTFProxy_attributes(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8GTFProxy_10attributes___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyMethodDef __pyx_methods_10TabProxies_GTFProxy[] = {
+  {__Pyx_NAMESTR("asDict"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy_asDict, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy_asDict)},
+  {__Pyx_NAMESTR("fromDict"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy_fromDict, METH_O, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy_fromDict)},
+  {__Pyx_NAMESTR("invert"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy_invert, METH_O, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy_invert)},
+  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy_keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy_keys)},
+  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy___getattr__, METH_O|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy___getattr__)},
+  {__Pyx_NAMESTR("setAttribute"), (PyCFunction)__pyx_pf_10TabProxies_8GTFProxy_setAttribute, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10TabProxies_8GTFProxy_setAttribute)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_10TabProxies_GTFProxy[] = {
+  {(char *)"contig", __pyx_getprop_10TabProxies_8GTFProxy_contig, __pyx_setprop_10TabProxies_8GTFProxy_contig, __Pyx_DOCSTR(__pyx_k_19), 0},
+  {(char *)"feature", __pyx_getprop_10TabProxies_8GTFProxy_feature, __pyx_setprop_10TabProxies_8GTFProxy_feature, __Pyx_DOCSTR(__pyx_k_20), 0},
+  {(char *)"source", __pyx_getprop_10TabProxies_8GTFProxy_source, __pyx_setprop_10TabProxies_8GTFProxy_source, __Pyx_DOCSTR(__pyx_k_21), 0},
+  {(char *)"start", __pyx_getprop_10TabProxies_8GTFProxy_start, __pyx_setprop_10TabProxies_8GTFProxy_start, __Pyx_DOCSTR(__pyx_k_22), 0},
+  {(char *)"end", __pyx_getprop_10TabProxies_8GTFProxy_end, __pyx_setprop_10TabProxies_8GTFProxy_end, __Pyx_DOCSTR(__pyx_k_23), 0},
+  {(char *)"score", __pyx_getprop_10TabProxies_8GTFProxy_score, __pyx_setprop_10TabProxies_8GTFProxy_score, __Pyx_DOCSTR(__pyx_k_24), 0},
+  {(char *)"strand", __pyx_getprop_10TabProxies_8GTFProxy_strand, __pyx_setprop_10TabProxies_8GTFProxy_strand, __Pyx_DOCSTR(__pyx_k_25), 0},
+  {(char *)"frame", __pyx_getprop_10TabProxies_8GTFProxy_frame, __pyx_setprop_10TabProxies_8GTFProxy_frame, __Pyx_DOCSTR(__pyx_k_26), 0},
+  {(char *)"attributes", __pyx_getprop_10TabProxies_8GTFProxy_attributes, __pyx_setprop_10TabProxies_8GTFProxy_attributes, __Pyx_DOCSTR(__pyx_k_27), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_GTFProxy = {
+  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_GTFProxy = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  __pyx_sq_item_10TabProxies_GTFProxy, /*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_GTFProxy = {
+  0, /*mp_length*/
+  __pyx_pf_10TabProxies_8GTFProxy___getitem__, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_GTFProxy = {
+  #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
+};
+
+PyTypeObject __pyx_type_10TabProxies_GTFProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("TabProxies.GTFProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_10TabProxies_GTFProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_10TabProxies_GTFProxy, /*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_GTFProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_GTFProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_GTFProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_10TabProxies_8GTFProxy___str__, /*tp_str*/
+  __pyx_tp_getattro_10TabProxies_GTFProxy, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_GTFProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("Proxy class for access to GTF fields.\n\n    This class represents a GTF entry for fast read-access.\n    Write-access has been added as well, though some care must\n    be taken. If any of the string fields (contig, source, ...)\n    are set, the new value is tied to the lifetime of the\n    argument that was supplied.\n\n    The only exception is the attributes field when set from\n    a dictionary - this field will manage its own memory.\n\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_10TabProxies_GTFProxy, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_10TabProxies_GTFProxy, /*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_10TabProxies_GTFProxy, /*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_10TabProxies_NamedTupleProxy __pyx_vtable_10TabProxies_NamedTupleProxy;
+
+static PyObject *__pyx_tp_new_10TabProxies_NamedTupleProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy *p;
+  PyObject *o = __pyx_tp_new_10TabProxies_TupleProxy(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_10TabProxies_NamedTupleProxy *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10TabProxies_TupleProxy*)__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+  return o;
+}
+
+static PyObject *__pyx_tp_getattro_10TabProxies_NamedTupleProxy(PyObject *o, PyObject *n) {
+  PyObject *v = PyObject_GenericGetAttr(o, n);
+  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+    PyErr_Clear();
+    v = __pyx_pf_10TabProxies_15NamedTupleProxy___getattr__(o, n);
+  }
+  return v;
+}
+
+static int __pyx_tp_setattro_10TabProxies_NamedTupleProxy(PyObject *o, PyObject *n, PyObject *v) {
+  if (v) {
+    return __pyx_pf_10TabProxies_15NamedTupleProxy___setattr__(o, n, v);
+  }
+  else {
+    if (__pyx_ptype_10TabProxies_TupleProxy->tp_setattro)
+      return __pyx_ptype_10TabProxies_TupleProxy->tp_setattro(o, n, v);
+    return PyObject_GenericSetAttr(o, n, 0);
+  }
+}
+
+static PyMethodDef __pyx_methods_10TabProxies_NamedTupleProxy[] = {
+  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_10TabProxies_15NamedTupleProxy___getattr__, METH_O|METH_COEXIST, __Pyx_DOCSTR(0)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_NamedTupleProxy = {
+  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_NamedTupleProxy = {
+  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_NamedTupleProxy = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_NamedTupleProxy = {
+  #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
+};
+
+PyTypeObject __pyx_type_10TabProxies_NamedTupleProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("TabProxies.NamedTupleProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_10TabProxies_NamedTupleProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_10TabProxies_TupleProxy, /*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_NamedTupleProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_NamedTupleProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_NamedTupleProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  __pyx_tp_getattro_10TabProxies_NamedTupleProxy, /*tp_getattro*/
+  __pyx_tp_setattro_10TabProxies_NamedTupleProxy, /*tp_setattro*/
+  &__pyx_tp_as_buffer_NamedTupleProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_10TabProxies_NamedTupleProxy, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_10TabProxies_NamedTupleProxy, /*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_10TabProxies_BedProxy __pyx_vtable_10TabProxies_BedProxy;
+
+static PyObject *__pyx_tp_new_10TabProxies_BedProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_10TabProxies_BedProxy *p;
+  PyObject *o = __pyx_tp_new_10TabProxies_TupleProxy(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_10TabProxies_BedProxy *)o);
+  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10TabProxies_TupleProxy*)__pyx_vtabptr_10TabProxies_BedProxy;
+  return o;
+}
+
+static int __pyx_tp_setattro_10TabProxies_BedProxy(PyObject *o, PyObject *n, PyObject *v) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8BedProxy___setattr__(o, n, v);
+  }
+  else {
+    if (__pyx_ptype_10TabProxies_NamedTupleProxy->tp_setattro)
+      return __pyx_ptype_10TabProxies_NamedTupleProxy->tp_setattro(o, n, v);
+    return PyObject_GenericSetAttr(o, n, 0);
+  }
+}
+
+static PyMethodDef __pyx_methods_10TabProxies_BedProxy[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_BedProxy = {
+  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_BedProxy = {
+  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_BedProxy = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_BedProxy = {
+  #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
+};
+
+PyTypeObject __pyx_type_10TabProxies_BedProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("TabProxies.BedProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_10TabProxies_BedProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_10TabProxies_TupleProxy, /*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_BedProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_BedProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_BedProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_10TabProxies_8BedProxy___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  __pyx_tp_setattro_10TabProxies_BedProxy, /*tp_setattro*/
+  &__pyx_tp_as_buffer_BedProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("Proxy class for access to Bed fields.\n\n    This class represents a GTF entry for fast read-access.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_10TabProxies_BedProxy, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_10TabProxies_BedProxy, /*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_10TabProxies_VCFProxy __pyx_vtable_10TabProxies_VCFProxy;
+
+static PyObject *__pyx_tp_new_10TabProxies_VCFProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_10TabProxies_VCFProxy *p;
+  PyObject *o = __pyx_tp_new_10TabProxies_TupleProxy(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_10TabProxies_VCFProxy *)o);
+  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10TabProxies_TupleProxy*)__pyx_vtabptr_10TabProxies_VCFProxy;
+  if (__pyx_pf_10TabProxies_8VCFProxy___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static int __pyx_tp_setattro_10TabProxies_VCFProxy(PyObject *o, PyObject *n, PyObject *v) {
+  if (v) {
+    return __pyx_pf_10TabProxies_8VCFProxy___setattr__(o, n, v);
+  }
+  else {
+    if (__pyx_ptype_10TabProxies_NamedTupleProxy->tp_setattro)
+      return __pyx_ptype_10TabProxies_NamedTupleProxy->tp_setattro(o, n, v);
+    return PyObject_GenericSetAttr(o, n, 0);
+  }
+}
+
+static PyMethodDef __pyx_methods_10TabProxies_VCFProxy[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_VCFProxy = {
+  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_VCFProxy = {
+  __pyx_pf_10TabProxies_8VCFProxy___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_VCFProxy = {
+  __pyx_pf_10TabProxies_8VCFProxy___len__, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_VCFProxy = {
+  #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
+};
+
+PyTypeObject __pyx_type_10TabProxies_VCFProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("TabProxies.VCFProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_10TabProxies_VCFProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_10TabProxies_TupleProxy, /*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_VCFProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_VCFProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_VCFProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  __pyx_tp_setattro_10TabProxies_VCFProxy, /*tp_setattro*/
+  &__pyx_tp_as_buffer_VCFProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("Proxy class for access to VCF fields.\n\n    The genotypes are accessed via index.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_10TabProxies_VCFProxy, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_10TabProxies_VCFProxy, /*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 PyMethodDef __pyx_methods[] = {
+  {__Pyx_NAMESTR("toDot"), (PyCFunction)__pyx_pf_10TabProxies_toDot, METH_O, __Pyx_DOCSTR(__pyx_doc_10TabProxies_toDot)},
+  {__Pyx_NAMESTR("quote"), (PyCFunction)__pyx_pf_10TabProxies_quote, METH_O, __Pyx_DOCSTR(__pyx_doc_10TabProxies_quote)},
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+    PyModuleDef_HEAD_INIT,
+    __Pyx_NAMESTR("TabProxies"),
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
+  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
+  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
+  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
+  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
+  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
+  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
+  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
+  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
+  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
+  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
+  {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0},
+  {&__pyx_kp_u_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0, 0},
+  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
+  {&__pyx_kp_u_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0, 0},
+  {&__pyx_kp_u_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 1, 0, 0},
+  {&__pyx_kp_u_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0, 0},
+  {&__pyx_kp_u_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 1, 0, 0},
+  {&__pyx_kp_u_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 1, 0, 0},
+  {&__pyx_kp_u_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 1, 0, 0},
+  {&__pyx_kp_u_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 1, 0, 0},
+  {&__pyx_kp_u_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 1, 0, 0},
+  {&__pyx_kp_u_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 1, 0, 0},
+  {&__pyx_kp_u_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 1, 0, 0},
+  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
+  {&__pyx_kp_u_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 1, 0, 0},
+  {&__pyx_kp_u_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 1, 0, 0},
+  {&__pyx_kp_u_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 1, 0, 0},
+  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
+  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
+  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
+  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
+  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
+  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
+  {&__pyx_n_s__BedProxy, __pyx_k__BedProxy, sizeof(__pyx_k__BedProxy), 0, 0, 1, 1},
+  {&__pyx_n_s__GTFProxy, __pyx_k__GTFProxy, sizeof(__pyx_k__GTFProxy), 0, 0, 1, 1},
+  {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
+  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
+  {&__pyx_n_s__NamedTupleProxy, __pyx_k__NamedTupleProxy, sizeof(__pyx_k__NamedTupleProxy), 0, 0, 1, 1},
+  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
+  {&__pyx_n_s__StringType, __pyx_k__StringType, sizeof(__pyx_k__StringType), 0, 0, 1, 1},
+  {&__pyx_n_s__StringTypes, __pyx_k__StringTypes, sizeof(__pyx_k__StringTypes), 0, 0, 1, 1},
+  {&__pyx_n_s__TupleProxy, __pyx_k__TupleProxy, sizeof(__pyx_k__TupleProxy), 0, 0, 1, 1},
+  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
+  {&__pyx_n_s__VCFProxy, __pyx_k__VCFProxy, sizeof(__pyx_k__VCFProxy), 0, 0, 1, 1},
+  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
+  {&__pyx_n_s____getattr__, __pyx_k____getattr__, sizeof(__pyx_k____getattr__), 0, 0, 1, 1},
+  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
+  {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
+  {&__pyx_n_s____setattr__, __pyx_k____setattr__, sizeof(__pyx_k____setattr__), 0, 0, 1, 1},
+  {&__pyx_n_s____setitem__, __pyx_k____setitem__, sizeof(__pyx_k____setitem__), 0, 0, 1, 1},
+  {&__pyx_n_s____str__, __pyx_k____str__, sizeof(__pyx_k____str__), 0, 0, 1, 1},
+  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
+  {&__pyx_n_s___setindex, __pyx_k___setindex, sizeof(__pyx_k___setindex), 0, 0, 1, 1},
+  {&__pyx_n_s__alt, __pyx_k__alt, sizeof(__pyx_k__alt), 0, 0, 1, 1},
+  {&__pyx_n_s__asDict, __pyx_k__asDict, sizeof(__pyx_k__asDict), 0, 0, 1, 1},
+  {&__pyx_n_s__attributes, __pyx_k__attributes, sizeof(__pyx_k__attributes), 0, 0, 1, 1},
+  {&__pyx_n_s__bedfields, __pyx_k__bedfields, sizeof(__pyx_k__bedfields), 0, 0, 1, 1},
+  {&__pyx_n_s__blockCount, __pyx_k__blockCount, sizeof(__pyx_k__blockCount), 0, 0, 1, 1},
+  {&__pyx_n_s__blockSizes, __pyx_k__blockSizes, sizeof(__pyx_k__blockSizes), 0, 0, 1, 1},
+  {&__pyx_n_s__blockStarts, __pyx_k__blockStarts, sizeof(__pyx_k__blockStarts), 0, 0, 1, 1},
+  {&__pyx_n_s__contig, __pyx_k__contig, sizeof(__pyx_k__contig), 0, 0, 1, 1},
+  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
+  {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
+  {&__pyx_n_s__feature, __pyx_k__feature, sizeof(__pyx_k__feature), 0, 0, 1, 1},
+  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
+  {&__pyx_n_s__filter, __pyx_k__filter, sizeof(__pyx_k__filter), 0, 0, 1, 1},
+  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
+  {&__pyx_n_s__frame, __pyx_k__frame, sizeof(__pyx_k__frame), 0, 0, 1, 1},
+  {&__pyx_n_s__fromDict, __pyx_k__fromDict, sizeof(__pyx_k__fromDict), 0, 0, 1, 1},
+  {&__pyx_n_s__getMaxFields, __pyx_k__getMaxFields, sizeof(__pyx_k__getMaxFields), 0, 0, 1, 1},
+  {&__pyx_n_s__hasOwnAttributes, __pyx_k__hasOwnAttributes, sizeof(__pyx_k__hasOwnAttributes), 0, 0, 1, 1},
+  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
+  {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
+  {&__pyx_n_s__info, __pyx_k__info, sizeof(__pyx_k__info), 0, 0, 1, 1},
+  {&__pyx_n_s__invert, __pyx_k__invert, sizeof(__pyx_k__invert), 0, 0, 1, 1},
+  {&__pyx_n_s__is_modified, __pyx_k__is_modified, sizeof(__pyx_k__is_modified), 0, 0, 1, 1},
+  {&__pyx_n_s__itemRGB, __pyx_k__itemRGB, sizeof(__pyx_k__itemRGB), 0, 0, 1, 1},
+  {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
+  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
+  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
+  {&__pyx_n_s__map_key2field, __pyx_k__map_key2field, sizeof(__pyx_k__map_key2field), 0, 0, 1, 1},
+  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
+  {&__pyx_n_s__nbytes, __pyx_k__nbytes, sizeof(__pyx_k__nbytes), 0, 0, 1, 1},
+  {&__pyx_n_s__nfields, __pyx_k__nfields, sizeof(__pyx_k__nfields), 0, 0, 1, 1},
+  {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
+  {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
+  {&__pyx_n_s__qual, __pyx_k__qual, sizeof(__pyx_k__qual), 0, 0, 1, 1},
+  {&__pyx_n_s__quote, __pyx_k__quote, sizeof(__pyx_k__quote), 0, 0, 1, 1},
+  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
+  {&__pyx_n_s__ref, __pyx_k__ref, sizeof(__pyx_k__ref), 0, 0, 1, 1},
+  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
+  {&__pyx_n_s__setAttribute, __pyx_k__setAttribute, sizeof(__pyx_k__setAttribute), 0, 0, 1, 1},
+  {&__pyx_n_s__source, __pyx_k__source, sizeof(__pyx_k__source), 0, 0, 1, 1},
+  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
+  {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
+  {&__pyx_n_s__strand, __pyx_k__strand, sizeof(__pyx_k__strand), 0, 0, 1, 1},
+  {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
+  {&__pyx_n_s__thickEnd, __pyx_k__thickEnd, sizeof(__pyx_k__thickEnd), 0, 0, 1, 1},
+  {&__pyx_n_s__thickStart, __pyx_k__thickStart, sizeof(__pyx_k__thickStart), 0, 0, 1, 1},
+  {&__pyx_n_s__toDot, __pyx_k__toDot, sizeof(__pyx_k__toDot), 0, 0, 1, 1},
+  {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
+  {&__pyx_n_s__update, __pyx_k__update, sizeof(__pyx_k__update), 0, 0, 1, 1},
+  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
+  {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
+  {0, 0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __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 = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #else
+  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __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 = 462; __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 = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initTabProxies(void); /*proto*/
+PyMODINIT_FUNC initTabProxies(void)
+#else
+PyMODINIT_FUNC PyInit_TabProxies(void); /*proto*/
+PyMODINIT_FUNC PyInit_TabProxies(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  #if CYTHON_REFNANNY
+  void* __pyx_refnanny = NULL;
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_TabProxies(void)", __LINE__, __FILE__);
+  #endif
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __pyx_binding_PyCFunctionType_USED
+  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("TabProxies"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  #if PY_MAJOR_VERSION < 3
+  Py_INCREF(__pyx_m);
+  #endif
+  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_module_is_main_TabProxies) {
+    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  __pyx_vtabptr_10TabProxies_TupleProxy = &__pyx_vtable_10TabProxies_TupleProxy;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_10TabProxies_TupleProxy.getMaxFields = (int (*)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t))__pyx_f_10TabProxies_10TupleProxy_getMaxFields;
+  __pyx_vtable_10TabProxies_TupleProxy.take = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_10TupleProxy_take;
+  __pyx_vtable_10TabProxies_TupleProxy.present = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_10TupleProxy_present;
+  __pyx_vtable_10TabProxies_TupleProxy.copy = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_10TupleProxy_copy;
+  __pyx_vtable_10TabProxies_TupleProxy.update = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_10TupleProxy_update;
+  #else
+  *(void(**)(void))&__pyx_vtable_10TabProxies_TupleProxy.getMaxFields = (void(*)(void))__pyx_f_10TabProxies_10TupleProxy_getMaxFields;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_TupleProxy.take = (void(*)(void))__pyx_f_10TabProxies_10TupleProxy_take;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_TupleProxy.present = (void(*)(void))__pyx_f_10TabProxies_10TupleProxy_present;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_TupleProxy.copy = (void(*)(void))__pyx_f_10TabProxies_10TupleProxy_copy;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_TupleProxy.update = (void(*)(void))__pyx_f_10TabProxies_10TupleProxy_update;
+  #endif
+  if (PyType_Ready(&__pyx_type_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_TupleProxy, "__setitem__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___setitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___setitem__.doc = __pyx_doc_10TabProxies_10TupleProxy___setitem__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_10TupleProxy___setitem__;
+    }
+  }
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_TupleProxy, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___next__.doc = __pyx_doc_10TabProxies_10TupleProxy___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_10TupleProxy___next__;
+    }
+  }
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_TupleProxy, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_10TupleProxy___str__.doc = __pyx_doc_10TabProxies_10TupleProxy___str__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_10TupleProxy___str__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_10TabProxies_TupleProxy.tp_dict, __pyx_vtabptr_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "TupleProxy", (PyObject *)&__pyx_type_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_TupleProxy = &__pyx_type_10TabProxies_TupleProxy;
+  __pyx_vtabptr_10TabProxies_GTFProxy = &__pyx_vtable_10TabProxies_GTFProxy;
+  __pyx_vtable_10TabProxies_GTFProxy.__pyx_base = *__pyx_vtabptr_10TabProxies_TupleProxy;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_10TabProxies_GTFProxy.__pyx_base.getMaxFields = (int (*)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t))__pyx_f_10TabProxies_8GTFProxy_getMaxFields;
+  __pyx_vtable_10TabProxies_GTFProxy.__pyx_base.update = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_8GTFProxy_update;
+  #else
+  *(void(**)(void))&__pyx_vtable_10TabProxies_GTFProxy.__pyx_base.getMaxFields = (void(*)(void))__pyx_f_10TabProxies_8GTFProxy_getMaxFields;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_GTFProxy.__pyx_base.update = (void(*)(void))__pyx_f_10TabProxies_8GTFProxy_update;
+  #endif
+  __pyx_type_10TabProxies_GTFProxy.tp_base = __pyx_ptype_10TabProxies_TupleProxy;
+  if (PyType_Ready(&__pyx_type_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_GTFProxy, "__getattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_8GTFProxy___getattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_8GTFProxy___getattr__.doc = __pyx_doc_10TabProxies_8GTFProxy___getattr__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_8GTFProxy___getattr__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_10TabProxies_GTFProxy.tp_dict, __pyx_vtabptr_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "GTFProxy", (PyObject *)&__pyx_type_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_GTFProxy = &__pyx_type_10TabProxies_GTFProxy;
+  __pyx_vtabptr_10TabProxies_NamedTupleProxy = &__pyx_vtable_10TabProxies_NamedTupleProxy;
+  __pyx_vtable_10TabProxies_NamedTupleProxy.__pyx_base = *__pyx_vtabptr_10TabProxies_TupleProxy;
+  __pyx_type_10TabProxies_NamedTupleProxy.tp_base = __pyx_ptype_10TabProxies_TupleProxy;
+  if (PyType_Ready(&__pyx_type_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_NamedTupleProxy, "__setattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_15NamedTupleProxy___setattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_15NamedTupleProxy___setattr__.doc = __pyx_doc_10TabProxies_15NamedTupleProxy___setattr__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_15NamedTupleProxy___setattr__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_10TabProxies_NamedTupleProxy.tp_dict, __pyx_vtabptr_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "NamedTupleProxy", (PyObject *)&__pyx_type_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_NamedTupleProxy = &__pyx_type_10TabProxies_NamedTupleProxy;
+  __pyx_vtabptr_10TabProxies_BedProxy = &__pyx_vtable_10TabProxies_BedProxy;
+  __pyx_vtable_10TabProxies_BedProxy.__pyx_base = *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_10TabProxies_BedProxy.__pyx_base.__pyx_base.getMaxFields = (int (*)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t))__pyx_f_10TabProxies_8BedProxy_getMaxFields;
+  __pyx_vtable_10TabProxies_BedProxy.__pyx_base.__pyx_base.update = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_8BedProxy_update;
+  #else
+  *(void(**)(void))&__pyx_vtable_10TabProxies_BedProxy.__pyx_base.__pyx_base.getMaxFields = (void(*)(void))__pyx_f_10TabProxies_8BedProxy_getMaxFields;
+  *(void(**)(void))&__pyx_vtable_10TabProxies_BedProxy.__pyx_base.__pyx_base.update = (void(*)(void))__pyx_f_10TabProxies_8BedProxy_update;
+  #endif
+  __pyx_type_10TabProxies_BedProxy.tp_base = __pyx_ptype_10TabProxies_NamedTupleProxy;
+  if (PyType_Ready(&__pyx_type_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_BedProxy, "__setattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_8BedProxy___setattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_8BedProxy___setattr__.doc = __pyx_doc_10TabProxies_8BedProxy___setattr__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_8BedProxy___setattr__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_10TabProxies_BedProxy.tp_dict, __pyx_vtabptr_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "BedProxy", (PyObject *)&__pyx_type_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_BedProxy = &__pyx_type_10TabProxies_BedProxy;
+  __pyx_vtabptr_10TabProxies_VCFProxy = &__pyx_vtable_10TabProxies_VCFProxy;
+  __pyx_vtable_10TabProxies_VCFProxy.__pyx_base = *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_10TabProxies_VCFProxy.__pyx_base.__pyx_base.update = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_10TabProxies_8VCFProxy_update;
+  #else
+  *(void(**)(void))&__pyx_vtable_10TabProxies_VCFProxy.__pyx_base.__pyx_base.update = (void(*)(void))__pyx_f_10TabProxies_8VCFProxy_update;
+  #endif
+  __pyx_type_10TabProxies_VCFProxy.tp_base = __pyx_ptype_10TabProxies_NamedTupleProxy;
+  if (PyType_Ready(&__pyx_type_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_10TabProxies_VCFProxy, "__setattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_10TabProxies_8VCFProxy___setattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_10TabProxies_8VCFProxy___setattr__.doc = __pyx_doc_10TabProxies_8VCFProxy___setattr__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_10TabProxies_8VCFProxy___setattr__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_10TabProxies_VCFProxy.tp_dict, __pyx_vtabptr_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "VCFProxy", (PyObject *)&__pyx_type_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_VCFProxy = &__pyx_type_10TabProxies_VCFProxy;
+  /*--- Type import code ---*/
+  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":1
+ * import types             # <<<<<<<<<<<<<<
+ * from cpython cimport PyString_FromStringAndSize, PyString_AsString, PyString_AS_STRING
+ * 
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":490
+ * cdef class NamedTupleProxy( TupleProxy ):
+ * 
+ *     map_key2field = {}             # <<<<<<<<<<<<<<
+ * 
+ *     def __setattr__(self, key, value ):
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItem((PyObject *)__pyx_ptype_10TabProxies_NamedTupleProxy->tp_dict, __pyx_n_s__map_key2field, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  PyType_Modified(__pyx_ptype_10TabProxies_NamedTupleProxy);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":512
+ *     This class represents a GTF entry for fast read-access.
+ *     '''
+ *     map_key2field = {             # <<<<<<<<<<<<<<
+ *         'contig' : (0, str),
+ *         'start' : (1, int),
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":513
+ *     '''
+ *     map_key2field = {
+ *         'contig' : (0, str),             # <<<<<<<<<<<<<<
+ *         'start' : (1, int),
+ *         'end' : (2, int),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
+  __Pyx_GIVEREF(__pyx_int_0);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__contig), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":514
+ *     map_key2field = {
+ *         'contig' : (0, str),
+ *         'start' : (1, int),             # <<<<<<<<<<<<<<
+ *         'end' : (2, int),
+ *         'name' : (3, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__start), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":515
+ *         'contig' : (0, str),
+ *         'start' : (1, int),
+ *         'end' : (2, int),             # <<<<<<<<<<<<<<
+ *         'name' : (3, str),
+ *         'score' : (4, float),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_2);
+  __Pyx_GIVEREF(__pyx_int_2);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__end), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":516
+ *         'start' : (1, int),
+ *         'end' : (2, int),
+ *         'name' : (3, str),             # <<<<<<<<<<<<<<
+ *         'score' : (4, float),
+ *         'strand' : (5, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_3);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_3);
+  __Pyx_GIVEREF(__pyx_int_3);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__name), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":517
+ *         'end' : (2, int),
+ *         'name' : (3, str),
+ *         'score' : (4, float),             # <<<<<<<<<<<<<<
+ *         'strand' : (5, str),
+ *         'thickStart' : (6,int ),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_4);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_4);
+  __Pyx_GIVEREF(__pyx_int_4);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyFloat_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyFloat_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyFloat_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__score), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":518
+ *         'name' : (3, str),
+ *         'score' : (4, float),
+ *         'strand' : (5, str),             # <<<<<<<<<<<<<<
+ *         'thickStart' : (6,int ),
+ *         'thickEnd' : (7,int),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_5);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_5);
+  __Pyx_GIVEREF(__pyx_int_5);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__strand), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":519
+ *         'score' : (4, float),
+ *         'strand' : (5, str),
+ *         'thickStart' : (6,int ),             # <<<<<<<<<<<<<<
+ *         'thickEnd' : (7,int),
+ *         'itemRGB' : (8,str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_6);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_6);
+  __Pyx_GIVEREF(__pyx_int_6);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__thickStart), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":520
+ *         'strand' : (5, str),
+ *         'thickStart' : (6,int ),
+ *         'thickEnd' : (7,int),             # <<<<<<<<<<<<<<
+ *         'itemRGB' : (8,str),
+ *         'blockCount': (9,int),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_7);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_7);
+  __Pyx_GIVEREF(__pyx_int_7);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__thickEnd), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":521
+ *         'thickStart' : (6,int ),
+ *         'thickEnd' : (7,int),
+ *         'itemRGB' : (8,str),             # <<<<<<<<<<<<<<
+ *         'blockCount': (9,int),
+ *         'blockSizes': (10,str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_8);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_8);
+  __Pyx_GIVEREF(__pyx_int_8);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__itemRGB), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":522
+ *         'thickEnd' : (7,int),
+ *         'itemRGB' : (8,str),
+ *         'blockCount': (9,int),             # <<<<<<<<<<<<<<
+ *         'blockSizes': (10,str),
+ *         'blockStarts': (11,str), }
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_9);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_9);
+  __Pyx_GIVEREF(__pyx_int_9);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__blockCount), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":523
+ *         'itemRGB' : (8,str),
+ *         'blockCount': (9,int),
+ *         'blockSizes': (10,str),             # <<<<<<<<<<<<<<
+ *         'blockStarts': (11,str), }
+ * 
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_10);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_10);
+  __Pyx_GIVEREF(__pyx_int_10);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__blockSizes), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":524
+ *         'blockCount': (9,int),
+ *         'blockSizes': (10,str),
+ *         'blockStarts': (11,str), }             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int getMaxFields( self, size_t nbytes ):
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_11);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_11);
+  __Pyx_GIVEREF(__pyx_int_11);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__blockStarts), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem((PyObject *)__pyx_ptype_10TabProxies_BedProxy->tp_dict, __pyx_n_s__map_key2field, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  PyType_Modified(__pyx_ptype_10TabProxies_BedProxy);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":578
+ *     The genotypes are accessed via index.
+ *     '''
+ *     map_key2field = {             # <<<<<<<<<<<<<<
+ *         'contig' : (0, str),
+ *         'pos' : (1, int),
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":579
+ *     '''
+ *     map_key2field = {
+ *         'contig' : (0, str),             # <<<<<<<<<<<<<<
+ *         'pos' : (1, int),
+ *         'id' : (2, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
+  __Pyx_GIVEREF(__pyx_int_0);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__contig), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":580
+ *     map_key2field = {
+ *         'contig' : (0, str),
+ *         'pos' : (1, int),             # <<<<<<<<<<<<<<
+ *         'id' : (2, str),
+ *         'ref' : (3, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyInt_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyInt_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":581
+ *         'contig' : (0, str),
+ *         'pos' : (1, int),
+ *         'id' : (2, str),             # <<<<<<<<<<<<<<
+ *         'ref' : (3, str),
+ *         'alt' : (4, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_2);
+  __Pyx_GIVEREF(__pyx_int_2);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__id), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":582
+ *         'pos' : (1, int),
+ *         'id' : (2, str),
+ *         'ref' : (3, str),             # <<<<<<<<<<<<<<
+ *         'alt' : (4, str),
+ *         'qual' : (5, str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_3);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_3);
+  __Pyx_GIVEREF(__pyx_int_3);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ref), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":583
+ *         'id' : (2, str),
+ *         'ref' : (3, str),
+ *         'alt' : (4, str),             # <<<<<<<<<<<<<<
+ *         'qual' : (5, str),
+ *         'filter' : (6,str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_4);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_4);
+  __Pyx_GIVEREF(__pyx_int_4);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__alt), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":584
+ *         'ref' : (3, str),
+ *         'alt' : (4, str),
+ *         'qual' : (5, str),             # <<<<<<<<<<<<<<
+ *         'filter' : (6,str),
+ *         'info' : (7,str),
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_5);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_5);
+  __Pyx_GIVEREF(__pyx_int_5);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":585
+ *         'alt' : (4, str),
+ *         'qual' : (5, str),
+ *         'filter' : (6,str),             # <<<<<<<<<<<<<<
+ *         'info' : (7,str),
+ *         'format' : (8,str) }
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_6);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_6);
+  __Pyx_GIVEREF(__pyx_int_6);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__filter), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":586
+ *         'qual' : (5, str),
+ *         'filter' : (6,str),
+ *         'info' : (7,str),             # <<<<<<<<<<<<<<
+ *         'format' : (8,str) }
+ * 
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_7);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_7);
+  __Pyx_GIVEREF(__pyx_int_7);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__info), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":587
+ *         'filter' : (6,str),
+ *         'info' : (7,str),
+ *         'format' : (8,str) }             # <<<<<<<<<<<<<<
+ * 
+ *     def __cinit__(self ):
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_8);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_8);
+  __Pyx_GIVEREF(__pyx_int_8);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__format), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem((PyObject *)__pyx_ptype_10TabProxies_VCFProxy->tp_dict, __pyx_n_s__map_key2field, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  PyType_Modified(__pyx_ptype_10TabProxies_VCFProxy);
+
+  /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":1
+ * import types             # <<<<<<<<<<<<<<
+ * from cpython cimport PyString_FromStringAndSize, PyString_AsString, PyString_AS_STRING
+ * 
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s___setindex); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_28), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____setitem__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_29), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_30), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____str__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_31), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__toDot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_32), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__quote); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_33), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__asDict); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_34), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fromDict); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_35), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__invert); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_36), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_37), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_38), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setAttribute); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_39), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__NamedTupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_40), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__BedProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_41), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_42), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/Cython-0.13-py2.7-linux-x86_64.egg/Cython/Includes/cpython/type.pxd":2
+ * 
+ * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
+ *     # The C structure of the objects used to describe built-in types.
+ * 
+ */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  if (__pyx_m) {
+    __Pyx_AddTraceback("init TabProxies");
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init TabProxies");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* Runtime support code */
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+    PyObject *result;
+    result = PyObject_GetAttr(dict, name);
+    if (!result)
+        PyErr_SetObject(PyExc_NameError, name);
+    return result;
+}
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *number, *more_or_less;
+
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    number = (num_expected == 1) ? "" : "s";
+    PyErr_Format(PyExc_TypeError,
+        #if PY_VERSION_HEX < 0x02050000
+            "%s() takes %s %d positional argument%s (%d given)",
+        #else
+            "%s() takes %s %zd positional argument%s (%zd given)",
+        #endif
+        func_name, more_or_less, num_expected, number, num_found);
+}
+
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
+    PyObject *kwdict,
+    const char* function_name,
+    int kw_allowed)
+{
+    PyObject* key = 0;
+    Py_ssize_t pos = 0;
+    while (PyDict_Next(kwdict, &pos, &key, 0)) {
+        #if PY_MAJOR_VERSION < 3
+        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
+        #else
+        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
+        #endif
+            goto invalid_keyword_type;
+    }
+    if ((!kw_allowed) && unlikely(key))
+        goto invalid_keyword;
+    return 1;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%s() keywords must be strings", function_name);
+    return 0;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%s() got an unexpected keyword argument '%s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+    return 0;
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AS_STRING(kw_name));
+        #endif
+}
+
+static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+        } else {
+            #if PY_MAJOR_VERSION < 3
+            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
+            #else
+            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
+            #endif
+                goto invalid_keyword_type;
+            } else {
+                for (name = first_kw_arg; *name; name++) {
+                    #if PY_MAJOR_VERSION >= 3
+                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
+                        PyUnicode_Compare(**name, key) == 0) break;
+                    #else
+                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
+                        _PyString_Eq(**name, key)) break;
+                    #endif
+                }
+                if (*name) {
+                    values[name-argnames] = value;
+                } else {
+                    /* unexpected keyword found */
+                    for (name=argnames; name != first_kw_arg; name++) {
+                        if (**name == key) goto arg_passed_twice;
+                        #if PY_MAJOR_VERSION >= 3
+                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
+                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
+                        #else
+                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
+                            _PyString_Eq(**name, key)) goto arg_passed_twice;
+                        #endif
+                    }
+                    if (kwds2) {
+                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+                    } else {
+                        goto invalid_keyword;
+                    }
+                }
+            }
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%s() got an unexpected keyword argument '%s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+
+static double __Pyx__PyObject_AsDouble(PyObject* obj) {
+    PyObject* float_value;
+    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
+        return PyFloat_AsDouble(obj);
+    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
+#if PY_MAJOR_VERSION >= 3
+        float_value = PyFloat_FromString(obj);
+#else
+        float_value = PyFloat_FromString(obj, 0);
+#endif
+    } else {
+        PyObject* args = PyTuple_New(1);
+        if (unlikely(!args)) goto bad;
+        PyTuple_SET_ITEM(args, 0, obj);
+        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
+        PyTuple_SET_ITEM(args, 0, 0);
+        Py_DECREF(args);
+    }
+    if (likely(float_value)) {
+        double value = PyFloat_AS_DOUBLE(float_value);
+        Py_DECREF(float_value);
+        return value;
+    }
+bad:
+    return (double)-1;
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
+    PyErr_Format(PyExc_ValueError,
+        #if PY_VERSION_HEX < 0x02050000
+                 "need more than %d value%s to unpack", (int)index,
+        #else
+                 "need more than %zd value%s to unpack", index,
+        #endif
+                 (index == 1) ? "" : "s");
+}
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+    PyErr_Format(PyExc_ValueError,
+        #if PY_VERSION_HEX < 0x02050000
+            "too many values to unpack (expected %d)", (int)expected);
+        #else
+            "too many values to unpack (expected %zd)", expected);
+        #endif
+}
+
+static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
+    PyObject *item;
+    if (!(item = PyIter_Next(iter))) {
+        if (!PyErr_Occurred()) {
+            __Pyx_RaiseNeedMoreValuesError(index);
+        }
+    }
+    return item;
+}
+
+static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
+    PyObject *item;
+    if ((item = PyIter_Next(iter))) {
+        Py_DECREF(item);
+        __Pyx_RaiseTooManyValuesError(expected);
+        return -1;
+    }
+    else if (!PyErr_Occurred())
+        return 0;
+    else
+        return -1;
+}
+
+static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->exc_type;
+    *value = tstate->exc_value;
+    *tb = tstate->exc_traceback;
+    Py_XINCREF(*type);
+    Py_XINCREF(*value);
+    Py_XINCREF(*tb);
+}
+
+static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = type;
+    tstate->exc_value = value;
+    tstate->exc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+    PyObject *py_import = 0;
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+    if (!py_import)
+        goto bad;
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    module = PyObject_CallFunctionObjArgs(py_import,
+        name, global_dict, empty_dict, list, NULL);
+bad:
+    Py_XDECREF(empty_list);
+    Py_XDECREF(py_import);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+}
+
+
+#if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    #if PY_VERSION_HEX < 0x02050000
+    if (!PyClass_Check(type))
+    #else
+    if (!PyType_Check(type))
+    #endif
+    {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        /* Normalize to raise <class>, <instance> */
+        Py_DECREF(value);
+        value = type;
+        #if PY_VERSION_HEX < 0x02050000
+            if (PyInstance_Check(type)) {
+                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+                Py_INCREF(type);
+            }
+            else {
+                type = 0;
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception must be an old-style class or instance");
+                goto raise_error;
+            }
+        #else
+            type = (PyObject*) Py_TYPE(type);
+            Py_INCREF(type);
+            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception class must be a subclass of BaseException");
+                goto raise_error;
+            }
+        #endif
+    }
+
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+#else /* Python 3+ */
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (!PyExceptionClass_Check(type)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+
+    PyErr_SetObject(type, value);
+
+    if (tb) {
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+    }
+
+bad:
+    return;
+}
+#endif
+
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
+    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
+    const int is_unsigned = const_zero < neg_one;
+    if ((sizeof(uint32_t) == sizeof(char))  ||
+        (sizeof(uint32_t) == sizeof(short))) {
+        return PyInt_FromLong((long)val);
+    } else if ((sizeof(uint32_t) == sizeof(int)) ||
+               (sizeof(uint32_t) == sizeof(long))) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLong((unsigned long)val);
+        else
+            return PyInt_FromLong((long)val);
+    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
+        else
+            return PyLong_FromLongLong((PY_LONG_LONG)val);
+    } else {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&val;
+        return _PyLong_FromByteArray(bytes, sizeof(uint32_t), 
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject* x) {
+    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
+    const int is_unsigned = const_zero < neg_one;
+    if (sizeof(uint32_t) == sizeof(char)) {
+        if (is_unsigned)
+            return (uint32_t)__Pyx_PyInt_AsUnsignedChar(x);
+        else
+            return (uint32_t)__Pyx_PyInt_AsSignedChar(x);
+    } else if (sizeof(uint32_t) == sizeof(short)) {
+        if (is_unsigned)
+            return (uint32_t)__Pyx_PyInt_AsUnsignedShort(x);
+        else
+            return (uint32_t)__Pyx_PyInt_AsSignedShort(x);
+    } else if (sizeof(uint32_t) == sizeof(int)) {
+        if (is_unsigned)
+            return (uint32_t)__Pyx_PyInt_AsUnsignedInt(x);
+        else
+            return (uint32_t)__Pyx_PyInt_AsSignedInt(x);
+    } else if (sizeof(uint32_t) == sizeof(long)) {
+        if (is_unsigned)
+            return (uint32_t)__Pyx_PyInt_AsUnsignedLong(x);
+        else
+            return (uint32_t)__Pyx_PyInt_AsSignedLong(x);
+    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return (uint32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
+        else
+            return (uint32_t)__Pyx_PyInt_AsSignedLongLong(x);
+    }  else {
+        uint32_t val;
+        PyObject *v = __Pyx_PyNumber_Int(x);
+        #if PY_VERSION_HEX < 0x03000000
+        if (likely(v) && !PyLong_Check(v)) {
+            PyObject *tmp = v;
+            v = PyNumber_Long(tmp);
+            Py_DECREF(tmp);
+        }
+        #endif
+        if (likely(v)) {
+            int one = 1; int is_little = (int)*(unsigned char *)&one;
+            unsigned char *bytes = (unsigned char *)&val;
+            int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                          bytes, sizeof(val),
+                                          is_little, !is_unsigned);
+            Py_DECREF(v);
+            if (likely(!ret))
+                return val;
+        }
+        return (uint32_t)-1;
+    }
+}
+
+static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
+    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned char" :
+                    "value too large to convert to unsigned char");
+            }
+            return (unsigned char)-1;
+        }
+        return (unsigned char)val;
+    }
+    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
+    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned short" :
+                    "value too large to convert to unsigned short");
+            }
+            return (unsigned short)-1;
+        }
+        return (unsigned short)val;
+    }
+    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
+    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned int" :
+                    "value too large to convert to unsigned int");
+            }
+            return (unsigned int)-1;
+        }
+        return (unsigned int)val;
+    }
+    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
+    const char neg_one = (char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to char" :
+                    "value too large to convert to char");
+            }
+            return (char)-1;
+        }
+        return (char)val;
+    }
+    return (char)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
+    const short neg_one = (short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to short" :
+                    "value too large to convert to short");
+            }
+            return (short)-1;
+        }
+        return (short)val;
+    }
+    return (short)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
+    const int neg_one = (int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to int" :
+                    "value too large to convert to int");
+            }
+            return (int)-1;
+        }
+        return (int)val;
+    }
+    return (int)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
+    const signed char neg_one = (signed char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed char" :
+                    "value too large to convert to signed char");
+            }
+            return (signed char)-1;
+        }
+        return (signed char)val;
+    }
+    return (signed char)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
+    const signed short neg_one = (signed short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed short" :
+                    "value too large to convert to signed short");
+            }
+            return (signed short)-1;
+        }
+        return (signed short)val;
+    }
+    return (signed short)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
+    const signed int neg_one = (signed int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed int" :
+                    "value too large to convert to signed int");
+            }
+            return (signed int)-1;
+        }
+        return (signed int)val;
+    }
+    return (signed int)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
+    const int neg_one = (int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to int" :
+                    "value too large to convert to int");
+            }
+            return (int)-1;
+        }
+        return (int)val;
+    }
+    return (int)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
+    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to unsigned long");
+            return (unsigned long)-1;
+        }
+        return (unsigned long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to unsigned long");
+                return (unsigned long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        unsigned long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (unsigned long)-1;
+        val = __Pyx_PyInt_AsUnsignedLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
+    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to unsigned PY_LONG_LONG");
+            return (unsigned PY_LONG_LONG)-1;
+        }
+        return (unsigned PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to unsigned PY_LONG_LONG");
+                return (unsigned PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        unsigned PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (unsigned PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
+    const long neg_one = (long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to long");
+            return (long)-1;
+        }
+        return (long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to long");
+                return (long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (long)-1;
+        val = __Pyx_PyInt_AsLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
+    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to PY_LONG_LONG");
+            return (PY_LONG_LONG)-1;
+        }
+        return (PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to PY_LONG_LONG");
+                return (PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
+    const signed long neg_one = (signed long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to signed long");
+            return (signed long)-1;
+        }
+        return (signed long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to signed long");
+                return (signed long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        signed long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (signed long)-1;
+        val = __Pyx_PyInt_AsSignedLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
+    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to signed PY_LONG_LONG");
+            return (signed PY_LONG_LONG)-1;
+        }
+        return (signed PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to signed PY_LONG_LONG");
+                return (signed PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        signed PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (signed PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsSignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static void __Pyx_WriteUnraisable(const char *name) {
+    PyObject *old_exc, *old_val, *old_tb;
+    PyObject *ctx;
+    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
+    #if PY_MAJOR_VERSION < 3
+    ctx = PyString_FromString(name);
+    #else
+    ctx = PyUnicode_FromString(name);
+    #endif
+    __Pyx_ErrRestore(old_exc, old_val, old_tb);
+    if (!ctx) {
+        PyErr_WriteUnraisable(Py_None);
+    } else {
+        PyErr_WriteUnraisable(ctx);
+        Py_DECREF(ctx);
+    }
+}
+
+static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+    PyObject *ob = PyCapsule_New(vtable, 0, 0);
+#else
+    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
+#endif
+    if (!ob)
+        goto bad;
+    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
+        goto bad;
+    Py_DECREF(ob);
+    return 0;
+bad:
+    Py_XDECREF(ob);
+    return -1;
+}
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+    long size, int strict)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+    char warning[200];
+
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(class_name);
+    #else
+    py_name = PyUnicode_FromString(class_name);
+    #endif
+    if (!py_name)
+        goto bad;
+    result = PyObject_GetAttr(py_module, py_name);
+    Py_DECREF(py_name);
+    py_name = 0;
+    Py_DECREF(py_module);
+    py_module = 0;
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError, 
+            "%s.%s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
+        PyOS_snprintf(warning, sizeof(warning), 
+            "%s.%s size changed, may indicate binary incompatibility",
+            module_name, class_name);
+        #if PY_VERSION_HEX < 0x02050000
+        PyErr_Warn(NULL, warning);
+        #else
+        PyErr_WarnEx(NULL, warning, 0);
+        #endif
+    }
+    else if (((PyTypeObject *)result)->tp_basicsize != size) {
+        PyErr_Format(PyExc_ValueError, 
+            "%s.%s has the wrong size, try recompiling",
+            module_name, class_name);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_module);
+    Py_XDECREF(result);
+    return 0;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(name);
+    #else
+    py_name = PyUnicode_FromString(name);
+    #endif
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
+#endif
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(const char *funcname) {
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    PyObject *py_globals = 0;
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(__pyx_filename);
+    #else
+    py_srcfile = PyUnicode_FromString(__pyx_filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (__pyx_clineno) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    py_code = PyCode_New(
+        0,            /*int argcount,*/
+        #if PY_MAJOR_VERSION >= 3
+        0,            /*int kwonlyargcount,*/
+        #endif
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple,  /*PyObject *consts,*/
+        __pyx_empty_tuple,  /*PyObject *names,*/
+        __pyx_empty_tuple,  /*PyObject *varnames,*/
+        __pyx_empty_tuple,  /*PyObject *freevars,*/
+        __pyx_empty_tuple,  /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        __pyx_lineno,   /*int firstlineno,*/
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    if (!py_code) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = __pyx_lineno;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else  /* Python 3+ has unicode identifiers */
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+/* Type Conversion Functions */
+
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
+  PyNumberMethods *m;
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_VERSION_HEX < 0x03000000
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return Py_INCREF(x), x;
+  m = Py_TYPE(x)->tp_as_number;
+#if PY_VERSION_HEX < 0x03000000
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+#else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+#endif
+  if (res) {
+#if PY_VERSION_HEX < 0x03000000
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%s__ returned non-%s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject* x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+#if PY_VERSION_HEX < 0x02050000
+   if (ival <= LONG_MAX)
+       return PyInt_FromLong((long)ival);
+   else {
+       unsigned char *bytes = (unsigned char *) &ival;
+       int one = 1; int little = (int)*(unsigned char*)&one;
+       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
+   }
+#else
+   return PyInt_FromSize_t(ival);
+#endif
+}
+
+static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
+   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
+   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
+       return (size_t)-1;
+   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
+       PyErr_SetString(PyExc_OverflowError,
+                       "value too large to convert to size_t");
+       return (size_t)-1;
+   }
+   return (size_t)val;
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/pysam/TabProxies.pxd b/pysam/TabProxies.pxd
new file mode 100644 (file)
index 0000000..32597af
--- /dev/null
@@ -0,0 +1,97 @@
+cdef extern from "stdlib.h":
+    void free(void *)
+    void *malloc(size_t)       
+    void *calloc(size_t,size_t)
+    void *realloc(void *,size_t)
+    int c_abs "abs" (int)  
+    int c_abs "abs" (int)
+    int atoi( char *nptr)
+    long atol( char *nptr)
+    double atof( char *nptr)
+
+cdef extern from "Python.h":
+    ctypedef struct FILE
+    FILE* PyFile_AsFile(object)
+    char *fgets(char *str, int size, FILE *ifile)
+    int feof(FILE *stream)
+    size_t strlen(char *s)
+    size_t getline(char **lineptr, size_t *n, FILE *stream)
+    char *strstr(char *, char *)
+    char *strchr(char *string, int c)
+    int fileno(FILE *stream)
+
+cdef extern from "string.h":
+  int strcmp(char *s1, char *s2)
+  int strncmp(char *s1,char *s2,size_t len)
+  char *strcpy(char *dest,char *src)
+  char *strncpy(char *dest,char *src, size_t len)
+  char *strdup(char *)
+  char *strcat(char *,char *)
+  size_t strlen(char *s)
+  int memcmp( void * s1, void *s2, size_t len )
+  void *memcpy(void *dest, void *src, size_t n)
+  void *memchr(void *s, int c, size_t n)
+
+cdef extern from "stdint.h":
+  ctypedef int int64_t
+  ctypedef int int32_t
+  ctypedef int uint32_t
+  ctypedef int uint8_t
+  ctypedef int uint64_t
+
+cdef class TupleProxy:
+
+    cdef:
+        char * data
+        char ** fields
+        int nfields
+        int index
+        int nbytes
+        int offset
+        cdef bint is_modified
+
+    cdef int getMaxFields( self, size_t nbytes )
+
+    cdef take( self, char * buffer, size_t nbytes )
+    cdef present( self, char * buffer, size_t nbytes )
+    cdef copy( self, char * buffer, size_t nbytes )
+    cdef update( self, char * buffer, size_t nbytes )
+
+cdef class GTFProxy( TupleProxy) :
+
+    cdef:
+        char * contig
+        char * source
+        char * feature
+        uint32_t start
+        uint32_t end
+        char * score
+        char * strand
+        char * frame
+        char * attributes
+        cdef bint hasOwnAttributes
+
+    cdef int getMaxFields( self, size_t nbytes )
+    cdef update( self, char * buffer, size_t nbytes )
+
+cdef class NamedTupleProxy( TupleProxy) :
+    pass
+
+cdef class BedProxy( NamedTupleProxy) :
+
+    cdef:
+        char * contig
+        uint32_t start
+        uint32_t end
+        int bedfields
+
+    cdef int getMaxFields( self, size_t nbytes )
+    cdef update( self, char * buffer, size_t nbytes )
+
+cdef class VCFProxy( NamedTupleProxy) :
+
+    cdef:
+        char * contig
+        uint32_t pos
+
+    cdef update( self, char * buffer, size_t nbytes )
diff --git a/pysam/TabProxies.pyx b/pysam/TabProxies.pyx
new file mode 100644 (file)
index 0000000..36295eb
--- /dev/null
@@ -0,0 +1,617 @@
+import types
+from cpython cimport PyString_FromStringAndSize, PyString_AsString, PyString_AS_STRING
+
+cdef char * nextItem( char * buffer ):
+    cdef char * pos
+    pos = strchr( buffer, '\t' )
+    if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
+    pos[0] = '\0'
+    pos += 1
+    return pos
+
+cdef char *StrOrEmpty( char * buffer ):
+     if buffer == NULL: return ""
+     else: return buffer
+
+cdef int isNew( char * p, char * buffer, size_t nbytes ):
+     if p == NULL: return 0
+     return not (buffer <= p < buffer + nbytes )
+
+cdef class TupleProxy:
+    '''Proxy class for access to parsed row as a tuple.
+
+    This class represents a table row for fast read-access.
+
+    Access to individual fields is via the [] operator.
+    
+    Only read-only access is implemented.
+    '''
+
+    def __cinit__(self ): 
+        self.data = NULL
+        self.fields = NULL
+        self.index = 0
+        self.nbytes = 0
+        self.is_modified = 0
+        self.nfields = 0
+        # start counting at field offset
+        self.offset = 0
+
+    def __dealloc__(self):
+        cdef int x
+        if self.is_modified:
+            for x from 0 <= x < self.nfields:
+                if isNew( self.fields[x], self.data, self.nbytes ):
+                    free( self.fields[x] )
+                    self.fields[x] = NULL
+
+        if self.data != NULL: free(self.data)
+        if self.fields != NULL: free( self.fields )
+
+    cdef take( self, char * buffer, size_t nbytes ):
+        '''start presenting buffer.
+
+        Take ownership of the pointer.
+        '''
+        self.data = buffer
+        self.nbytes = nbytes
+        self.update( buffer, nbytes )
+
+    cdef present( self, char * buffer, size_t nbytes ):
+        '''start presenting buffer.
+
+        Do not take ownership of the pointer.
+        '''
+        self.update( buffer, nbytes )
+
+    cdef copy( self, char * buffer, size_t nbytes ):
+        '''start presenting buffer.
+
+        Take a copy of buffer.
+        '''
+        cdef int s
+        # +1 for '\0'
+        s = sizeof(char) *  (nbytes + 1)
+        self.data = <char*>malloc( s ) 
+        if self.data == NULL:
+            raise ValueError("out of memory" )
+        self.nbytes = nbytes
+        memcpy( <char*>self.data, buffer, s )
+        self.update( self.data, nbytes )
+
+    cdef int getMaxFields( self, size_t nbytes ):
+        '''initialize fields.'''
+        return nbytes / 2
+
+    cdef update( self, char * buffer, size_t nbytes ):
+        '''update internal data.
+
+        Update starts work in buffer, thus can be used
+        to collect any number of fields until nbytes
+        is exhausted.
+
+        If max_fields is set, the number of fields is initialized to max_fields.
+
+        '''
+        cdef char * pos
+        cdef char * old_pos
+        cdef int field
+        cdef int max_fields, x
+
+        if buffer[nbytes] != 0:
+            raise ValueError( "incomplete line at %s" % buffer )
+
+        #################################
+        # clear data
+        if self.fields != NULL: free(self.fields)
+        
+        for field from 0 <= field < self.nfields:
+            if isNew( self.fields[field], self.data, self.nbytes ):
+                free( self.fields[field] )
+                
+        self.is_modified = self.nfields = 0
+
+        #################################
+        # allocate new
+        max_fields = self.getMaxFields( nbytes )
+        self.fields = <char **>calloc( max_fields, sizeof(char *) ) 
+        if self.fields == NULL:
+            raise ValueError("out of memory" )
+
+        #################################
+        # start filling
+        field = 0
+        self.fields[field] = pos = buffer
+        field += 1
+        old_pos = pos
+        
+        while 1:
+
+            pos = <char*>memchr( pos, '\t', nbytes )
+            if pos == NULL: break
+            pos[0] = '\0'
+            pos += 1
+            self.fields[field] = pos
+            field += 1
+            if field >= max_fields:
+                raise ValueError("row too large - more than %i fields" % max_fields )
+            nbytes -= pos - old_pos
+            if nbytes < 0: break
+            old_pos = pos
+
+        self.nfields = field
+
+    def __getitem__( self, key ):
+
+        cdef int i = key
+        if i < 0: i += self.nfields
+        if i < 0: raise IndexError( "list index out of range" )
+        i += self.offset
+        if i >= self.nfields:
+            raise IndexError( "list index out of range" )
+        return self.fields[i]
+
+    def _setindex( self, index, value ):
+        '''set item at idx index.'''
+        cdef int idx = index
+        if idx < 0: raise IndexError( "list index out of range" )        
+        if idx >= self.nfields:
+            raise IndexError( "list index out of range" )
+
+        if isNew( self.fields[idx], self.data, self.nbytes ):
+            free( self.fields[idx] )
+
+        self.is_modified = 1
+
+        if value == None:
+            self.fields[idx] = NULL
+            return
+
+        # conversion with error checking
+        cdef char * tmp = PyString_AsString( value )
+        self.fields[idx] = <char*>malloc( (strlen( tmp ) + 1) * sizeof(char) )
+        if self.fields[idx] == NULL:
+            raise ValueError("out of memory" )
+        strcpy( self.fields[idx], tmp )
+
+    def __setitem__(self, index, value ):
+        '''set item at *index* to *value*'''
+        cdef int i = index
+        if i < 0: i += self.nfields
+        i += self.offset
+        
+        self._setindex( i, value )
+
+    def __len__(self):
+        return self.nfields
+
+    def __iter__(self):
+        self.index = 0
+        return self
+
+    def __next__(self): 
+        """python version of next().
+        """
+        if self.index >= self.nfields:
+            raise StopIteration
+        cdef char * retval = self.fields[self.index]
+        self.index += 1
+        if retval == NULL: return None
+        else: return retval
+
+    def __str__(self):
+        '''return original data'''
+        # copy and replace \0 bytes with \t characters
+        if self.is_modified:
+            # todo: treat NULL values
+            return "\t".join( [StrOrEmpty( self.fields[x]) for x in xrange(0, self.nfields ) ] )
+        else:
+            cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
+            if cpy == NULL:
+                raise ValueError("out of memory" )
+            memcpy( cpy, self.data, self.nbytes+1)
+            for x from 0 <= x < self.nbytes:
+                if cpy[x] == '\0': cpy[x] = '\t'
+            result = PyString_FromStringAndSize(cpy, self.nbytes)
+            free(cpy)
+            return result
+
+def toDot( v ):
+    '''convert value to '.' if None'''
+    if v == None: return "." 
+    else: return str(v)
+
+def quote( v ):
+    '''return a quoted attribute.'''
+    if type(v) in types.StringTypes:
+        return '"%s"' % v
+    else: 
+        return str(v)
+
+cdef class GTFProxy( TupleProxy ):
+    '''Proxy class for access to GTF fields.
+
+    This class represents a GTF entry for fast read-access.
+    Write-access has been added as well, though some care must
+    be taken. If any of the string fields (contig, source, ...)
+    are set, the new value is tied to the lifetime of the
+    argument that was supplied.
+
+    The only exception is the attributes field when set from
+    a dictionary - this field will manage its own memory.
+
+    '''
+
+    def __cinit__(self ): 
+        # automatically calls TupleProxy.__cinit__
+        self.hasOwnAttributes = False
+
+    def __dealloc__(self):
+        # automatically calls TupleProxy.__dealloc__
+        if self.hasOwnAttributes:
+            free(self.attributes)
+
+    cdef int getMaxFields( self, size_t nbytes ):
+        '''return max number of fields.'''
+        return 9
+
+    cdef update( self, char * buffer, size_t nbytes ):
+        '''update internal data.
+
+        nbytes does not include the terminal '\0'.
+        '''
+        cdef int end
+        cdef char * cstart, * cend, * cscore
+        self.contig = buffer
+        cdef char * pos
+
+        if buffer[nbytes] != 0:
+            raise ValueError( "incomplete line at %s" % buffer )
+        
+        self.source = pos = nextItem( buffer )
+        self.feature = pos = nextItem( pos )
+        cstart = pos = nextItem( pos )
+        cend = pos = nextItem( pos )
+        self.score = pos = nextItem( pos )
+        self.strand = pos = nextItem( pos )
+        self.frame = pos = nextItem( pos )
+        self.attributes = pos = nextItem( pos )
+
+        self.start = atoi( cstart ) - 1
+        self.end = atoi( cend )
+                      
+    property contig:
+       '''contig of feature.'''
+       def __get__( self ): return self.contig
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.contig = value
+
+    property feature:
+       '''feature name.'''
+       def __get__( self ): return self.feature
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.feature = value
+
+    property source:
+       '''feature source.'''
+       def __get__( self ): return self.source
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.source = value
+
+    property start:
+       '''feature start (in 0-based open/closed coordinates).'''
+       def __get__( self ): return self.start
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.start = value
+
+    property end:
+       '''feature end (in 0-based open/closed coordinates).'''
+       def __get__( self ): return self.end
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.end = value
+
+    property score:
+       '''feature score.'''
+       def __get__( self ): 
+           if self.score[0] == '.' and self.score[1] == '\0' :
+               return None
+           else:
+               return atof(self.score)
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.score = value
+
+    property strand:
+       '''feature strand.'''
+       def __get__( self ): return self.strand
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.strand = value
+
+    property frame:
+       '''feature frame.'''
+       def __get__( self ): return self.frame
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.frame = value
+
+    property attributes:
+       '''feature attributes (as a string).'''
+       def __get__( self ): return self.attributes
+       def __set__( self, value ): 
+           self.is_modified = True
+           self.attributes = value
+
+    def asDict( self ):
+        """parse attributes - return as dict
+        """
+
+        # remove comments
+        attributes = self.attributes
+
+        # separate into fields
+        fields = [ x.strip() for x in attributes.split(";")[:-1]]
+        
+        result = {}
+
+        for f in fields:
+            
+            d = [ x.strip() for x in f.split(" ")]
+            
+            n,v = d[0], d[1]
+            if len(d) > 2: v = d[1:]
+
+            if v[0] == '"' and v[-1] == '"':
+                v = v[1:-1]
+            else:
+                ## try to convert to a value
+                try:
+                    v = float( v )
+                    v = int( v )
+                except ValueError:
+                    pass
+                except TypeError:
+                    pass
+
+            result[n] = v
+        
+        return result
+    
+    def fromDict( self, d ):
+        '''set attributes from a dictionary.'''
+        cdef char * p
+        cdef int l
+
+        # clean up if this field is set twice
+        if self.hasOwnAttributes:
+            free(self.attributes)
+
+        aa = []
+        for k,v in d.items():
+            if type(v) == types.StringType:
+                aa.append( '%s "%s"' % (k,v) )
+            else:
+                aa.append( '%s %s' % (k,str(v)) )
+
+        a = "; ".join( aa ) + ";"
+        p = a
+        l = len(a)
+        self.attributes = <char *>calloc( l + 1, sizeof(char) )
+        if self.attributes == NULL:
+            raise ValueError("out of memory" )
+        memcpy( self.attributes, p, l )
+
+        self.hasOwnAttributes = True
+        self.is_modified = True
+
+    def __str__(self):
+        cdef char * cpy
+        cdef int x
+
+        if self.is_modified:
+            return "\t".join( 
+                (self.contig, 
+                 self.source, 
+                 self.feature, 
+                 str(self.start+1),
+                 str(self.end),
+                 toDot(self.score),
+                 self.strand,
+                 self.frame,
+                 self.attributes ) )
+        else: 
+            return TupleProxy.__str__(self)
+
+    def invert( self, int lcontig ):
+        '''invert coordinates to negative strand coordinates
+        
+        This method will only act if the feature is on the
+        negative strand.'''
+
+        if self.strand[0] == '-':
+            start = min(self.start, self.end)
+            end = max(self.start, self.end)
+            self.start, self.end = lcontig - end, lcontig - start
+
+    def keys( self ):
+        '''return a list of attributes defined in this entry.'''
+        r = self.attributes
+        return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
+
+    def __getitem__(self, item):
+        return self.__getattr__( item )
+
+    def __getattr__(self, item ):
+        """Generic lookup of attribute from GFF/GTF attributes 
+        Only called if there *isn't* an attribute with this name
+        """
+        cdef char * start
+        cdef char * query 
+        cdef char * cpy
+        cdef char * end
+        cdef int l
+        query = item
+        
+        start = strstr( self.attributes, query)
+        if start == NULL:
+            raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
+
+        start += strlen(query) + 1
+        # skip gaps before
+        while start[0] == " ": start += 1
+        if start[0] == '"':
+            start += 1
+            end = start
+            while end[0] != '\0' and end[0] != '"': end += 1
+            l = end - start + 1
+            cpy = <char*>calloc( l, sizeof(char ) )
+            if cpy == NULL: raise ValueError("out of memory" )
+            memcpy( cpy, start, l )
+            cpy[l-1] = '\0'
+            result = cpy
+            free(cpy)
+            return result
+        else:
+            return start
+
+    def setAttribute( self, name, value ):
+        '''convenience method to set an attribute.'''
+        r = self.asDict()
+        r[name] = value
+        self.fromDict( r )
+
+cdef class NamedTupleProxy( TupleProxy ):
+
+    map_key2field = {}
+
+    def __setattr__(self, key, value ):
+        '''set attribute.'''
+        cdef int idx
+        idx, f = self.map_key2field[key]
+        if self.nfields < idx:
+            raise KeyError( "field %s not set" % key )
+        TupleProxy.__setitem__(self, idx, str(value) )
+
+    def __getattr__(self, key ):
+        cdef int idx
+        idx, f = self.map_key2field[key]
+        if self.nfields < idx:
+            raise KeyError( "field %s not set" % key )
+        return f( self.fields[idx] )
+
+cdef class BedProxy( NamedTupleProxy ):
+    '''Proxy class for access to Bed fields.
+
+    This class represents a GTF entry for fast read-access.
+    '''
+    map_key2field = { 
+        'contig' : (0, str),
+        'start' : (1, int),
+        'end' : (2, int),
+        'name' : (3, str),
+        'score' : (4, float),
+        'strand' : (5, str),
+        'thickStart' : (6,int ),
+        'thickEnd' : (7,int),
+        'itemRGB' : (8,str),
+        'blockCount': (9,int),
+        'blockSizes': (10,str),
+        'blockStarts': (11,str), } 
+
+    cdef int getMaxFields( self, size_t nbytes ):
+        '''return max number of fields.'''
+        return 12
+
+    cdef update( self, char * buffer, size_t nbytes ):
+        '''update internal data.
+
+        nbytes does not include the terminal '\0'.
+        '''
+        TupleProxy.update( self, buffer, nbytes )
+
+        if self.nfields < 3:
+            raise ValueError( "bed format requires at least three columns" )
+
+        # determines bed format
+        self.bedfields = self.nfields
+
+        # do automatic conversion
+        self.contig = self.fields[0]
+        self.start = atoi( self.fields[1] ) 
+        self.end = atoi( self.fields[2] )
+
+    # __setattr__ in base class seems to take precedence
+    # hence implement setters in __setattr__
+    #property start:
+    #    def __get__( self ): return self.start
+    #property end:
+    #    def __get__( self ): return self.end
+
+    def __str__(self):
+
+        cdef int save_fields = self.nfields
+        # ensure fields to use correct format
+        self.nfields = self.bedfields
+        retval = TupleProxy.__str__( self )
+        self.nfields = save_fields
+        return retval
+
+    def __setattr__(self, key, value ):
+        '''set attribute.'''
+        if key == "start": self.start = value
+        elif key == "end": self.end = value
+
+        cdef int idx
+        idx, f = self.map_key2field[key]
+        TupleProxy._setindex(self, idx, str(value) )
+
+cdef class VCFProxy( NamedTupleProxy ):
+    '''Proxy class for access to VCF fields.
+
+    The genotypes are accessed via index.
+    '''
+    map_key2field = { 
+        'contig' : (0, str),
+        'pos' : (1, int),
+        'id' : (2, str),
+        'ref' : (3, str),
+        'alt' : (4, str),
+        'qual' : (5, str),
+        'filter' : (6,str),
+        'info' : (7,str),
+        'format' : (8,str) }
+
+    def __cinit__(self ): 
+        # automatically calls TupleProxy.__cinit__
+        # start indexed access at genotypes
+        self.offset = 9
+
+    cdef update( self, char * buffer, size_t nbytes ):
+        '''update internal data.
+        
+        nbytes does not include the terminal '\0'.
+        '''
+        TupleProxy.update( self, buffer, nbytes )
+
+        self.contig = self.fields[0]
+        # vcf counts from 1 - correct here
+        self.pos = atoi( self.fields[1] ) - 1
+
+    def __len__(self):
+        return max(0, self.nfields - 9)
+
+    def __setattr__(self, key, value ):
+        '''set attribute.'''
+        if key == "pos": 
+            self.pos = value
+            value += 1
+
+        cdef int idx
+        idx, f = self.map_key2field[key]
+        TupleProxy._setindex(self, idx, str(value) )
+    
diff --git a/pysam/VCF.py b/pysam/VCF.py
new file mode 100644 (file)
index 0000000..115aa2b
--- /dev/null
@@ -0,0 +1,1088 @@
+#
+# Code to read, write and edit VCF files
+#
+# VCF lines are encoded as a dictionary with these keys (note: all lowercase):
+# 'chrom':  string
+# 'pos':    integer
+# 'id':     string
+# 'ref':    string
+# 'alt':    list of strings
+# 'qual':   integer
+# 'filter': None (missing value), or list of keys (strings); empty list parsed as ["PASS"]
+# 'info':   dictionary of values (see below)
+# 'format': list of keys (strings)
+# sample keys: dictionary of values (see below)
+#
+# The sample keys are accessible through vcf.getsamples()
+#
+# A dictionary of values contains value keys (defined in ##INFO or ##FORMAT lines) which map
+# to a list, containign integers, floats, strings, or characters.  Missing values are replaced 
+# by a particular value, often -1 or .
+#
+# Genotypes are not stored as a string, but as a list of 1 or 3 elements (for haploid and diploid samples),
+# the first (and last) the integer representing an allele, and the second the separation character.
+# Note that there is just one genotype per sample, but for consistency the single element is stored in a list.
+#
+# Header lines other than ##INFO, ##FORMAT and ##FILTER are stored as (key, value) pairs and are accessible
+# through getheader()
+#
+# The VCF class can be instantiated with a 'regions' variable consisting of tuples (chrom,start,end) encoding
+# 0-based half-open segments.  Only variants with a position inside the segment will be parsed.  A regions
+# parser is available under parse_regions.
+#
+# When instantiated, a reference can be passed to the VCF class.  This may be any class that supports a
+# fetch(chrom, start, end) method.
+#
+#
+#
+# NOTE: the position that is returned to Python is 0-based, NOT 1-based as in the VCF file.
+#
+#
+#
+# TODO:
+#  only v4.0 writing is complete; alleles are not converted to v3.3 format
+#
+
+from collections import namedtuple, defaultdict
+from operator import itemgetter
+import sys, re, copy, bisect
+
+import pysam
+
+gtsRegEx = re.compile("[|/\\\\]")
+alleleRegEx = re.compile('^[ACGTN]+$')
+
+# Utility function.  Uses 0-based coordinates
+def get_sequence(chrom, start, end, fa):
+    # obtain sequence from .fa file, without truncation
+    if end<=start: return ""
+    if not fa: return "N"*(end-start)
+    if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+    sequence = fa.fetch(chrom, start, end).upper()
+    if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))
+    return sequence
+
+# Utility function.  Parses a region string
+def parse_regions( string ):
+    result = []
+    for r in string.split(','):
+        elts = r.split(':')
+        chrom, start, end = elts[0], 0, 3000000000
+        if len(elts)==1: pass
+        elif len(elts)==2:
+            if len(elts[1])>0:
+                ielts = elts[1].split('-')
+                if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+                try:    start, end = int(ielts[0])-1, int(ielts[1])
+                except: raise ValueError("Don't understand region string '%s'" % r)
+        else:
+            raise ValueError("Don't understand region string '%s'" % r)
+        result.append( (chrom,start,end) )
+    return result
+            
+
+FORMAT = namedtuple('FORMAT','id numbertype number type description missingvalue')
+
+###########################################################################################################
+# 
+# New class
+# 
+###########################################################################################################
+
+class VCFRecord:
+    '''vcf record.
+
+    initialized from data and vcf meta 
+    '''
+    
+    data = None
+    vcf = None
+
+    def __init__(self, data, vcf):
+        self.data, self.vcf = data, vcf
+
+        if len(data) != len(self.vcf._samples):
+            self.error(str(data),
+                       self.BAD_NUMBER_OF_COLUMNS, 
+                       "expected %s for %s samples (%s), got %s" % \
+                           (len(self.vcf._samples), 
+                            len(self.vcf._samples), 
+                            self.vcf._samples, 
+                            len(data)))
+        
+    property contig:
+    def contig( self ): return self.data[0]
+
+    property pos:
+    def __get__( self ): 
+            return self.data.pos
+        
+    property id:
+        def __get__( self ): return self.data[2]
+
+    property ref:
+        def __get__(self ): 
+            # note: gerton substitutes reference if it can be fixed.
+            return self.data[3].upper()
+
+    property alt:
+        def __get__(self):
+            # convert v3.3 to v4.0 alleles below
+            alt = self.data[4] 
+            if alt == ".": alt = []
+            else: alt = alt.upper().split(',')
+            return alt
+
+    property qual:
+        def __get__(self):
+            qual = self.data[5]
+            if qual == ".": qual = -1
+            else: 
+                try:    qual = float(qual)
+                except: self.error(line,self.QUAL_NOT_NUMERICAL)
+
+    property filter:
+        def __get__(self):
+            # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+            if cols[6] == "." or cols[6] == "PASS" or cols[6] == "0": filter = []
+            else: filter = cols[6].split(';')
+
+            return filter
+
+    property info:
+        def __get__(self):
+            col = self.data[7]
+            # dictionary of keys, and list of values
+            info = {}
+            if col != ".":
+                for blurp in col.split(';'):
+                    elts = blurp.split('=')
+                    if len(elts) == 1: v = None
+                    elif len(elts) == 2: v = elts[1]
+                    else: self.error(str(self.data),self.ERROR_INFO_STRING)
+                    info[elts[0]] = self.parse_formatdata(elts[0], v, self.vcf._info, line)
+            return info
+
+    property format:
+         def __get__(self):
+             return self.data[8].split(':')
+
+    def __getitem__(self, key):
+        
+        # parse sample columns
+        values = self.data[self.vcf._sample2column[key]].split(':')
+        alt = self.alt
+        format = self.format
+
+        if len(values) > len(format):
+            self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+
+        result = {}
+        for idx in range(len(format)):
+            expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)
+            if idx < len(values): value = values[idx]
+            else:
+                if expected == -1: value = "."
+                else: value = ",".join(["."]*expected)
+
+            result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, line)
+            if expected != -1 and len(result[format[idx]]) != expected:
+                self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+                           "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+                if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))
+                result[format[idx]] = result[format[idx]][:expected]
+
+        return result
+    def __str__(self):
+        return str(self.data)
+
+class VCF:
+
+    # types
+    NT_UNKNOWN = 0
+    NT_NUMBER = 1
+    NT_ALLELES = 2
+    NT_NR_ALLELES = 3
+    NT_GENOTYPES = 4
+    NT_PHASED_GENOTYPES = 5
+
+    _errors = { 0:"UNKNOWN_FORMAT_STRING:Unknown file format identifier",
+                1:"BADLY_FORMATTED_FORMAT_STRING:Formatting error in the format string",
+                2:"BADLY_FORMATTED_HEADING:Did not find 9 required headings (CHROM, POS, ..., FORMAT) %s",
+                3:"BAD_NUMBER_OF_COLUMNS:Wrong number of columns found (%s)",
+                4:"POS_NOT_NUMERICAL:Position column is not numerical",
+                5:"UNKNOWN_CHAR_IN_REF:Unknown character in reference field",
+                6:"V33_BAD_REF:Reference should be single-character in v3.3 VCF",
+                7:"V33_BAD_ALLELE:Cannot interpret allele for v3.3 VCF",
+                8:"POS_NOT_POSITIVE:Position field must be >0",
+                9:"QUAL_NOT_NUMERICAL:Quality field must be numerical, or '.'",
+               10:"ERROR_INFO_STRING:Error while parsing info field",
+               11:"ERROR_UNKNOWN_KEY:Unknown key (%s) found in formatted field (info; format; or filter)",
+               12:"ERROR_FORMAT_NOT_NUMERICAL:Expected integer or float in formatted field; got %s",
+               13:"ERROR_FORMAT_NOT_CHAR:Eexpected character in formatted field; got string",
+               14:"FILTER_NOT_DEFINED:Identifier (%s) in filter found which was not defined in header",
+               15:"FORMAT_NOT_DEFINED:Identifier (%s) in format found which was not defined in header",
+               16:"BAD_NUMBER_OF_VALUES:Found too many of values in sample column (%s)",
+               17:"BAD_NUMBER_OF_PARAMETERS:Found unexpected number of parameters (%s)",
+               18:"BAD_GENOTYPE:Cannot parse genotype (%s)",
+               19:"V40_BAD_ALLELE:Bad allele found for v4.0 VCF (%s)",
+               20:"MISSING_REF:Reference allele missing",
+               21:"V33_UNMATCHED_DELETION:Deleted sequence does not match reference (%s)",
+               22:"V40_MISSING_ANGLE_BRACKETS:Format definition is not deliminted by angular brackets",
+               23:"FORMAT_MISSING_QUOTES:Description field in format definition is not surrounded by quotes",
+               24:"V40_FORMAT_MUST_HAVE_NAMED_FIELDS:Fields in v4.0 VCF format definition must have named fields",
+               25:"HEADING_NOT_SEPARATED_BY_TABS:Heading line appears separated by spaces, not tabs",
+               26:"WRONG_REF:Wrong reference %s",
+               27:"ERROR_TRAILING_DATA:Numerical field ('%s') has semicolon-separated trailing data",
+               28:"BAD_CHR_TAG:Error calculating chr tag for %s",
+               29:"ZERO_LENGTH_ALLELE:Found zero-length allele",
+               30:"MISSING_INDEL_ALLELE_REF_BASE:Indel alleles must begin with single reference base"
+                }
+
+    # tag-value pairs; tags are not unique; does not include fileformat, INFO, FILTER or FORMAT fields
+    _header = []
+
+    # version number; 33=v3.3; 40=v4.0
+    _version = 40
+
+    # info, filter and format data
+    _info = {}
+    _filter = {}
+    _format = {}
+
+    # header; and required columns
+    _required = ["CHROM","POS","ID","REF","ALT","QUAL","FILTER","INFO","FORMAT"]
+    _samples = []
+
+    # control behaviour
+    _ignored_errors = set([11])   # ERROR_UNKNOWN_KEY
+    _warn_errors = set([])
+    _leftalign = False
+
+    # reference sequence
+    _reference = None
+
+    # regions to include; None includes everything
+    _regions = None
+
+    # statefull stuff
+    _lineno = -1
+    _line = None
+    _lines = None
+
+    def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):
+        # make error identifiers accessible by name
+        for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+        if _copy != None:
+            self._leftalign = _copy._leftalign
+            self._header = _copy._header[:]
+            self._version = _copy._version
+            self._info = copy.deepcopy(_copy._info)
+            self._filter = copy.deepcopy(_copy._filter)
+            self._format = copy.deepcopy(_copy._format)
+            self._samples = _copy._samples[:]
+            self._sample2column = copy.deepcopy(_copy._sample2column)
+            self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+            self._warn_errors = copy.deepcopy(_copy._warn_errors)
+            self._reference = _copy._reference
+            self._regions = _copy._regions
+        if reference: self._reference = reference
+        if regions: self._regions = regions
+        if leftalign: self._leftalign = leftalign
+        self._lines = lines
+
+    def error(self,line,error,opt=None):
+        if error in self._ignored_errors: return
+        errorlabel, errorstring = self._errors[error].split(':')
+        if opt: errorstring = errorstring % opt
+        errwarn = ["Error","Warning"][error in self._warn_errors]
+        sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+        if error in self._warn_errors: return
+        raise ValueError(errorstring)
+
+    def parse_format(self,line,format,filter=False):
+        if self._version == 40:
+            if not format.startswith('<'): 
+                self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+                format = "<"+format
+            if not format.endswith('>'): 
+                self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+                format += ">"
+            format = format[1:-1]
+        data = {'id':None,'number':None,'type':None,'descr':None}
+        idx = 0
+        while len(format.strip())>0:
+            elts = format.strip().split(',')
+            first, rest = elts[0], ','.join(elts[1:])
+            if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+                if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+                if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+                first = ["ID=","Number=","Type=","Description="][idx] + first
+            if first.startswith('ID='):            data['id'] = first.split('=')[1]
+            elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+            elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+            elif first.startswith('Description='):
+                elts = format.split('"')
+                if len(elts)<3: 
+                    self.error(line,self.FORMAT_MISSING_QUOTES)
+                    elts = first.split('=') + [rest] 
+                data['descr'] = elts[1]
+                rest = '"'.join(elts[2:])
+                if rest.startswith(','): rest = rest[1:]
+            else:
+                self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+            format = rest
+            idx += 1
+            if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+        if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        if not data['descr']: 
+            self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+            data['descr'] = '<none>'
+        if not data['type'] and not data['number']:
+            # fine, ##filter format
+            return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')
+        if not data['type'] in ["Integer","Float","Character","String","Flag"]:
+            self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        # I would like a missing-value field, but it isn't there
+        if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value
+        else:                                   data['missing'] = '.'
+        if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        try:
+            n = int(data['number'])
+            t = self.NT_NUMBER
+        except ValueError:
+            n = -1
+            if data['number'] == '.':                   t = self.NT_UNKNOWN
+            elif data['number'] == '#alleles':          t = self.NT_ALLELES
+            elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+            elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES
+            elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES
+            else:
+                self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        return FORMAT(data['id'],t,n,data['type'],data['descr'],data['missing'])
+    
+
+    def format_format( self, fmt, filter=False ):
+        values = [('ID',fmt.id)]
+        if fmt.number != None and not filter:
+            if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+            elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+            elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+            elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+            elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"
+            elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"
+            else:
+                raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)
+            values.append( ('Number',nmb) )
+            values.append( ('Type', fmt.type) )
+        values.append( ('Description', '"' + fmt.description + '"') )
+        if self._version == 33:
+            format = ",".join(v for k,v in values)
+        else:
+            format = "<" + (",".join( "%s=%s" % (k,v) for (k,v) in values )) + ">"
+        return format
+
+    def get_expected(self, format, formatdict, alt):
+        fmt = formatdict[format]
+        if fmt.numbertype == self.NT_UNKNOWN: return -1
+        if fmt.numbertype == self.NT_NUMBER: return fmt.number
+        if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+        if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+        if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+        if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)
+        return 0
+
+
+    def _add_definition(self, formatdict, key, data, line ):
+        if key in formatdict: return
+        self.error(line,self.ERROR_UNKNOWN_KEY,key)
+        if data == None:
+            formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+            return
+        if data == []: data = [""]             # unsure what type -- say string
+        if type(data[0]) == type(0.0):
+            formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+            return
+        if type(data[0]) == type(0):
+            formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+            return
+        formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"String","(Undefined tag)",".")
+
+
+    # todo: trim trailing missing values
+    def format_formatdata( self, data, format, key=True, value=True, separator=":" ):
+        output, sdata = [], []
+        if type(data) == type([]): # for FORMAT field, make data with dummy values
+            d = {}
+            for k in data: d[k] = []
+            data = d
+        # convert missing values; and silently add definitions if required
+        for k in data:
+            self._add_definition( format, k, data[k], "(output)" )
+            for idx,v in enumerate(data[k]):
+                if v == format[k].missingvalue: data[k][idx] = "."
+        # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+        for k in data: 
+            if k != 'GT': sdata.append( (k,data[k]) )
+        sdata.sort()
+        if 'GT' in data:
+            sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+        for k,v in sdata:
+            if v == []: v = None
+            if key and value:
+                if v != None: output.append( k+"="+','.join(map(str,v)) )
+                else: output.append( k )
+            elif key: output.append(k)
+            elif value:
+                if v != None: output.append( ','.join(map(str,v)) )
+                else: output.append( "." )                    # should not happen
+        # snip off trailing missing data
+        while len(output) > 1:
+            last = output[-1].replace(',','').replace('.','')
+            if len(last)>0: break
+            output = output[:-1]
+        return separator.join(output)
+
+
+    def enter_default_format(self):
+        for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+                  FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+                  FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+                  FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+                  FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+            if f.id not in self._format:
+                self._format[f.id] = f
+
+    def parse_header( self, line ):
+        assert line.startswith('##')
+        elts = line[2:].split('=')
+        key = elts[0].strip()
+        value = '='.join(elts[1:]).strip()
+        if key == "fileformat":
+            if value == "VCFv3.3":
+                self._version = 33
+            elif value == "VCFv4.0":
+                self._version = 40
+            elif value == "VCFv4.1":
+                # AH - for testing
+                self._version = 40
+            else:
+                self.error(line,self.UNKNOWN_FORMAT_STRING)
+        elif key == "INFO":
+            f = self.parse_format(line, value)
+            self._info[ f.id ] = f
+        elif key == "FILTER":
+            f = self.parse_format(line, value, filter=True)
+            self._filter[ f.id ] = f
+        elif key == "FORMAT":
+            f = self.parse_format(line, value)
+            self._format[ f.id ] = f
+        else:
+            # keep other keys in the header field
+            self._header.append( (key,value) )
+
+
+    def write_header( self, stream ):
+        stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+        for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+        for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:
+            for f in var.itervalues(): stream.write("##%s=%s\n" % (label,self.format_format(f,filter=(label=="FILTER"))))
+        
+
+    def parse_heading( self, line ):
+        assert line.startswith('#')
+        assert not line.startswith('##')
+        headings = line[1:].split('\t')
+        if len(headings)==1 and len(line[1:].split()) >= 9:
+            self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)
+            headings = line[1:].split()
+
+        for i,s in enumerate(self._required):
+
+            if len(headings)<=i or headings[i] != s:
+
+                if len(headings) <= i: 
+                    err = "(%sth entry not found)" % (i+1)
+                else:
+                    err = "(found %s, expected %s)" % (headings[i],s)
+
+                #self.error(line,self.BADLY_FORMATTED_HEADING,err)
+
+                # allow FORMAT column to be absent
+                if len(headings) == 8:
+                    headings.append("FORMAT")
+                else:
+                    self.error(line,self.BADLY_FORMATTED_HEADING,err)
+
+        self._samples = headings[9:]
+        self._sample2column = dict( [(y,x) for x,y in enumerate( self._samples ) ] )
+                           
+    def write_heading( self, stream ):
+        stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+
+    def convertGT(self, GTstring):
+        if GTstring == ".": return ["."]
+        try:
+            gts = gtsRegEx.split(GTstring)
+            if len(gts) == 1: return [int(gts[0])]
+            if len(gts) != 2: raise ValueError()
+            if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+            return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+        except ValueError:
+            self.error(self._line,self.BAD_GENOTYPE,GTstring)
+            return [".","|","."]
+
+
+    def convertGTback(self, GTdata):
+        return ''.join(map(str,GTdata))
+
+    def parse_formatdata( self, key, value, formatdict, line ):
+        # To do: check that the right number of values is present
+        f = formatdict.get(key,None)
+        if f == None:
+            self._add_definition(formatdict, key, value, line )
+            f = formatdict[key]
+        if f.type == "Flag":
+            if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+            return []
+        values = value.split(',')
+        # deal with trailing data in some early VCF files
+        if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:
+            self.error(line,self.ERROR_TRAILING_DATA,values[-1])
+            values[-1] = values[-1].split(';')[0]
+        if f.type == "Integer": 
+            for idx,v in enumerate(values):
+                try:
+                    if v == ".": values[idx] = f.missingvalue
+                    else:        values[idx] = int(v)
+                except: 
+                    self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+                    return [0] * len(values)
+            return values
+        elif f.type == "String":
+            self._line = line
+            if f.id == "GT": values = map( self.convertGT, values )
+            return values
+        elif f.type == "Character":
+            for v in values: 
+                if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+            return values
+        elif f.type == "Float":
+            for idx,v in enumerate(values):
+                if v == ".": values[idx] = f.missingvalue
+            try: return map(float,values)
+            except:
+                self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+                return [0.0] * len(values)
+        else:
+            # can't happen
+            self.error(line,self.ERROR_INFO_STRING)
+
+
+    def inregion(self, chrom, pos):
+        if not self._regions: return True
+        for r in self._regions:
+            if r[0] == chrom and r[1] <= pos < r[2]: return True
+        return False
+        
+
+    def parse_data( self, line, lineparse=False ):
+        cols = line.split('\t')
+        if len(cols) != len(self._samples)+9:
+            # gracefully deal with absent FORMAT column
+            if len(cols) == 8 and len(self._samples)==0:
+                cols.append("")
+            else:
+                self.error(line,
+                           self.BAD_NUMBER_OF_COLUMNS, 
+                           "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))
+
+        chrom = cols[0]
+
+        # get 0-based position
+        try:    pos = int(cols[1])-1
+        except: self.error(line,self.POS_NOT_NUMERICAL)
+        if pos < 0: self.error(line,self.POS_NOT_POSITIVE)
+
+        # implement filtering
+        if not self.inregion(chrom,pos): return None
+
+        # end of first-pass parse for sortedVCF
+        if lineparse: return chrom, pos, line
+        
+        id = cols[2]
+
+        ref = cols[3].upper()
+        if ref == ".":
+            self.error(line,self.MISSING_REF)
+            if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+            else:                   ref = ""
+        else:
+            for c in ref:
+                if c not in "ACGTN": self.error(line,self.UNKNOWN_CHAR_IN_REF)
+            if "N" in ref: ref = get_sequence(chrom,pos,pos+len(ref),self._reference)
+
+        # make sure reference is sane
+        if self._reference:
+            left = max(0,pos-100)
+            faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+            faref = faref_leftflank[pos-left:]
+            if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+            ref = faref
+
+        # convert v3.3 to v4.0 alleles below
+        if cols[4] == ".": alt = []
+        else: alt = cols[4].upper().split(',')
+
+        if cols[5] == ".": qual = -1
+        else: 
+            try:    qual = float(cols[5])
+            except: self.error(line,self.QUAL_NOT_NUMERICAL)
+
+        # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+        if cols[6] == "." or cols[6] == "PASS" or cols[6] == "0": filter = []
+        else: filter = cols[6].split(';')
+
+        # dictionary of keys, and list of values
+        info = {}
+        if cols[7] != ".":
+            for blurp in cols[7].split(';'):
+                elts = blurp.split('=')
+                if len(elts) == 1: v = None
+                elif len(elts) == 2: v = elts[1]
+                else: self.error(line,self.ERROR_INFO_STRING)
+                info[elts[0]] = self.parse_formatdata(elts[0], v, self._info, line)
+
+        # Gracefully deal with absent FORMAT column
+        if cols[8] == "": format = []
+        else: format = cols[8].split(':')
+
+        # check: all filters are defined
+        for f in filter:
+            if f not in self._filter: self.error(line,self.FILTER_NOT_DEFINED, f)
+            
+        # check: format fields are defined
+        for f in format:
+            if f not in self._format: self.error(line,self.FORMAT_NOT_DEFINED, f)
+
+        # convert v3.3 alleles
+        if self._version == 33:
+            if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+            newalts = []
+            have_deletions = False
+            for a in alt:
+                if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+                elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+                elif a.startswith('D'): # allow D<seq> and D<num>
+                    have_deletions = True
+                    try:
+                        l = int(a[1:])          # throws ValueError if sequence
+                        if len(ref) < l:        # add to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[l:]             # new deletion, deleting pos...pos+l
+                    except ValueError:
+                        s = a[1:]
+                        if len(ref) < len(s):   # add Ns to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+                            if not s.endswith(addns) and addns != 'N'*len(addns):
+                                self.error(line,self.V33_UNMATCHED_DELETION,
+                                           "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[len(s):]        # new deletion, deleting from pos
+                else:
+                    self.error(line,self.V33_BAD_ALLELE)
+                newalts.append(a)
+            alt = newalts
+            # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+            if have_deletions:
+                if pos == 0:
+                    # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+                    addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+                    ref += addn
+                    alt = [allele+addn for allele in alt]
+                else:
+                    addn = get_sequence(chrom,pos-1,pos,self._reference)
+                    ref = addn + ref
+                    alt = [addn + allele for allele in alt]
+                    pos -= 1
+        else:
+            # format v4.0 -- just check for nucleotides
+            for allele in alt:
+                if not alleleRegEx.match(allele):
+                    self.error(line,self.V40_BAD_ALLELE,allele)
+
+        # check for leading nucleotide in indel calls
+        for allele in alt:
+            if len(allele) != len(ref):
+                if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+                if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+                    self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)
+
+        # trim trailing bases in alleles
+        for i in range(1,min(len(ref),min(map(len,alt)))):
+            if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+                break
+            ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+
+        # left-align alleles, if a reference is available
+        if self._leftalign and self._reference:
+            while left < pos:
+                movable = True
+                for allele in alt:
+                    if len(allele) > len(ref):
+                        longest, shortest = allele, ref
+                    else:
+                        longest, shortest = ref, allele
+                    if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+                        movable = False
+                    if longest[-1].upper() != longest[len(shortest)-1].upper():
+                        movable = False
+                if not movable:
+                    break
+                ref = ref[:-1]
+                alt = [allele[:-1] for allele in alt]
+                if min(len(allele) for allele in alt) == 0 or len(ref) == 0:
+                    ref = faref_leftflank[pos-left-1] + ref
+                    alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+                    pos -= 1
+
+        # parse sample columns
+        samples = []
+        for sample in cols[9:]:
+            dict = {}
+            values = sample.split(':')
+            if len(values) > len(format):
+                self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+            for idx in range(len(format)):
+                expected = self.get_expected(format[idx], self._format, alt)
+                if idx < len(values): value = values[idx]
+                else:
+                    if expected == -1: value = "."
+                    else: value = ",".join(["."]*expected)
+                dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+                if expected != -1 and len(dict[format[idx]]) != expected:
+                    self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+                               "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+                    if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+                    dict[format[idx]] = dict[format[idx]][:expected]
+            samples.append( dict )
+
+        # done
+        d = {'chrom':chrom,
+             'pos':pos,      # return 0-based position
+             'id':id,
+             'ref':ref,
+             'alt':alt,
+             'qual':qual,
+             'filter':filter,
+             'info':info,
+             'format':format}
+        for key,value in zip(self._samples,samples):
+            d[key] = value
+        
+        return d
+
+
+    def write_data(self, stream, data):
+        required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+        for k in required:
+            if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+        if data['alt'] == []: alt = "."
+        else: alt = ",".join(data['alt'])
+        if data['filter'] == None: filter = "."
+        elif data['filter'] == []: 
+            if self._version == 33: filter = "0"
+            else: filter = "PASS"
+        else: filter = ';'.join(data['filter'])
+        if data['qual'] == -1: qual = "."
+        else: qual = str(data['qual'])
+
+        output = [data['chrom'], 
+                  str(data['pos']+1),   # change to 1-based position
+                  data['id'],
+                  data['ref'],
+                  alt,
+                  qual,
+                  filter,
+                  self.format_formatdata( data['info'], self._info, separator=";" ),
+                  self.format_formatdata( data['format'], self._format, value=False ) ]
+        
+        for s in self._samples:
+            output.append( self.format_formatdata( data[s], self._format, key=False ) )
+        
+        stream.write( "\t".join(output) + "\n" )
+
+    def _parse_header(self, stream):
+        self._lineno = 0
+        for line in stream:
+            self._lineno += 1
+            if line.startswith('##'):
+                self.parse_header( line.strip() )
+            elif line.startswith('#'):
+                self.parse_heading( line.strip() )
+                self.enter_default_format()
+            else:
+                break
+        return line
+
+    def _parse(self, line, stream):
+        if len(line.strip()) > 0:
+            d = self.parse_data( line.strip() )
+            if d: yield d
+        for line in stream:
+            self._lineno += 1
+            if self._lines and self._lineno > self._lines: raise StopIteration
+            d = self.parse_data( line.strip() )
+            if d: yield d
+
+    ######################################################################################################
+    #
+    # API follows
+    #
+    ######################################################################################################
+
+    def getsamples(self):
+        """ List of samples in VCF file """
+        return self._samples
+
+    def setsamples(self,samples):
+        """ List of samples in VCF file """
+        self._samples = samples
+
+    def getheader(self):
+        """ List of header key-value pairs (strings) """
+        return self._header
+
+    def setheader(self,header):
+        """ List of header key-value pairs (strings) """
+        self._header = header
+
+    def getinfo(self):
+        """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+        return self._info
+
+    def setinfo(self,info):
+        """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+        self._info = info
+
+    def getformat(self):
+        """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+        return self._format
+
+    def setformat(self,format):
+        """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+        self._format = format
+
+    def getfilter(self):
+        """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+        return self._filter
+
+    def setfilter(self,filter):
+        """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+        self._filter = filter
+
+    def setversion(self, version):
+        if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")
+        self._version = version
+
+    def setregions(self, regions):
+        self._regions = regions
+
+    def setreference(self, ref):
+        """ Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile """
+        self._reference = ref
+
+    def ignoreerror(self, errorstring):
+        try:             self._ignored_errors.add(self.__dict__[errorstring])
+        except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+
+    def warnerror(self, errorstring):
+        try:             self._warn_errors.add(self.__dict__[errorstring])
+        except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+
+    def parse(self, stream):
+        """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+        last_line = self._parse_header(stream)
+        # now return a generator that does the actual work.  In this way the pre-processing is done
+        # before the first piece of data is yielded
+        return self._parse(last_line, stream)
+
+    def write(self, stream, datagenerator):
+        """ Writes a VCF file to a stream, using a data generator (or list) """
+        self.write_header(stream)
+        self.write_heading(stream)
+        for data in datagenerator: self.write_data(stream,data)
+
+    def writeheader(self, stream):
+        """ Writes a VCF header """
+        self.write_header(stream)
+        self.write_heading(stream)
+
+    def compare_calls(self, pos1, ref1, alt1, pos2, ref2, alt2):
+        """ Utility function: compares two calls for equality """
+        # a variant should always be assigned to a unique position, one base before
+        # the leftmost position of the alignment gap.  If this rule is implemented
+        # correctly, the two positions must be equal for the calls to be identical.
+        if pos1 != pos2: return False
+        # from both calls, trim rightmost bases when identical.  Do this safely, i.e.
+        # only when the reference bases are not Ns
+        while len(ref1)>0 and len(alt1)>0 and ref1[-1] == alt1[-1]:
+            ref1 = ref1[:-1]
+            alt1 = alt1[:-1]
+        while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+            ref2 = ref2[:-1]
+            alt2 = alt2[:-1]
+        # now, the alternative alleles must be identical
+        return alt1 == alt2
+
+###########################################################################################################
+###########################################################################################################
+## API functions added by Andreas
+###########################################################################################################
+
+    def connect( self, filename ):
+        '''connect to tabix file.'''
+        self.tabixfile = pysam.Tabixfile( filename )
+        self._parse_header(self.tabixfile.header)
+        
+    def fetch(self,
+              reference = None,
+              start = None, 
+              end = None, 
+              region = None ):
+        """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+
+        iter = self.tabixfile.fetch( reference, start, end, region, parser = pysam.asVCF() )
+        for x in iter:
+            yield VCFRecord( x, self )
+
+    def validate( self, record ):
+        '''validate vcf record.
+
+        returns a validated record.
+        '''
+
+        chrom, pos = record.chrom, record.pos
+
+        # check reference
+        ref = record.ref
+        if ref == ".":
+            self.error(str(record),self.MISSING_REF)
+            if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+            else:                   ref = ""
+        else:
+            for c in ref:
+                if c not in "ACGTN": self.error(str(record),self.UNKNOWN_CHAR_IN_REF)
+                if "N" in ref: ref = get_sequence(chrom,
+                                                  pos,
+                                                  pos+len(ref),
+                                                  self._reference)
+
+        # make sure reference is sane
+        if self._reference:
+            left = max(0,self.pos-100)
+            faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+            faref = faref_leftflank[pos-left:]
+            if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+            ref = faref
+            
+        # check: format fields are defined
+        for f in record.format:
+            if f not in self._format: self.error(str(record),self.FORMAT_NOT_DEFINED, f)
+            
+        # check: all filters are defined
+        for f in record.filter:
+            if f not in self._filter: self.error(str(record),self.FILTER_NOT_DEFINED, f)
+
+        # convert v3.3 alleles
+        if self._version == 33:
+            if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+            newalts = []
+            have_deletions = False
+            for a in alt:
+                if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+                elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+                elif a.startswith('D'): # allow D<seq> and D<num>
+                    have_deletions = True
+                    try:
+                        l = int(a[1:])          # throws ValueError if sequence
+                        if len(ref) < l:        # add to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[l:]             # new deletion, deleting pos...pos+l
+                    except ValueError:
+                        s = a[1:]
+                        if len(ref) < len(s):   # add Ns to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+                            if not s.endswith(addns) and addns != 'N'*len(addns):
+                                self.error(line,self.V33_UNMATCHED_DELETION,
+                                           "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[len(s):]        # new deletion, deleting from pos
+                else:
+                    self.error(line,self.V33_BAD_ALLELE)
+                newalts.append(a)
+            alt = newalts
+            # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+            if have_deletions:
+                if pos == 0:
+                    # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+                    addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+                    ref += addn
+                    alt = [allele+addn for allele in alt]
+                else:
+                    addn = get_sequence(chrom,pos-1,pos,self._reference)
+                    ref = addn + ref
+                    alt = [addn + allele for allele in alt]
+                    pos -= 1
+        else:
+            # format v4.0 -- just check for nucleotides
+            for allele in alt:
+                if not alleleRegEx.match(allele):
+                    self.error(line,self.V40_BAD_ALLELE,allele)
+                    
+
+        # check for leading nucleotide in indel calls
+        for allele in alt:
+            if len(allele) != len(ref):
+                if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+                if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+                    self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)
+
+        # trim trailing bases in alleles
+        for i in range(1,min(len(ref),min(map(len,alt)))):
+            if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+                break
+            ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+
+        # left-align alleles, if a reference is available
+        if self._leftalign and self._reference:
+            while left < pos:
+                movable = True
+                for allele in alt:
+                    if len(allele) > len(ref):
+                        longest, shortest = allele, ref
+                    else:
+                        longest, shortest = ref, allele
+                    if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+                        movable = False
+                    if longest[-1].upper() != longest[len(shortest)-1].upper():
+                        movable = False
+                if not movable:
+                    break
+                ref = ref[:-1]
+                alt = [allele[:-1] for allele in alt]
+                if min(len(allele) for allele in alt) == 0 or len(ref) == 0:
+                    ref = faref_leftflank[pos-left-1] + ref
+                    alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+                    pos -= 1
+
+
+
+
index 28cd2331b8dc0a82aed30022959aceb888d7482c..ec0439f17290876217c610355072aa4f4d074efa 100644 (file)
@@ -2,6 +2,8 @@ from csamtools import *
 from ctabix import *
 import csamtools
 import ctabix
+from cvcf import *
+import cvcf
 import Pileup
 import sys
 import os
@@ -104,9 +106,11 @@ for key, options in SAMTOOLS_DISPATCH.iteritems():
     globals()[key] = SamtoolsDispatcher(cmd, parser)
 
 # hack to export all the symbols from csamtools
-__all__ = csamtools.__all__ + \
+__all__ = \
+    csamtools.__all__ + \
     ctabix.__all__ + \
+    cvcf.__all__ +\
     [ "SamtoolsError", "SamtoolsDispatcher" ] + list(SAMTOOLS_DISPATCH) +\
-    ["Pileup",
+    ["Pileup" 
 
 from version import __version__, __samtools_version__
index bdb21aa4c56a8b190309c0167d30e03a45eb60b9..6e18ed67e74be88d34b093dda8deb09205244cda 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.13 on Fri Feb 11 09:01:21 2011 */
+/* Generated by Cython 0.13 on Tue Jun  7 17:24:36 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -292,7 +292,7 @@ static const char *__pyx_f[] = {
 
 /* Type declarations */
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":366
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":388
  *      counter[0] += 1;
  * 
  * ctypedef struct MateData:             # <<<<<<<<<<<<<<
@@ -306,7 +306,7 @@ typedef struct {
   uint32_t flag;
 } __pyx_t_9csamtools_MateData;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1332
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1478
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * ctypedef struct __iterdata:             # <<<<<<<<<<<<<<
@@ -323,7 +323,7 @@ typedef struct {
   int seq_len;
 } __pyx_t_9csamtools___iterdata;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1510
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -336,87 +336,35 @@ struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData {
   int reopen;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":80
- *      return dest
- * 
- * cdef class PileupRead             # <<<<<<<<<<<<<<
- * cdef makePileupRead( bam_pileup1_t * src ):
- *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
- */
-
-struct __pyx_obj_9csamtools_PileupRead {
-  PyObject_HEAD
-  struct __pyx_obj_9csamtools_AlignedRead *_alignment;
-  int32_t _qpos;
-  int _indel;
-  int _level;
-  uint32_t _is_del;
-  uint32_t _is_head;
-  uint32_t _is_tail;
-};
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1125
- * ##-------------------------------------------------------------------
- * ##-------------------------------------------------------------------
- * cdef class IteratorRow:             # <<<<<<<<<<<<<<
- *     '''abstract base class for iterators over mapped reads.
- * 
- */
-
-struct __pyx_obj_9csamtools_IteratorRow {
-  PyObject_HEAD
-};
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1283
- * 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3192
+ *         bam_maqindel_ret_destroy(self._r)
  * 
- * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
- *     """iterates over all mapped reads by chaining iterators over each reference
- *     """
- */
-
-struct __pyx_obj_9csamtools_IteratorRowAllRefs {
-  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_obj_9csamtools_Samfile *samfile;
-  int tid;
-  struct __pyx_obj_9csamtools_IteratorRowRegion *rowiter;
-};
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":71
- *     return dest
+ * cdef class IndelCallerBase:             # <<<<<<<<<<<<<<
+ *     '''Base class for SNP callers.
  * 
- * cdef class PileupProxy             # <<<<<<<<<<<<<<
- * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
- *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  */
 
-struct __pyx_obj_9csamtools_PileupProxy {
+struct __pyx_obj_9csamtools_IndelCallerBase {
   PyObject_HEAD
-  bam_pileup1_t *plp;
-  int tid;
-  int pos;
-  int n_pu;
+  bam_maqindel_opt_t *options;
+  struct __pyx_obj_9csamtools_IteratorColumn *iter;
+  int cap_mapQ;
+  int max_depth;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1144
- *     pass
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3330
+ *         return self._call()
  * 
- * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
- *     """*(Samfile samfile, int tid, int beg, int end, int reopen = True )*
+ * cdef class IteratorIndelCalls( IndelCallerBase ):             # <<<<<<<<<<<<<<
+ *     """*(IteratorColumn iterator)*
  * 
  */
 
-struct __pyx_obj_9csamtools_IteratorRowRegion {
-  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtab;
-  bam_iter_t iter;
-  bam1_t *b;
-  int retval;
-  struct __pyx_obj_9csamtools_Samfile *samfile;
-  samfile_t *fp;
+struct __pyx_obj_9csamtools_IteratorIndelCalls {
+  struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":222
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
  * ## Public methods
  * ######################################################################
  * cdef class Fastafile:             # <<<<<<<<<<<<<<
@@ -431,7 +379,7 @@ struct __pyx_obj_9csamtools_Fastafile {
   faidx_t *fastafile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2892
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3103
  *         return call
  * 
  * cdef class IndelCall:             # <<<<<<<<<<<<<<
@@ -448,62 +396,91 @@ struct __pyx_obj_9csamtools_IndelCall {
   bam_maqindel_ret_t *_r;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2981
- *         bam_maqindel_ret_destroy(self._r)
- * 
- * cdef class IndelCallerBase:             # <<<<<<<<<<<<<<
- *     '''Base class for SNP callers.
+/* "pysam/csamtools.pxd":388
+ *     cdef bam1_t * _delegate
  * 
+ * cdef class Samfile:             # <<<<<<<<<<<<<<
+ *     cdef char * _filename
+ *     # pointer to samfile
  */
 
-struct __pyx_obj_9csamtools_IndelCallerBase {
+struct __pyx_obj_9csamtools_Samfile {
   PyObject_HEAD
-  bam_maqindel_opt_t *options;
-  struct __pyx_obj_9csamtools_IteratorColumn *iter;
-  int cap_mapQ;
-  int max_depth;
+  struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtab;
+  char *_filename;
+  samfile_t *samfile;
+  bam_index_t *index;
+  int isbam;
+  int isremote;
+  bam1_t *b;
+  char *mode;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3119
- *         return self._call()
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3287
+ *         return call
  * 
- * cdef class IteratorIndelCalls( IndelCallerBase ):             # <<<<<<<<<<<<<<
- *     """*(IteratorColumn iterator)*
+ * cdef class IndelCaller( IndelCallerBase ):             # <<<<<<<<<<<<<<
+ *     '''*(IteratorColumn iterator_column )*
  * 
  */
 
-struct __pyx_obj_9csamtools_IteratorIndelCalls {
+struct __pyx_obj_9csamtools_IndelCaller {
   struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2662
- * 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":91
+ *      return dest
  * 
- * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
- *     '''Base class for SNP callers.
+ * cdef class PileupRead             # <<<<<<<<<<<<<<
+ * cdef makePileupRead( bam_pileup1_t * src ):
+ *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
+ */
+
+struct __pyx_obj_9csamtools_PileupRead {
+  PyObject_HEAD
+  struct __pyx_obj_9csamtools_AlignedRead *_alignment;
+  int32_t _qpos;
+  int _indel;
+  int _level;
+  uint32_t _is_del;
+  uint32_t _is_head;
+  uint32_t _is_tail;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2816
+ *     return retval, out_stderr, out_stdout
  * 
+ * cdef class SNPCall:             # <<<<<<<<<<<<<<
+ *     '''the results of a SNP call.'''
+ *     cdef int _tid
  */
 
-struct __pyx_obj_9csamtools_SNPCallerBase {
+struct __pyx_obj_9csamtools_SNPCall {
   PyObject_HEAD
-  struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtab;
-  bam_maqcns_t *c;
-  struct __pyx_obj_9csamtools_IteratorColumn *iter;
+  int _tid;
+  int _pos;
+  char _reference_base;
+  char _genotype;
+  int _consensus_quality;
+  int _snp_quality;
+  int _rms_mapping_quality;
+  int _coverage;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2735
- *         sys.stdout.flush()
+/* "pysam/csamtools.pxd":383
  * 
- * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
- *     """*(IteratorColumn iterator)*
+ * # need to declare all C fields and methods here
+ * cdef class AlignedRead:             # <<<<<<<<<<<<<<
  * 
+ *     # object that this AlignedRead represents
  */
 
-struct __pyx_obj_9csamtools_IteratorSNPCalls {
-  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
+struct __pyx_obj_9csamtools_AlignedRead {
+  PyObject_HEAD
+  bam1_t *_delegate;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1397
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
  *     return ret
  * 
  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
@@ -527,7 +504,7 @@ struct __pyx_obj_9csamtools_IteratorColumn {
   PyObject *stepper;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1567
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
  *             self.iterdata.seq = NULL
  * 
  * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -539,19 +516,53 @@ struct __pyx_obj_9csamtools_IteratorColumnRegion {
   struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2810
- *         return call
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1187
+ * ##-------------------------------------------------------------------
+ * ##-------------------------------------------------------------------
+ * cdef class IteratorRow:             # <<<<<<<<<<<<<<
+ *     '''abstract base class for iterators over mapped reads.
  * 
- * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
- *     '''*(IteratorColumn iterator_column )*
+ */
+
+struct __pyx_obj_9csamtools_IteratorRow {
+  PyObject_HEAD
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1356
+ *         if self.owns_samfile: samclose( self.fp )
  * 
+ * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """iterates over all mapped reads by chaining iterators over each reference
+ *     """
  */
 
-struct __pyx_obj_9csamtools_SNPCaller {
-  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
+struct __pyx_obj_9csamtools_IteratorRowAllRefs {
+  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_obj_9csamtools_Samfile *samfile;
+  int tid;
+  struct __pyx_obj_9csamtools_IteratorRowRegion *rowiter;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
+ *     pass
+ * 
+ * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile, int tid, int beg, int end, int reopen = True )*
+ * 
+ */
+
+struct __pyx_obj_9csamtools_IteratorRowRegion {
+  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtab;
+  bam_iter_t iter;
+  bam1_t *b;
+  int retval;
+  struct __pyx_obj_9csamtools_Samfile *samfile;
+  samfile_t *fp;
+  int owns_samfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1596
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
  *                                      self.n_plp )
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -563,60 +574,65 @@ struct __pyx_obj_9csamtools_IteratorColumnAllRefs {
   struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3076
- *         return call
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
+ *                 raise StopIteration
  * 
- * cdef class IndelCaller( IndelCallerBase ):             # <<<<<<<<<<<<<<
- *     '''*(IteratorColumn iterator_column )*
+ * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile)*
  * 
  */
 
-struct __pyx_obj_9csamtools_IndelCaller {
-  struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
+struct __pyx_obj_9csamtools_IteratorRowSelection {
+  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *__pyx_vtab;
+  bam1_t *b;
+  int current_pos;
+  samfile_t *fp;
+  PyObject *positions;
+  int owns_samfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":393
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
  * 
  * 
- * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     '''*(filename, mode='r', template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
+ * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
+ *     '''Base class for SNP callers.
  * 
  */
 
-struct __pyx_obj_9csamtools_Samfile {
+struct __pyx_obj_9csamtools_SNPCallerBase {
   PyObject_HEAD
-  struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtab;
-  char *_filename;
-  samfile_t *samfile;
-  bam_index_t *index;
-  int isbam;
-  int isremote;
-  bam1_t *b;
-  char *mode;
+  struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtab;
+  bam_maqcns_t *c;
+  struct __pyx_obj_9csamtools_IteratorColumn *iter;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2605
- *     return retval, out_stderr, out_stdout
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
+ *         return call
+ * 
+ * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     '''*(IteratorColumn iterator_column )*
  * 
- * cdef class SNPCall:             # <<<<<<<<<<<<<<
- *     '''the results of a SNP call.'''
- *     cdef int _tid
  */
 
-struct __pyx_obj_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;
+struct __pyx_obj_9csamtools_SNPCaller {
+  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
+ *         sys.stdout.flush()
+ * 
+ * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     """*(IteratorColumn iterator)*
+ * 
+ */
+
+struct __pyx_obj_9csamtools_IteratorSNPCalls {
+  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1224
- *         samclose( self.fp )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
+ *         if self.owns_samfile: samclose( self.fp )
  * 
  * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
  *     """*(Samfile samfile, int reopen = True)*
@@ -628,24 +644,44 @@ struct __pyx_obj_9csamtools_IteratorRowAll {
   struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtab;
   bam1_t *b;
   samfile_t *fp;
+  int owns_samfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":64
- * ## private factory methods
- * #####################################################################
- * cdef class AlignedRead             # <<<<<<<<<<<<<<
- * cdef makeAlignedRead(bam1_t * src):
- *     '''enter src into AlignedRead.'''
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3370
+ * 
+ * 
+ * cdef class IndexedReads:             # <<<<<<<<<<<<<<
+ *     """index a bamfile by read.
+ * 
  */
 
-struct __pyx_obj_9csamtools_AlignedRead {
+struct __pyx_obj_9csamtools_IndexedReads {
   PyObject_HEAD
-  bam1_t *_delegate;
+  struct __pyx_obj_9csamtools_Samfile *samfile;
+  samfile_t *fp;
+  PyObject *index;
+  int owns_samfile;
 };
 
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1397
- *     return ret
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":82
+ *     return dest
+ * 
+ * cdef class PileupProxy             # <<<<<<<<<<<<<<
+ * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
+ *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
+ */
+
+struct __pyx_obj_9csamtools_PileupProxy {
+  PyObject_HEAD
+  bam_pileup1_t *plp;
+  int tid;
+  int pos;
+  int n_pu;
+};
+
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
+ *     return ret
  * 
  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
  *     '''abstract base class for iterators over columns.
@@ -662,7 +698,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumn {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtabptr_9csamtools_IteratorColumn;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1567
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
  *             self.iterdata.seq = NULL
  * 
  * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -676,7 +712,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *__pyx_vtabptr_9csamtools_IteratorColumnRegion;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2662
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
  * 
  * 
  * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
@@ -690,7 +726,7 @@ struct __pyx_vtabstruct_9csamtools_SNPCallerBase {
 static struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtabptr_9csamtools_SNPCallerBase;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2810
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
  *         return call
  * 
  * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
@@ -704,7 +740,7 @@ struct __pyx_vtabstruct_9csamtools_SNPCaller {
 static struct __pyx_vtabstruct_9csamtools_SNPCaller *__pyx_vtabptr_9csamtools_SNPCaller;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1144
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
  *     pass
  * 
  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
@@ -719,7 +755,22 @@ struct __pyx_vtabstruct_9csamtools_IteratorRowRegion {
 static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtabptr_9csamtools_IteratorRowRegion;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1596
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
+ *                 raise StopIteration
+ * 
+ * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile)*
+ * 
+ */
+
+struct __pyx_vtabstruct_9csamtools_IteratorRowSelection {
+  bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowSelection *);
+  int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowSelection *);
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *__pyx_vtabptr_9csamtools_IteratorRowSelection;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
  *                                      self.n_plp )
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -733,11 +784,11 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":393
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":415
  * 
  * 
  * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     '''*(filename, mode='r', template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
+ *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
  * 
  */
 
@@ -745,11 +796,13 @@ struct __pyx_vtabstruct_9csamtools_Samfile {
   bam_header_t *(*_buildHeader)(struct __pyx_obj_9csamtools_Samfile *, PyObject *);
   bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_Samfile *);
   int (*cnext)(struct __pyx_obj_9csamtools_Samfile *);
+  int (*write)(struct __pyx_obj_9csamtools_Samfile *, struct __pyx_obj_9csamtools_AlignedRead *, int __pyx_skip_dispatch);
+  char *(*_getrname)(struct __pyx_obj_9csamtools_Samfile *, int);
 };
 static struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtabptr_9csamtools_Samfile;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":222
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
  * ## Public methods
  * ######################################################################
  * cdef class Fastafile:             # <<<<<<<<<<<<<<
@@ -763,8 +816,8 @@ struct __pyx_vtabstruct_9csamtools_Fastafile {
 static struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtabptr_9csamtools_Fastafile;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1224
- *         samclose( self.fp )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
+ *         if self.owns_samfile: samclose( self.fp )
  * 
  * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
  *     """*(Samfile samfile, int reopen = True)*
@@ -778,7 +831,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorRowAll {
 static struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtabptr_9csamtools_IteratorRowAll;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2735
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
  *         sys.stdout.flush()
  * 
  * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
@@ -931,6 +984,8 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb
 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
     const char *name, int exact); /*proto*/
 
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
 
 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
     PyObject *r;
@@ -1051,8 +1106,6 @@ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
     #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
 #endif
 
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-
 static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
     PyObject* value;
 #if PY_MAJOR_VERSION >= 3
@@ -1125,6 +1178,8 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t);
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int64_t(int64_t);
 
+static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject *);
+
 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t);
@@ -1137,6 +1192,8 @@ static PyObject* __pyx_print_kwargs = 0;
 
 static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
 
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t);
+
 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
 
 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
@@ -1171,8 +1228,6 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *
 
 static void __Pyx_WriteUnraisable(const char *name); /*proto*/
 
-static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject *);
-
 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
 
 static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
@@ -1261,14 +1316,15 @@ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
 
 static PyTypeObject *__pyx_ptype_9csamtools_file = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_AlignedRead = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_Samfile = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_PileupProxy = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_PileupRead = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_Fastafile = 0;
-static PyTypeObject *__pyx_ptype_9csamtools_Samfile = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRow = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowRegion = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAll = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAllRefs = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowSelection = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumn = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnRegion = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnAllRefs = 0;
@@ -1280,6 +1336,7 @@ static PyTypeObject *__pyx_ptype_9csamtools_IndelCall = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IndelCallerBase = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IndelCaller = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorIndelCalls = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IndexedReads = 0;
 static char *__pyx_v_9csamtools_bam_nt16_rev_table;
 static int __pyx_v_9csamtools_max_pos;
 static PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *); /*proto*/
@@ -1305,6 +1362,7 @@ static PyObject *__pyx_builtin_object;
 static PyObject *__pyx_builtin_map;
 static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_IOError;
+static PyObject *__pyx_builtin_OverflowError;
 static PyObject *__pyx_builtin_NotImplementedError;
 static PyObject *__pyx_builtin_KeyError;
 static PyObject *__pyx_builtin_StopIteration;
@@ -1330,82 +1388,82 @@ static char __pyx_k_15[] = "either supply options `template`, `header` or  both
 static char __pyx_k_16[] = "unequal names and lengths of reference sequences";
 static char __pyx_k_17[] = "-";
 static char __pyx_k_18[] = "file `%s` not found";
-static char __pyx_k_19[] = "could not open file - is it SAM/BAM format?";
-static char __pyx_k_20[] = ".bai";
-static char __pyx_k_21[] = "error while opening index `%s` ";
-static char __pyx_k_22[] = "tid out of range 0<=tid<%i";
-static char __pyx_k_23[] = "[:-]";
-static char __pyx_k_24[] = "invalid reference `%s`";
-static char __pyx_k_25[] = "invalid coordinates: start (%i) > end (%i)";
-static char __pyx_k_26[] = "seek only available in bam files";
-static char __pyx_k_28[] = "fetch called on bamfile without index";
-static char __pyx_k_29[] = "callback functionality requires a region/reference";
-static char __pyx_k_30[] = "no index available for fetch";
-static char __pyx_k_31[] = "fetch called for samfile without header";
-static char __pyx_k_32[] = "fetch for a region is not available for sam files";
-static char __pyx_k_33[] = "callback not implemented yet";
-static char __pyx_k_34[] = "read is unpaired";
-static char __pyx_k_35[] = "mate is unmapped";
-static char __pyx_k_36[] = "mate not found";
-static char __pyx_k_38[] = "counting functionality requires a region/reference";
-static char __pyx_k_39[] = "count for a region is not available for sam files";
-static char __pyx_k_40[] = "no index available for pileup";
-static char __pyx_k_41[] = "pileup of samfiles not implemented yet";
-static char __pyx_k_42[] = "@";
-static char __pyx_k_43[] = "header line without '@': '%s'";
-static char __pyx_k_44[] = "header line with invalid type '%s': '%s'";
-static char __pyx_k_45[] = ":";
-static char __pyx_k_46[] = "unknown field code '%s' in record '%s'";
-static char __pyx_k_47[] = "multiple '%s' lines are not permitted";
-static char __pyx_k_48[] = "@%s";
-static char __pyx_k_49[] = "%s:%s";
-static char __pyx_k_50[] = "invalid type for record %s: %s, expected %s";
-static char __pyx_k_51[] = "incomplete sequence information in '%s'";
-static char __pyx_k_52[] = "no index available for iteration";
-static char __pyx_k_53[] = "reference sequence for '%s' (tid=%i) not found";
-static char __pyx_k_54[] = "unknown stepper option `%s` in IteratorColumn";
-static char __pyx_k_56[] = "error during iteration";
-static char __pyx_k_57[] = "Invalid clipping in CIGAR string";
-static char __pyx_k_58[] = "quality and sequence mismatch: %i != %i";
-static char __pyx_k_59[] = "%c";
-static char __pyx_k_60[] = "create_string_buffer";
-static char __pyx_k_61[] = "<cccf";
-static char __pyx_k_62[] = "<cccb";
-static char __pyx_k_63[] = "<ccch";
-static char __pyx_k_64[] = "integer %i out of range of BAM/SAM specification";
-static char __pyx_k_65[] = "<ccci";
-static char __pyx_k_66[] = "<cccB";
-static char __pyx_k_67[] = "<cccH";
-static char __pyx_k_68[] = "<cccI";
-static char __pyx_k_69[] = "<cccc";
-static char __pyx_k_70[] = "<ccc%is";
-static char __pyx_k_71[] = "tags field too large";
-static char __pyx_k_72[] = "tag '%s' not present";
-static char __pyx_k_73[] = "Contig index";
-static char __pyx_k_74[] = "Mapped position on contig";
-static char __pyx_k_75[] = "Contig index for mate pair";
-static char __pyx_k_76[] = "Position of mate pair";
-static char __pyx_k_77[] = "Insert size";
-static char __pyx_k_78[] = "Binary flag";
-static char __pyx_k_79[] = "Count of cigar entries";
-static char __pyx_k_80[] = "Cigar entries";
-static char __pyx_k_81[] = "Mapping quality";
-static char __pyx_k_82[] = "Bam index bin number";
-static char __pyx_k_83[] = "Length of query name";
-static char __pyx_k_84[] = "Query name";
-static char __pyx_k_85[] = "Length of query sequence";
-static char __pyx_k_86[] = "Query sequence";
-static char __pyx_k_87[] = "Quality scores";
-static char __pyx_k_88[] = "Length of auxilary data";
-static char __pyx_k_89[] = "Maximum data length";
-static char __pyx_k_90[] = "Current data length";
-static char __pyx_k_91[] = "%-30s %-10s= %s";
-static char __pyx_k_92[] = "(";
-static char __pyx_k_93[] = ")";
-static char __pyx_k_94[] = "This class cannot be instantiated from Python";
-static char __pyx_k_97[] = "No such file or directory: '%s'";
-static char __pyx_k_98[] = "-o";
-static char __pyx_k_99[] = "option -o is forbidden in samtools view";
+static char __pyx_k_19[] = "could not open file (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_20[] = "file does not have valid header (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_21[] = "file header is empty (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_22[] = ".bai";
+static char __pyx_k_23[] = "error while opening index `%s` ";
+static char __pyx_k_24[] = "tid %i out of range 0<=tid<%i";
+static char __pyx_k_25[] = "[:-]";
+static char __pyx_k_26[] = "invalid reference `%s`";
+static char __pyx_k_27[] = "invalid coordinates: start (%i) > end (%i)";
+static char __pyx_k_28[] = "seek only available in bam files";
+static char __pyx_k_30[] = "fetch called on bamfile without index";
+static char __pyx_k_31[] = "callback functionality requires a region/reference";
+static char __pyx_k_32[] = "no index available for fetch";
+static char __pyx_k_33[] = "fetch called for samfile without header";
+static char __pyx_k_34[] = "fetch for a region is not available for sam files";
+static char __pyx_k_35[] = "callback not implemented yet";
+static char __pyx_k_36[] = "read %s: is unpaired";
+static char __pyx_k_37[] = "mate %s: is unmapped";
+static char __pyx_k_38[] = "mate not found";
+static char __pyx_k_40[] = "counting functionality requires a region/reference";
+static char __pyx_k_41[] = "count for a region is not available for sam files";
+static char __pyx_k_42[] = "no index available for pileup";
+static char __pyx_k_43[] = "pileup of samfiles not implemented yet";
+static char __pyx_k_44[] = "@";
+static char __pyx_k_45[] = "header line without '@': '%s'";
+static char __pyx_k_46[] = "header line with invalid type '%s': '%s'";
+static char __pyx_k_47[] = ":";
+static char __pyx_k_48[] = "unknown field code '%s' in record '%s'";
+static char __pyx_k_49[] = "multiple '%s' lines are not permitted";
+static char __pyx_k_50[] = "@%s";
+static char __pyx_k_51[] = "%s:%s";
+static char __pyx_k_52[] = "invalid type for record %s: %s, expected %s";
+static char __pyx_k_53[] = "incomplete sequence information in '%s'";
+static char __pyx_k_54[] = "no index available for iteration";
+static char __pyx_k_55[] = "can only use this iterator on bam files";
+static char __pyx_k_56[] = "reference sequence for '%s' (tid=%i) not found";
+static char __pyx_k_57[] = "unknown stepper option `%s` in IteratorColumn";
+static char __pyx_k_59[] = "error during iteration";
+static char __pyx_k_60[] = "Invalid clipping in CIGAR string";
+static char __pyx_k_61[] = "quality and sequence mismatch: %i != %i";
+static char __pyx_k_62[] = "%c";
+static char __pyx_k_63[] = "create_string_buffer";
+static char __pyx_k_64[] = "<cccf";
+static char __pyx_k_65[] = "<cccb";
+static char __pyx_k_66[] = "<ccch";
+static char __pyx_k_67[] = "integer %i out of range of BAM/SAM specification";
+static char __pyx_k_68[] = "<ccci";
+static char __pyx_k_69[] = "<cccB";
+static char __pyx_k_70[] = "<cccH";
+static char __pyx_k_71[] = "<cccI";
+static char __pyx_k_72[] = "<cccc";
+static char __pyx_k_73[] = "<ccc%is";
+static char __pyx_k_74[] = "tags field too large";
+static char __pyx_k_75[] = "tag '%s' not present";
+static char __pyx_k_76[] = "Contig index";
+static char __pyx_k_77[] = "Mapped position on contig";
+static char __pyx_k_78[] = "Contig index for mate pair";
+static char __pyx_k_79[] = "Position of mate pair";
+static char __pyx_k_80[] = "Insert size";
+static char __pyx_k_81[] = "Binary flag";
+static char __pyx_k_82[] = "Count of cigar entries";
+static char __pyx_k_83[] = "Cigar entries";
+static char __pyx_k_84[] = "Mapping quality";
+static char __pyx_k_85[] = "Bam index bin number";
+static char __pyx_k_86[] = "Length of query name";
+static char __pyx_k_87[] = "Query name";
+static char __pyx_k_88[] = "Length of query sequence";
+static char __pyx_k_89[] = "Query sequence";
+static char __pyx_k_90[] = "Quality scores";
+static char __pyx_k_91[] = "Length of auxilary data";
+static char __pyx_k_92[] = "Maximum data length";
+static char __pyx_k_93[] = "Current data length";
+static char __pyx_k_94[] = "%-30s %-10s= %s";
+static char __pyx_k_95[] = "(";
+static char __pyx_k_96[] = ")";
+static char __pyx_k_97[] = "This class cannot be instantiated from Python";
 static char __pyx_k__A[] = "A";
 static char __pyx_k__C[] = "C";
 static char __pyx_k__D[] = "D";
@@ -1423,117 +1481,127 @@ static char __pyx_k__r[] = "r";
 static char __pyx_k__s[] = "s";
 static char __pyx_k__w[] = "w";
 static char __pyx_k__x[] = "x";
-static char __pyx_k_100[] = "_rms_mapping_quality";
-static char __pyx_k_101[] = "--> read %i %s %i";
-static char __pyx_k_102[] = "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i";
-static char __pyx_k_103[] = "-------------------------------------\n";
-static char __pyx_k_104[] = "IteratorSNPCalls requires an pileup iterator with reference sequence";
-static char __pyx_k_105[] = "position %i out of bounds on reference sequence (len=%i)";
-static char __pyx_k_106[] = "no reads in region - no call";
-static char __pyx_k_107[] = "%s/%s";
-static char __pyx_k_108[] = "IndelCallerBase requires an pileup iterator with reference sequence";
-static char __pyx_k_109[] = "the query name (None if not present)";
-static char __pyx_k_110[] = "the :term:`cigar` alignment (None if not present).\n        ";
-static char __pyx_k_111[] = "read sequence bases, including :term:`soft clipped` bases (None if not present)";
-static char __pyx_k_112[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present)";
-static char __pyx_k_113[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present)\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 algorithms, which may not require alignments\n        that begin at the first residue or end at the last.  In addition,\n        extra sequencing adapters, multiplex identifiers, and low-quality bases that\n        were not considered for alignment may have been retained.";
-static char __pyx_k_114[] = "aligned query sequence quality values (None if not present)";
-static char __pyx_k_115[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
-static char __pyx_k_116[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
-static char __pyx_k_117[] = "Length of the aligned query sequence";
-static char __pyx_k_118[] = "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        ";
-static char __pyx_k_119[] = "properties flag";
-static char __pyx_k_120[] = "\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()`\n            \n        ";
-static char __pyx_k_121[] = "\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_122[] = "0-based leftmost coordinate";
-static char __pyx_k_123[] = "properties bin";
-static char __pyx_k_124[] = "length of the read (read only). Returns 0 if not given.";
-static char __pyx_k_125[] = "aligned end position of the read (read only).  Returns\n        None if not available.";
-static char __pyx_k_126[] = "aligned length of the read (read only).  Returns None if\n        not available.";
-static char __pyx_k_127[] = "mapping quality";
-static char __pyx_k_128[] = "the :term:`reference` id of the mate ";
-static char __pyx_k_129[] = "the position of the mate";
-static char __pyx_k_130[] = "the insert size";
-static char __pyx_k_131[] = "true if read is paired in sequencing";
-static char __pyx_k_132[] = "true if read is mapped in a proper pair";
-static char __pyx_k_133[] = "true if read itself is unmapped";
-static char __pyx_k_134[] = "true if the mate is unmapped";
-static char __pyx_k_135[] = "true if read is mapped to reverse strand";
-static char __pyx_k_136[] = "true is read is mapped to reverse strand";
-static char __pyx_k_137[] = "true if this is read1";
-static char __pyx_k_138[] = "true if this is read2";
-static char __pyx_k_139[] = "true if not primary alignment";
-static char __pyx_k_140[] = "true if QC failure";
-static char __pyx_k_141[] = " true if optical or PCR duplicate";
-static char __pyx_k_142[] = "the chromosome ID as is defined in the header";
-static char __pyx_k_143[] = "number of reads mapping to this column.";
-static char __pyx_k_144[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
-static char __pyx_k_145[] = "a :class:`pysam.AlignedRead` object of the aligned read";
-static char __pyx_k_146[] = "position of the read base at the pileup site, 0-based";
-static char __pyx_k_147[] = "indel length; 0 for no indel, positive for ins and negative for del";
-static char __pyx_k_148[] = "1 iff the base on the padded read is a deletion";
-static char __pyx_k_149[] = "number of :term:`filename` associated with this object.";
-static char __pyx_k_150[] = "number of :term:`reference` sequences in the file.";
-static char __pyx_k_151[] = "tuple with the names of :term:`reference` sequences.";
-static char __pyx_k_152[] = "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_153[] = "full contents of the :term:`sam file` header as a string.";
-static char __pyx_k_154[] = "header information within the :term:`sam file`. The records and fields are returned as \n        a two-level dictionary.\n        ";
-static char __pyx_k_155[] = "current sequence length.";
-static char __pyx_k_156[] = "nucleotide position of SNP.";
-static char __pyx_k_157[] = "reference base at pos. ``N`` if no reference sequence supplied.";
-static char __pyx_k_158[] = "the genotype called.";
-static char __pyx_k_159[] = "the genotype quality (Phred-scaled).";
-static char __pyx_k_160[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
-static char __pyx_k_161[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
-static char __pyx_k_162[] = "coverage or read depth - the number of reads involved in the call.";
-static char __pyx_k_163[] = "sequence of first allele.";
-static char __pyx_k_164[] = "sequence of second allele.";
-static char __pyx_k_165[] = "reads supporting first allele.";
-static char __pyx_k_166[] = "=ACMGRSVTWYHKDBN";
-static char __pyx_k_167[] = "/dev/null";
-static char __pyx_k_168[] = "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_169[] = "\n    stderr is captured. \n    ";
-static char __pyx_k_170[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
-static char __pyx_k_171[] = "Fastafile._isOpen (line 243)";
-static char __pyx_k_172[] = "Fastafile._open (line 253)";
-static char __pyx_k_173[] = "Fastafile.fetch (line 284)";
-static char __pyx_k_174[] = "Samfile._isOpen (line 451)";
-static char __pyx_k_175[] = "Samfile._hasIndex (line 455)";
-static char __pyx_k_176[] = "Samfile._open (line 459)";
-static char __pyx_k_177[] = "Samfile.getrname (line 582)";
-static char __pyx_k_178[] = "Samfile.gettid (line 590)";
-static char __pyx_k_179[] = "Samfile._parseRegion (line 599)";
-static char __pyx_k_180[] = "Samfile.seek (line 644)";
-static char __pyx_k_181[] = "Samfile.tell (line 655)";
-static char __pyx_k_182[] = "Samfile.fetch (line 666)";
-static char __pyx_k_183[] = "Samfile.mate (line 735)";
-static char __pyx_k_184[] = "Samfile.count (line 776)";
-static char __pyx_k_185[] = "Samfile.pileup (line 821)";
-static char __pyx_k_186[] = "Samfile.close (line 902)";
-static char __pyx_k_187[] = "Samfile.write (line 918)";
-static char __pyx_k_188[] = "Samfile._buildLine (line 1022)";
-static char __pyx_k_189[] = "Samfile.__next__ (line 1111)";
-static char __pyx_k_190[] = "IteratorRowRegion.__next__ (line 1213)";
-static char __pyx_k_191[] = "IteratorRowAll.__next__ (line 1266)";
-static char __pyx_k_192[] = "IteratorRowAllRefs.__next__ (line 1302)";
-static char __pyx_k_193[] = "IteratorColumn.addReference (line 1489)";
-static char __pyx_k_194[] = "IteratorColumn.hasReference (line 1497)";
-static char __pyx_k_195[] = "IteratorColumnRegion.__next__ (line 1579)";
-static char __pyx_k_196[] = "IteratorColumnRegion";
-static char __pyx_k_197[] = "IteratorColumnAllRefs.__next__ (line 1610)";
-static char __pyx_k_198[] = "IteratorColumnAllRefs";
-static char __pyx_k_199[] = "AlignedRead.__str__ (line 1759)";
-static char __pyx_k_200[] = "AlignedRead.compare (line 1772)";
-static char __pyx_k_201[] = "AlignedRead.opt (line 2331)";
-static char __pyx_k_202[] = "AlignedRead.fancy_str (line 2353)";
-static char __pyx_k_203[] = "Outs.setdevice (line 2495)";
-static char __pyx_k_204[] = "Outs.setfile (line 2500)";
-static char __pyx_k_205[] = "Outs.restore (line 2512)";
-static char __pyx_k_206[] = "_samtools_dispatch (line 2523)";
-static char __pyx_k_207[] = "IteratorSNPCalls.__next__ (line 2758)";
-static char __pyx_k_208[] = "SNPCaller.call (line 2830)";
-static char __pyx_k_209[] = "IndelCaller.call (line 3095)";
-static char __pyx_k_210[] = "IteratorIndelCalls.__next__ (line 3142)";
+static char __pyx_k_100[] = "No such file or directory: '%s'";
+static char __pyx_k_101[] = "-o";
+static char __pyx_k_102[] = "option -o is forbidden in samtools view";
+static char __pyx_k_103[] = "_rms_mapping_quality";
+static char __pyx_k_104[] = "--> read %i %s %i";
+static char __pyx_k_105[] = "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i";
+static char __pyx_k_106[] = "-------------------------------------\n";
+static char __pyx_k_107[] = "IteratorSNPCalls requires an pileup iterator with reference sequence";
+static char __pyx_k_108[] = "position %i out of bounds on reference sequence (len=%i)";
+static char __pyx_k_109[] = "no reads in region - no call";
+static char __pyx_k_110[] = "%s/%s";
+static char __pyx_k_111[] = "IndelCallerBase requires an pileup iterator with reference sequence";
+static char __pyx_k_112[] = "can only IndexReads on bam files";
+static char __pyx_k_113[] = "read %s not found";
+static char __pyx_k_114[] = "the query name (None if not present)";
+static char __pyx_k_115[] = "the :term:`cigar` alignment (None if not present).\n        ";
+static char __pyx_k_116[] = "read sequence bases, including :term:`soft clipped` bases (None if not present)";
+static char __pyx_k_117[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present)";
+static char __pyx_k_118[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present)\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 algorithms, which may not require alignments\n        that begin at the first residue or end at the last.  In addition,\n        extra sequencing adapters, multiplex identifiers, and low-quality bases that\n        were not considered for alignment may have been retained.";
+static char __pyx_k_119[] = "aligned query sequence quality values (None if not present)";
+static char __pyx_k_120[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
+static char __pyx_k_121[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
+static char __pyx_k_122[] = "Length of the aligned query sequence";
+static char __pyx_k_123[] = "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        ";
+static char __pyx_k_124[] = "properties flag";
+static char __pyx_k_125[] = "\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()`\n            \n        ";
+static char __pyx_k_126[] = "\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_127[] = "0-based leftmost coordinate";
+static char __pyx_k_128[] = "properties bin";
+static char __pyx_k_129[] = "length of the read (read only). Returns 0 if not given.";
+static char __pyx_k_130[] = "aligned end position of the read (read only).  Returns\n        None if not available.";
+static char __pyx_k_131[] = "aligned length of the read (read only).  Returns None if\n        not available.";
+static char __pyx_k_132[] = "mapping quality";
+static char __pyx_k_133[] = "the :term:`reference` id of the mate ";
+static char __pyx_k_134[] = "the position of the mate";
+static char __pyx_k_135[] = "the insert size";
+static char __pyx_k_136[] = "true if read is paired in sequencing";
+static char __pyx_k_137[] = "true if read is mapped in a proper pair";
+static char __pyx_k_138[] = "true if read itself is unmapped";
+static char __pyx_k_139[] = "true if the mate is unmapped";
+static char __pyx_k_140[] = "true if read is mapped to reverse strand";
+static char __pyx_k_141[] = "true is read is mapped to reverse strand";
+static char __pyx_k_142[] = "true if this is read1";
+static char __pyx_k_143[] = "true if this is read2";
+static char __pyx_k_144[] = "true if not primary alignment";
+static char __pyx_k_145[] = "true if QC failure";
+static char __pyx_k_146[] = "true if optical or PCR duplicate";
+static char __pyx_k_147[] = "a list of reference positions that this read aligns to.";
+static char __pyx_k_148[] = "number of :term:`filename` associated with this object.";
+static char __pyx_k_149[] = "number of :term:`reference` sequences in the file.";
+static char __pyx_k_150[] = "tuple with the names of :term:`reference` sequences.";
+static char __pyx_k_151[] = "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_152[] = "full contents of the :term:`sam file` header as a string.";
+static char __pyx_k_153[] = "header information within the :term:`sam file`. The records and fields are returned as \n        a two-level dictionary.\n        ";
+static char __pyx_k_154[] = "the chromosome ID as is defined in the header";
+static char __pyx_k_155[] = "number of reads mapping to this column.";
+static char __pyx_k_156[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
+static char __pyx_k_157[] = "a :class:`pysam.AlignedRead` object of the aligned read";
+static char __pyx_k_158[] = "position of the read base at the pileup site, 0-based";
+static char __pyx_k_159[] = "indel length; 0 for no indel, positive for ins and negative for del";
+static char __pyx_k_160[] = "1 iff the base on the padded read is a deletion";
+static char __pyx_k_161[] = "current sequence length.";
+static char __pyx_k_162[] = "nucleotide position of SNP.";
+static char __pyx_k_163[] = "reference base at pos. ``N`` if no reference sequence supplied.";
+static char __pyx_k_164[] = "the genotype called.";
+static char __pyx_k_165[] = "the genotype quality (Phred-scaled).";
+static char __pyx_k_166[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
+static char __pyx_k_167[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
+static char __pyx_k_168[] = "coverage or read depth - the number of reads involved in the call.";
+static char __pyx_k_169[] = "sequence of first allele.";
+static char __pyx_k_170[] = "sequence of second allele.";
+static char __pyx_k_171[] = "reads supporting first allele.";
+static char __pyx_k_172[] = "=ACMGRSVTWYHKDBN";
+static char __pyx_k_173[] = "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_174[] = "\n    stderr is captured. \n    ";
+static char __pyx_k_175[] = "does nothing. stderr can't be redirected on windows";
+static char __pyx_k_176[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
+static char __pyx_k_177[] = "Fastafile._isOpen (line 265)";
+static char __pyx_k_178[] = "Fastafile._open (line 275)";
+static char __pyx_k_179[] = "Fastafile.fetch (line 306)";
+static char __pyx_k_180[] = "Samfile._isOpen (line 464)";
+static char __pyx_k_181[] = "Samfile._hasIndex (line 468)";
+static char __pyx_k_182[] = "Samfile._open (line 472)";
+static char __pyx_k_183[] = "Samfile.gettid (line 612)";
+static char __pyx_k_184[] = "Samfile.getrname (line 621)";
+static char __pyx_k_185[] = "Samfile._parseRegion (line 637)";
+static char __pyx_k_186[] = "Samfile.seek (line 691)";
+static char __pyx_k_187[] = "Samfile.tell (line 702)";
+static char __pyx_k_188[] = "Samfile.fetch (line 713)";
+static char __pyx_k_189[] = "Samfile.mate (line 782)";
+static char __pyx_k_190[] = "Samfile.count (line 825)";
+static char __pyx_k_191[] = "Samfile.pileup (line 869)";
+static char __pyx_k_192[] = "Samfile.close (line 953)";
+static char __pyx_k_193[] = "Samfile.write (line 969)";
+static char __pyx_k_194[] = "Samfile._buildLine (line 1078)";
+static char __pyx_k_195[] = "Samfile.__next__ (line 1173)";
+static char __pyx_k_196[] = "IteratorRowRegion.__next__ (line 1281)";
+static char __pyx_k_197[] = "IteratorRowAll.__next__ (line 1340)";
+static char __pyx_k_198[] = "IteratorRowAllRefs.__next__ (line 1375)";
+static char __pyx_k_199[] = "IteratorRowSelection.__next__ (line 1459)";
+static char __pyx_k_200[] = "IteratorRowSelection";
+static char __pyx_k_201[] = "IteratorColumn.addReference (line 1634)";
+static char __pyx_k_202[] = "IteratorColumn.hasReference (line 1642)";
+static char __pyx_k_203[] = "IteratorColumnRegion.__next__ (line 1724)";
+static char __pyx_k_204[] = "IteratorColumnRegion";
+static char __pyx_k_205[] = "IteratorColumnAllRefs.__next__ (line 1755)";
+static char __pyx_k_206[] = "IteratorColumnAllRefs";
+static char __pyx_k_207[] = "AlignedRead.__str__ (line 1903)";
+static char __pyx_k_208[] = "AlignedRead.compare (line 1928)";
+static char __pyx_k_209[] = "AlignedRead.overlap (line 2512)";
+static char __pyx_k_210[] = "AlignedRead.opt (line 2541)";
+static char __pyx_k_211[] = "AlignedRead.fancy_str (line 2563)";
+static char __pyx_k_212[] = "Outs.setdevice (line 2705)";
+static char __pyx_k_213[] = "Outs.setfile (line 2710)";
+static char __pyx_k_214[] = "Outs.restore (line 2723)";
+static char __pyx_k_215[] = "_samtools_dispatch (line 2734)";
+static char __pyx_k_216[] = "IteratorSNPCalls.__next__ (line 2969)";
+static char __pyx_k_217[] = "SNPCaller.call (line 3041)";
+static char __pyx_k_218[] = "IndelCaller.call (line 3306)";
+static char __pyx_k_219[] = "IteratorIndelCalls.__next__ (line 3353)";
+static char __pyx_k_220[] = "IndexedReads.build (line 3406)";
 static char __pyx_k__AS[] = "AS";
 static char __pyx_k__CL[] = "CL";
 static char __pyx_k__CN[] = "CN";
@@ -1605,6 +1673,7 @@ static char __pyx_k__mask[] = "mask";
 static char __pyx_k__mate[] = "mate";
 static char __pyx_k__mode[] = "mode";
 static char __pyx_k__mpos[] = "mpos";
+static char __pyx_k__mrnm[] = "mrnm";
 static char __pyx_k__mtid[] = "mtid";
 static char __pyx_k__n_pu[] = "n_pu";
 static char __pyx_k__name[] = "name";
@@ -1614,6 +1683,7 @@ static char __pyx_k__port[] = "port";
 static char __pyx_k__qpos[] = "qpos";
 static char __pyx_k__qseq[] = "qseq";
 static char __pyx_k__qual[] = "qual";
+static char __pyx_k__rlen[] = "rlen";
 static char __pyx_k__seek[] = "seek";
 static char __pyx_k__self[] = "self";
 static char __pyx_k__tags[] = "tags";
@@ -1624,6 +1694,7 @@ static char __pyx_k___call[] = "_call";
 static char __pyx_k___open[] = "_open";
 static char __pyx_k___qpos[] = "_qpos";
 static char __pyx_k__bqual[] = "bqual";
+static char __pyx_k__build[] = "build";
 static char __pyx_k__cigar[] = "cigar";
 static char __pyx_k__close[] = "close";
 static char __pyx_k__cnext[] = "cnext";
@@ -1680,22 +1751,27 @@ static char __pyx_k__rg2lib[] = "rg2lib";
 static char __pyx_k__stderr[] = "stderr";
 static char __pyx_k__stdout[] = "stdout";
 static char __pyx_k__struct[] = "struct";
+static char __pyx_k__system[] = "system";
 static char __pyx_k__IOError[] = "IOError";
 static char __pyx_k__IntType[] = "IntType";
 static char __pyx_k__O_CREAT[] = "O_CREAT";
 static char __pyx_k__Samfile[] = "Samfile";
+static char __pyx_k__Windows[] = "Windows";
 static char __pyx_k____all__[] = "__all__";
 static char __pyx_k____del__[] = "__del__";
 static char __pyx_k____str__[] = "__str__";
 static char __pyx_k___isOpen[] = "_isOpen";
 static char __pyx_k___is_del[] = "_is_del";
 static char __pyx_k__compare[] = "compare";
+static char __pyx_k__devnull[] = "devnull";
 static char __pyx_k__is_head[] = "is_head";
 static char __pyx_k__is_tail[] = "is_tail";
+static char __pyx_k__isupper[] = "isupper";
 static char __pyx_k__l_qname[] = "l_qname";
 static char __pyx_k__mkstemp[] = "mkstemp";
 static char __pyx_k__n_cigar[] = "n_cigar";
 static char __pyx_k__options[] = "options";
+static char __pyx_k__overlap[] = "overlap";
 static char __pyx_k__pileups[] = "pileups";
 static char __pyx_k__q_indel[] = "q_indel";
 static char __pyx_k__r_indel[] = "r_indel";
@@ -1732,6 +1808,7 @@ static char __pyx_k__het_rate[] = "het_rate";
 static char __pyx_k__isremote[] = "isremote";
 static char __pyx_k__iterdata[] = "iterdata";
 static char __pyx_k__nextiter[] = "nextiter";
+static char __pyx_k__platform[] = "platform";
 static char __pyx_k__samtools[] = "samtools";
 static char __pyx_k__stderr_f[] = "stderr_f";
 static char __pyx_k__stderr_h[] = "stderr_h";
@@ -1750,11 +1827,12 @@ static char __pyx_k__alignment[] = "alignment";
 static char __pyx_k__exc_value[] = "exc_value";
 static char __pyx_k__fancy_str[] = "fancy_str";
 static char __pyx_k__fastafile[] = "fastafile";
-static char __pyx_k__is_paired[] = "is_paired";
+static char __pyx_k__itertools[] = "itertools";
 static char __pyx_k__max_depth[] = "max_depth";
 static char __pyx_k__min_baseQ[] = "min_baseQ";
 static char __pyx_k__n_targets[] = "n_targets";
 static char __pyx_k__pack_into[] = "pack_into";
+static char __pyx_k__positions[] = "positions";
 static char __pyx_k__readlines[] = "readlines";
 static char __pyx_k__reference[] = "reference";
 static char __pyx_k__setdevice[] = "setdevice";
@@ -1773,6 +1851,8 @@ static char __pyx_k__IteratorRow[] = "IteratorRow";
 static char __pyx_k__PileupProxy[] = "PileupProxy";
 static char __pyx_k__StderrStore[] = "StderrStore";
 static char __pyx_k__collections[] = "collections";
+static char __pyx_k__current_pos[] = "current_pos";
+static char __pyx_k__defaultdict[] = "defaultdict";
 static char __pyx_k__getSequence[] = "getSequence";
 static char __pyx_k__nreferences[] = "nreferences";
 static char __pyx_k__pileup_iter[] = "pileup_iter";
@@ -1780,6 +1860,7 @@ static char __pyx_k__reads_first[] = "reads_first";
 static char __pyx_k__snp_quality[] = "snp_quality";
 static char __pyx_k__stderr_save[] = "stderr_save";
 static char __pyx_k__target_name[] = "target_name";
+static char __pyx_k__IndexedReads[] = "IndexedReads";
 static char __pyx_k__PileupColumn[] = "PileupColumn";
 static char __pyx_k___buildHeader[] = "_buildHeader";
 static char __pyx_k___parseRegion[] = "_parseRegion";
@@ -1790,7 +1871,9 @@ static char __pyx_k__catch_stdout[] = "catch_stdout";
 static char __pyx_k__first_allele[] = "first_allele";
 static char __pyx_k__hasReference[] = "hasReference";
 static char __pyx_k__n_haplotypes[] = "n_haplotypes";
+static char __pyx_k__owns_samfile[] = "owns_samfile";
 static char __pyx_k__reads_second[] = "reads_second";
+static char __pyx_k__OverflowError[] = "OverflowError";
 static char __pyx_k__StopIteration[] = "StopIteration";
 static char __pyx_k__VALID_HEADERS[] = "VALID_HEADERS";
 static char __pyx_k__second_allele[] = "second_allele";
@@ -1804,13 +1887,13 @@ static char __pyx_k__iterator_column[] = "iterator_column";
 static char __pyx_k__mapping_quality[] = "mapping_quality";
 static char __pyx_k__IteratorSNPCalls[] = "IteratorSNPCalls";
 static char __pyx_k____getattribute__[] = "__getattribute__";
-static char __pyx_k__mate_is_unmapped[] = "mate_is_unmapped";
 static char __pyx_k__referencelengths[] = "referencelengths";
 static char __pyx_k__IteratorRowRegion[] = "IteratorRowRegion";
 static char __pyx_k__consensus_quality[] = "consensus_quality";
 static char __pyx_k__setupIteratorData[] = "setupIteratorData";
 static char __pyx_k__IteratorIndelCalls[] = "IteratorIndelCalls";
 static char __pyx_k__IteratorRowAllRefs[] = "IteratorRowAllRefs";
+static char __pyx_k__StderrStoreWindows[] = "StderrStoreWindows";
 static char __pyx_k__VALID_HEADER_ORDER[] = "VALID_HEADER_ORDER";
 static char __pyx_k__VALID_HEADER_TYPES[] = "VALID_HEADER_TYPES";
 static char __pyx_k___consensus_quality[] = "_consensus_quality";
@@ -1819,28 +1902,27 @@ static char __pyx_k__NotImplementedError[] = "NotImplementedError";
 static char __pyx_k__VALID_HEADER_FIELDS[] = "VALID_HEADER_FIELDS";
 static PyObject *__pyx_kp_s_1;
 static PyObject *__pyx_kp_s_10;
-static PyObject *__pyx_n_s_100;
+static PyObject *__pyx_kp_s_100;
 static PyObject *__pyx_kp_s_101;
 static PyObject *__pyx_kp_s_102;
+static PyObject *__pyx_n_s_103;
 static PyObject *__pyx_kp_s_104;
 static PyObject *__pyx_kp_s_105;
-static PyObject *__pyx_kp_s_106;
 static PyObject *__pyx_kp_s_107;
 static PyObject *__pyx_kp_s_108;
+static PyObject *__pyx_kp_s_109;
 static PyObject *__pyx_kp_s_11;
+static PyObject *__pyx_kp_s_110;
+static PyObject *__pyx_kp_s_111;
+static PyObject *__pyx_kp_s_112;
+static PyObject *__pyx_kp_s_113;
 static PyObject *__pyx_kp_s_12;
 static PyObject *__pyx_kp_s_15;
 static PyObject *__pyx_kp_s_16;
-static PyObject *__pyx_kp_s_167;
-static PyObject *__pyx_kp_s_168;
-static PyObject *__pyx_kp_s_169;
-static PyObject *__pyx_kp_s_170;
-static PyObject *__pyx_kp_u_171;
-static PyObject *__pyx_kp_u_172;
-static PyObject *__pyx_kp_u_173;
-static PyObject *__pyx_kp_u_174;
-static PyObject *__pyx_kp_u_175;
-static PyObject *__pyx_kp_u_176;
+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_u_177;
 static PyObject *__pyx_kp_u_178;
 static PyObject *__pyx_kp_u_179;
@@ -1862,31 +1944,41 @@ static PyObject *__pyx_kp_u_192;
 static PyObject *__pyx_kp_u_193;
 static PyObject *__pyx_kp_u_194;
 static PyObject *__pyx_kp_u_195;
-static PyObject *__pyx_n_s_196;
+static PyObject *__pyx_kp_u_196;
 static PyObject *__pyx_kp_u_197;
-static PyObject *__pyx_n_s_198;
+static PyObject *__pyx_kp_u_198;
 static PyObject *__pyx_kp_u_199;
 static PyObject *__pyx_kp_s_2;
 static PyObject *__pyx_kp_s_20;
-static PyObject *__pyx_kp_u_200;
+static PyObject *__pyx_n_s_200;
 static PyObject *__pyx_kp_u_201;
 static PyObject *__pyx_kp_u_202;
 static PyObject *__pyx_kp_u_203;
-static PyObject *__pyx_kp_u_204;
+static PyObject *__pyx_n_s_204;
 static PyObject *__pyx_kp_u_205;
-static PyObject *__pyx_kp_u_206;
+static PyObject *__pyx_n_s_206;
 static PyObject *__pyx_kp_u_207;
 static PyObject *__pyx_kp_u_208;
 static PyObject *__pyx_kp_u_209;
 static PyObject *__pyx_kp_s_21;
 static PyObject *__pyx_kp_u_210;
+static PyObject *__pyx_kp_u_211;
+static PyObject *__pyx_kp_u_212;
+static PyObject *__pyx_kp_u_213;
+static PyObject *__pyx_kp_u_214;
+static PyObject *__pyx_kp_u_215;
+static PyObject *__pyx_kp_u_216;
+static PyObject *__pyx_kp_u_217;
+static PyObject *__pyx_kp_u_218;
+static PyObject *__pyx_kp_u_219;
 static PyObject *__pyx_kp_s_22;
+static PyObject *__pyx_kp_u_220;
 static PyObject *__pyx_kp_s_23;
 static PyObject *__pyx_kp_s_24;
 static PyObject *__pyx_kp_s_25;
 static PyObject *__pyx_kp_s_26;
+static PyObject *__pyx_kp_s_27;
 static PyObject *__pyx_kp_s_28;
-static PyObject *__pyx_kp_s_29;
 static PyObject *__pyx_kp_s_3;
 static PyObject *__pyx_kp_s_30;
 static PyObject *__pyx_kp_s_31;
@@ -1895,8 +1987,8 @@ 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_s_37;
 static PyObject *__pyx_kp_s_38;
-static PyObject *__pyx_kp_s_39;
 static PyObject *__pyx_kp_s_4;
 static PyObject *__pyx_kp_s_40;
 static PyObject *__pyx_kp_s_41;
@@ -1914,14 +2006,14 @@ static PyObject *__pyx_kp_s_51;
 static PyObject *__pyx_kp_s_52;
 static PyObject *__pyx_kp_s_53;
 static PyObject *__pyx_kp_s_54;
+static PyObject *__pyx_kp_s_55;
 static PyObject *__pyx_kp_s_56;
-static PyObject *__pyx_kp_s_58;
+static PyObject *__pyx_kp_s_57;
 static PyObject *__pyx_kp_s_59;
 static PyObject *__pyx_kp_s_6;
-static PyObject *__pyx_n_s_60;
 static PyObject *__pyx_kp_s_61;
 static PyObject *__pyx_kp_s_62;
-static PyObject *__pyx_kp_s_63;
+static PyObject *__pyx_n_s_63;
 static PyObject *__pyx_kp_s_64;
 static PyObject *__pyx_kp_s_65;
 static PyObject *__pyx_kp_s_66;
@@ -1956,9 +2048,9 @@ static PyObject *__pyx_kp_s_91;
 static PyObject *__pyx_kp_s_92;
 static PyObject *__pyx_kp_s_93;
 static PyObject *__pyx_kp_s_94;
+static PyObject *__pyx_kp_s_95;
+static PyObject *__pyx_kp_s_96;
 static PyObject *__pyx_kp_s_97;
-static PyObject *__pyx_kp_s_98;
-static PyObject *__pyx_kp_s_99;
 static PyObject *__pyx_n_s__A;
 static PyObject *__pyx_n_s__AS;
 static PyObject *__pyx_n_s__AlignedRead;
@@ -1979,6 +2071,7 @@ static PyObject *__pyx_n_s__I;
 static PyObject *__pyx_n_s__ID;
 static PyObject *__pyx_n_s__IOError;
 static PyObject *__pyx_n_s__IndelCaller;
+static PyObject *__pyx_n_s__IndexedReads;
 static PyObject *__pyx_n_s__IntType;
 static PyObject *__pyx_n_s__IteratorColumn;
 static PyObject *__pyx_n_s__IteratorIndelCalls;
@@ -1995,6 +2088,7 @@ static PyObject *__pyx_n_s__NotImplementedError;
 static PyObject *__pyx_n_s__O_CREAT;
 static PyObject *__pyx_n_s__O_WRONLY;
 static PyObject *__pyx_n_s__Outs;
+static PyObject *__pyx_n_s__OverflowError;
 static PyObject *__pyx_n_s__PG;
 static PyObject *__pyx_n_s__PI;
 static PyObject *__pyx_n_s__PL;
@@ -2013,6 +2107,7 @@ static PyObject *__pyx_n_s__SP;
 static PyObject *__pyx_n_s__SQ;
 static PyObject *__pyx_n_s__Samfile;
 static PyObject *__pyx_n_s__StderrStore;
+static PyObject *__pyx_n_s__StderrStoreWindows;
 static PyObject *__pyx_n_s__StopIteration;
 static PyObject *__pyx_n_s__TypeError;
 static PyObject *__pyx_n_s__UR;
@@ -2022,6 +2117,7 @@ static PyObject *__pyx_n_s__VALID_HEADER_ORDER;
 static PyObject *__pyx_n_s__VALID_HEADER_TYPES;
 static PyObject *__pyx_n_s__VN;
 static PyObject *__pyx_n_s__ValueError;
+static PyObject *__pyx_n_s__Windows;
 static PyObject *__pyx_n_s__Z;
 static PyObject *__pyx_n_s____all__;
 static PyObject *__pyx_n_s____del__;
@@ -2067,6 +2163,7 @@ static PyObject *__pyx_n_s__bam;
 static PyObject *__pyx_n_s__beg;
 static PyObject *__pyx_n_s__bin;
 static PyObject *__pyx_n_s__bqual;
+static PyObject *__pyx_n_s__build;
 static PyObject *__pyx_n_s__c;
 static PyObject *__pyx_n_s__calcsize;
 static PyObject *__pyx_n_s__call;
@@ -2089,9 +2186,12 @@ static PyObject *__pyx_n_s__core;
 static PyObject *__pyx_n_s__count;
 static PyObject *__pyx_n_s__coverage;
 static PyObject *__pyx_n_s__ctypes;
+static PyObject *__pyx_n_s__current_pos;
 static PyObject *__pyx_n_s__d;
 static PyObject *__pyx_n_s__data;
 static PyObject *__pyx_n_s__data_len;
+static PyObject *__pyx_n_s__defaultdict;
+static PyObject *__pyx_n_s__devnull;
 static PyObject *__pyx_n_s__dup;
 static PyObject *__pyx_n_s__dup2;
 static PyObject *__pyx_n_s__end;
@@ -2127,14 +2227,15 @@ static PyObject *__pyx_n_s__indel2;
 static PyObject *__pyx_n_s__index;
 static PyObject *__pyx_n_s__is_del;
 static PyObject *__pyx_n_s__is_head;
-static PyObject *__pyx_n_s__is_paired;
 static PyObject *__pyx_n_s__is_tail;
 static PyObject *__pyx_n_s__isbam;
 static PyObject *__pyx_n_s__isize;
 static PyObject *__pyx_n_s__isremote;
+static PyObject *__pyx_n_s__isupper;
 static PyObject *__pyx_n_s__iter;
 static PyObject *__pyx_n_s__iterator_column;
 static PyObject *__pyx_n_s__iterdata;
+static PyObject *__pyx_n_s__itertools;
 static PyObject *__pyx_n_s__join;
 static PyObject *__pyx_n_s__l_aux;
 static PyObject *__pyx_n_s__l_qname;
@@ -2147,13 +2248,13 @@ static PyObject *__pyx_n_s__mapping_quality;
 static PyObject *__pyx_n_s__mapq;
 static PyObject *__pyx_n_s__mask;
 static PyObject *__pyx_n_s__mate;
-static PyObject *__pyx_n_s__mate_is_unmapped;
 static PyObject *__pyx_n_s__max_depth;
 static PyObject *__pyx_n_s__method;
 static PyObject *__pyx_n_s__min_baseQ;
 static PyObject *__pyx_n_s__mkstemp;
 static PyObject *__pyx_n_s__mode;
 static PyObject *__pyx_n_s__mpos;
+static PyObject *__pyx_n_s__mrnm;
 static PyObject *__pyx_n_s__mtid;
 static PyObject *__pyx_n_s__n;
 static PyObject *__pyx_n_s__n_cigar;
@@ -2171,14 +2272,18 @@ static PyObject *__pyx_n_s__open;
 static PyObject *__pyx_n_s__opt;
 static PyObject *__pyx_n_s__options;
 static PyObject *__pyx_n_s__os;
+static PyObject *__pyx_n_s__overlap;
+static PyObject *__pyx_n_s__owns_samfile;
 static PyObject *__pyx_n_s__pack_into;
 static PyObject *__pyx_n_s__path;
 static PyObject *__pyx_n_s__pileup;
 static PyObject *__pyx_n_s__pileup_iter;
 static PyObject *__pyx_n_s__pileups;
+static PyObject *__pyx_n_s__platform;
 static PyObject *__pyx_n_s__plp;
 static PyObject *__pyx_n_s__port;
 static PyObject *__pyx_n_s__pos;
+static PyObject *__pyx_n_s__positions;
 static PyObject *__pyx_n_s__q_cns;
 static PyObject *__pyx_n_s__q_indel;
 static PyObject *__pyx_n_s__q_r;
@@ -2211,6 +2316,7 @@ static PyObject *__pyx_n_s__reset;
 static PyObject *__pyx_n_s__restore;
 static PyObject *__pyx_n_s__retval;
 static PyObject *__pyx_n_s__rg2lib;
+static PyObject *__pyx_n_s__rlen;
 static PyObject *__pyx_n_s__rname;
 static PyObject *__pyx_n_s__rowiter;
 static PyObject *__pyx_n_s__s;
@@ -2239,6 +2345,7 @@ static PyObject *__pyx_n_s__streams;
 static PyObject *__pyx_n_s__strip;
 static PyObject *__pyx_n_s__struct;
 static PyObject *__pyx_n_s__sys;
+static PyObject *__pyx_n_s__system;
 static PyObject *__pyx_n_s__tags;
 static PyObject *__pyx_n_s__target_len;
 static PyObject *__pyx_n_s__target_name;
@@ -2282,13 +2389,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_27;
-static PyObject *__pyx_k_37;
-static int __pyx_k_55;
-static PyObject *__pyx_k_95;
-static PyObject *__pyx_k_96;
+static PyObject *__pyx_k_29;
+static PyObject *__pyx_k_39;
+static int __pyx_k_58;
+static PyObject *__pyx_k_98;
+static PyObject *__pyx_k_99;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":65
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":76
  * #####################################################################
  * cdef class AlignedRead
  * cdef makeAlignedRead(bam1_t * src):             # <<<<<<<<<<<<<<
@@ -2302,22 +2409,22 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("makeAlignedRead");
-  __Pyx_TraceCall("makeAlignedRead", __pyx_f[0], 65);
+  __Pyx_TraceCall("makeAlignedRead", __pyx_f[0], 76);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":67
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":78
  * cdef makeAlignedRead(bam1_t * src):
  *     '''enter src into AlignedRead.'''
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
  *     dest._delegate = bam_dup1(src)
  *     return dest
  */
-  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":68
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":79
  *     '''enter src into AlignedRead.'''
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *     dest._delegate = bam_dup1(src)             # <<<<<<<<<<<<<<
@@ -2326,7 +2433,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
  */
   __pyx_v_dest->_delegate = bam_dup1(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":69
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":80
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *     dest._delegate = bam_dup1(src)
  *     return dest             # <<<<<<<<<<<<<<
@@ -2352,7 +2459,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":72
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":83
  * 
  * cdef class PileupProxy
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):             # <<<<<<<<<<<<<<
@@ -2366,22 +2473,22 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("makePileupProxy");
-  __Pyx_TraceCall("makePileupProxy", __pyx_f[0], 72);
+  __Pyx_TraceCall("makePileupProxy", __pyx_f[0], 83);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":73
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":84
  * cdef class PileupProxy
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)             # <<<<<<<<<<<<<<
  *      dest.plp = plp
  *      dest.tid = tid
  */
-  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupProxy)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupProxy)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupProxy)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupProxy)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":74
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":85
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  *      dest.plp = plp             # <<<<<<<<<<<<<<
@@ -2390,7 +2497,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->plp = __pyx_v_plp;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":75
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":86
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  *      dest.plp = plp
  *      dest.tid = tid             # <<<<<<<<<<<<<<
@@ -2399,7 +2506,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->tid = __pyx_v_tid;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":76
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":87
  *      dest.plp = plp
  *      dest.tid = tid
  *      dest.pos = pos             # <<<<<<<<<<<<<<
@@ -2408,19 +2515,19 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->pos = __pyx_v_pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":77
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":88
  *      dest.tid = tid
  *      dest.pos = pos
  *      dest.n = n             # <<<<<<<<<<<<<<
  *      return dest
  * 
  */
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(((PyObject *)__pyx_v_dest), __pyx_n_s__n, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(((PyObject *)__pyx_v_dest), __pyx_n_s__n, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":78
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":89
  *      dest.pos = pos
  *      dest.n = n
  *      return dest             # <<<<<<<<<<<<<<
@@ -2446,7 +2553,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":81
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":92
  * 
  * cdef class PileupRead
  * cdef makePileupRead( bam_pileup1_t * src ):             # <<<<<<<<<<<<<<
@@ -2460,38 +2567,38 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("makePileupRead");
-  __Pyx_TraceCall("makePileupRead", __pyx_f[0], 81);
+  __Pyx_TraceCall("makePileupRead", __pyx_f[0], 92);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":83
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":94
  * cdef makePileupRead( bam_pileup1_t * src ):
  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)             # <<<<<<<<<<<<<<
  *     dest._alignment = makeAlignedRead( src.b )
  *     dest._qpos = src.qpos
  */
-  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":84
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":95
  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
  *     dest._alignment = makeAlignedRead( src.b )             # <<<<<<<<<<<<<<
  *     dest._qpos = src.qpos
  *     dest._indel = src.indel
  */
-  __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_src->b); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_src->b); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_1);
   __Pyx_GOTREF(__pyx_v_dest->_alignment);
   __Pyx_DECREF(((PyObject *)__pyx_v_dest->_alignment));
   __pyx_v_dest->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":85
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":96
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
  *     dest._alignment = makeAlignedRead( src.b )
  *     dest._qpos = src.qpos             # <<<<<<<<<<<<<<
@@ -2500,7 +2607,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_qpos = __pyx_v_src->qpos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":86
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":97
  *     dest._alignment = makeAlignedRead( src.b )
  *     dest._qpos = src.qpos
  *     dest._indel = src.indel             # <<<<<<<<<<<<<<
@@ -2509,7 +2616,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_indel = __pyx_v_src->indel;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":87
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":98
  *     dest._qpos = src.qpos
  *     dest._indel = src.indel
  *     dest._level = src.level             # <<<<<<<<<<<<<<
@@ -2518,7 +2625,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_level = __pyx_v_src->level;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":88
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":99
  *     dest._indel = src.indel
  *     dest._level = src.level
  *     dest._is_del = src.is_del             # <<<<<<<<<<<<<<
@@ -2527,7 +2634,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_del = __pyx_v_src->is_del;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":89
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":100
  *     dest._level = src.level
  *     dest._is_del = src.is_del
  *     dest._is_head = src.is_head             # <<<<<<<<<<<<<<
@@ -2536,7 +2643,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_head = __pyx_v_src->is_head;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":90
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":101
  *     dest._is_del = src.is_del
  *     dest._is_head = src.is_head
  *     dest._is_tail = src.is_tail             # <<<<<<<<<<<<<<
@@ -2545,7 +2652,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_tail = __pyx_v_src->is_tail;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":91
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":102
  *     dest._is_head = src.is_head
  *     dest._is_tail = src.is_tail
  *     return dest             # <<<<<<<<<<<<<<
@@ -2571,7 +2678,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":98
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":109
  * ## Generic callbacks for inserting python callbacks.
  * #####################################################################
  * cdef int fetch_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -2586,35 +2693,35 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch_callback");
-  __Pyx_TraceCall("fetch_callback", __pyx_f[0], 98);
+  __Pyx_TraceCall("fetch_callback", __pyx_f[0], 109);
   __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":103
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":114
  *     calls function in *f* with a new :class:`AlignedRead` object as parameter.
  *     '''
  *     a = makeAlignedRead( alignment )             # <<<<<<<<<<<<<<
  *     (<object>f)(a)
  * 
  */
-  __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_alignment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_alignment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_v_a);
   __pyx_v_a = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":104
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":115
  *     '''
  *     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 = 104; __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 = 115; __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), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_f), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __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;
@@ -2633,7 +2740,7 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":119
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
  *     '''
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -2642,7 +2749,8 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
  */
 
 static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_12PileupColumn___str__ = {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_9csamtools_12PileupColumn___str__, METH_O, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_12PileupColumn___str__[] = "PileupColumn.__str__(self)";
+static PyMethodDef __pyx_mdef_9csamtools_12PileupColumn___str__ = {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_9csamtools_12PileupColumn___str__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12PileupColumn___str__)};
 static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
@@ -2652,10 +2760,10 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 119);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 130);
   __pyx_self = __pyx_self;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":120
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
  *     '''
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -2664,30 +2772,30 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":121
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
  *     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_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":120
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
  *     '''
  *     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 = 120; __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 = 131; __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 = 120; __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 = 131; __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 = 120; __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 = 131; __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 = 120; __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 = 131; __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);
@@ -2698,7 +2806,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __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 = 120; __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 = 131; __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)));
@@ -2706,34 +2814,34 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __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 = 120; __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 = 131; __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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":121
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
  *     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_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __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 = 121; __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 = 132; __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 = 121; __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 = 132; __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)));
@@ -2741,19 +2849,19 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 121; __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 = 132; __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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_DECREF(__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 = 121; __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 = 132; __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;
@@ -2778,7 +2886,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":123
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":134
  *             "\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):             # <<<<<<<<<<<<<<
@@ -2797,76 +2905,76 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup_callback");
-  __Pyx_TraceCall("pileup_callback", __pyx_f[0], 123);
+  __Pyx_TraceCall("pileup_callback", __pyx_f[0], 134);
   __pyx_v_p = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":140
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":151
  *     '''
  * 
  *     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 = 140; __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 = 151; __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 = 140; __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 = 151; __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_p);
   __pyx_v_p = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":141
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":152
  * 
  *     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 = 141; __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 = 152; __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 = 141; __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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":142
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":153
  *     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 = 142; __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 = 153; __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 = 142; __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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":143
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":154
  *     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 = 143; __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 = 154; __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 = 143; __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 = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":144
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":155
  *     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 = 144; __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 = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_DECREF(((PyObject *)__pyx_v_pileups));
   __pyx_v_pileups = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":147
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":158
  * 
  *     cdef int x
  *     for x from 0 <= x < n:             # <<<<<<<<<<<<<<
@@ -2876,7 +2984,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   __pyx_t_3 = __pyx_v_n;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":148
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":159
  *     cdef int x
  *     for x from 0 <= x < n:
  *         pileups.append( makePileupRead( &(pl[x]) ) )             # <<<<<<<<<<<<<<
@@ -2884,36 +2992,36 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
  * 
  */
     if (unlikely(__pyx_v_pileups == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_2 = __pyx_f_9csamtools_makePileupRead((&(__pyx_v_pl[__pyx_v_x]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makePileupRead((&(__pyx_v_pl[__pyx_v_x]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":149
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":160
  *     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 = 149; __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 = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":151
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":162
  *     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 = 151; __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 = 162; __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), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)__pyx_v_f), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __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;
@@ -2933,7 +3041,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":153
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":164
  *     (<object>f)(p)
  * 
  * cdef int pileup_fetch_callback( bam1_t *b, void *data):             # <<<<<<<<<<<<<<
@@ -2946,9 +3054,9 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup_fetch_callback");
-  __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 153);
+  __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 164);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":159
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":170
  *     '''
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data             # <<<<<<<<<<<<<<
@@ -2957,7 +3065,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
  */
   __pyx_v_buf = ((bam_plbuf_t *)__pyx_v_data);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":160
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":171
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)             # <<<<<<<<<<<<<<
@@ -2966,7 +3074,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
  */
   bam_plbuf_push(__pyx_v_b, __pyx_v_buf);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":161
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":172
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)
  *     return 0             # <<<<<<<<<<<<<<
@@ -2983,7 +3091,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":167
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -2992,7 +3100,8 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
  */
 
 static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___init__, METH_O, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_11StderrStore___init__[] = "StderrStore.__init__(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___init__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore___init__)};
 static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
@@ -3001,10 +3110,10 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   PyObject *__pyx_t_4 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 167);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 178);
   __pyx_self = __pyx_self;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":168
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":179
  *     '''
  *     def __init__(self):
  *         return             # <<<<<<<<<<<<<<
@@ -3015,19 +3124,19 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":169
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":180
  *     def __init__(self):
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         self.stderr_save = Outs( sys.stderr.fileno() )
  *         self.stderr_save.setfd( self.stderr_h )
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __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 = 169; __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 = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
@@ -3035,78 +3144,78 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
     __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   } else {
-    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":170
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":181
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  *         self.stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __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 = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __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 = 170; __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 = 181; __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);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __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_3); __pyx_t_3 = 0;
-  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_save, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_save, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":171
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":182
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  *         self.stderr_save = Outs( sys.stderr.fileno() )
  *         self.stderr_save.setfd( self.stderr_h )             # <<<<<<<<<<<<<<
  * 
  *     def readAndRelease( self ):
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_h); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_h); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __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 = 171; __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 = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __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;
@@ -3128,7 +3237,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":173
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
@@ -3137,7 +3246,8 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
  */
 
 static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_readAndRelease, METH_O, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_11StderrStore_readAndRelease[] = "StderrStore.readAndRelease(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_readAndRelease)};
 static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_v_lines;
   PyObject *__pyx_r = NULL;
@@ -3147,11 +3257,11 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("readAndRelease");
-  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 173);
+  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 184);
   __pyx_self = __pyx_self;
   __pyx_v_lines = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":174
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":185
  * 
  *     def readAndRelease( self ):
  *         return []             # <<<<<<<<<<<<<<
@@ -3159,82 +3269,82 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
  *         lines = []
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __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 = 185; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":175
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":186
  *     def readAndRelease( self ):
  *         return []
  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
  *         lines = []
  *         if os.path.exists(self.stderr_f):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __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 = 175; __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 = 186; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":176
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":187
  *         return []
  *         self.stderr_save.restore()
  *         lines = []             # <<<<<<<<<<<<<<
  *         if os.path.exists(self.stderr_f):
  *             lines = open( self.stderr_f, "r" ).readlines()
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __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 = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(__pyx_v_lines);
   __pyx_v_lines = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":177
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":188
  *         self.stderr_save.restore()
  *         lines = []
  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
  *             lines = open( self.stderr_f, "r" ).readlines()
  *             os.remove( self.stderr_f )
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __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 = 188; __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 = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __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 = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __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_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __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 = 188; __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);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __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_3); __pyx_t_3 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __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 = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":178
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":189
  *         lines = []
  *         if os.path.exists(self.stderr_f):
  *             lines = open( self.stderr_f, "r" ).readlines()             # <<<<<<<<<<<<<<
  *             os.remove( self.stderr_f )
  *         return lines
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __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 = 178; __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 = 189; __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);
@@ -3242,39 +3352,39 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
     PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_lines);
     __pyx_v_lines = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":179
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":190
  *         if os.path.exists(self.stderr_f):
  *             lines = open( self.stderr_f, "r" ).readlines()
  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
  *         return lines
  * 
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __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 = 179; __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 = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __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;
@@ -3283,7 +3393,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":180
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":191
  *             lines = open( self.stderr_f, "r" ).readlines()
  *             os.remove( self.stderr_f )
  *         return lines             # <<<<<<<<<<<<<<
@@ -3311,7 +3421,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":182
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
@@ -3320,7 +3430,8 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__py
  */
 
 static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_release, METH_O, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_11StderrStore_release[] = "StderrStore.release(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_release)};
 static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
@@ -3329,10 +3440,10 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self,
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("release");
-  __Pyx_TraceCall("release", __pyx_f[0], 182);
+  __Pyx_TraceCall("release", __pyx_f[0], 193);
   __pyx_self = __pyx_self;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":183
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":194
  * 
  *     def release(self):
  *         return             # <<<<<<<<<<<<<<
@@ -3343,73 +3454,73 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self,
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":184
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":195
  *     def release(self):
  *         return
  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
  *         if os.path.exists(self.stderr_f):
  *             os.remove( self.stderr_f )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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 = 184; __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 = 195; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":185
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":196
  *         return
  *         self.stderr_save.restore()
  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
  *             os.remove( self.stderr_f )
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __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 = 196; __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 = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __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 = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __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_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __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 = 196; __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);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __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_3); __pyx_t_3 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __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 = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":186
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":197
  *         self.stderr_save.restore()
  *         if os.path.exists(self.stderr_f):
  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
  * 
  *     def __del__(self):
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __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 = 186; __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 = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __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;
@@ -3433,7 +3544,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":188
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
@@ -3442,26 +3553,27 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self,
  */
 
 static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___del__ = {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___del__, METH_O, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_11StderrStore___del__[] = "StderrStore.__del__(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___del__ = {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___del__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore___del__)};
 static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__del__");
-  __Pyx_TraceCall("__del__", __pyx_f[0], 188);
+  __Pyx_TraceCall("__del__", __pyx_f[0], 199);
   __pyx_self = __pyx_self;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":189
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":200
  * 
  *     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 = 189; __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 = 200; __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 = 189; __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 = 200; __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;
@@ -3480,7 +3592,95 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":238
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
+ * class StderrStoreWindows():
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass             # <<<<<<<<<<<<<<
+ *     def readAndRelease(self): return []
+ *     def release(self): pass
+ */
+
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18StderrStoreWindows___init__[] = "StderrStoreWindows.__init__(self)";
+static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows___init__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows___init__)};
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__init__");
+  __Pyx_TraceCall("__init__", __pyx_f[0], 204);
+  __pyx_self = __pyx_self;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
+ *     def release(self): pass
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18StderrStoreWindows_readAndRelease[] = "StderrStoreWindows.readAndRelease(self)";
+static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_readAndRelease)};
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("readAndRelease");
+  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 205);
+  __pyx_self = __pyx_self;
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __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("csamtools.StderrStoreWindows.readAndRelease");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []
+ *     def release(self): pass             # <<<<<<<<<<<<<<
+ * 
+ * if platform.system()=='Windows':
+ */
+
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18StderrStoreWindows_release[] = "StderrStoreWindows.release(self)";
+static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_release)};
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("release");
+  __Pyx_TraceCall("release", __pyx_f[0], 206);
+  __pyx_self = __pyx_self;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":260
  *     cdef faidx_t * fastafile
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
@@ -3498,7 +3698,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 238);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 260);
   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;
@@ -3506,7 +3706,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
   __Pyx_INCREF(__pyx_args);
   __pyx_v_args = __pyx_args;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":239
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":261
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -3515,7 +3715,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":240
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":262
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
@@ -3524,18 +3724,18 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":241
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":263
  *         self.fastafile = NULL
  *         self._filename = NULL
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *     def _isOpen( self ):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __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 = 241; __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __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;
@@ -3557,7 +3757,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":243
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":265
  *         self._open( *args, **kwargs )
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -3566,15 +3766,15 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  */
 
 static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile__isOpen[] = "return true if samfile has been opened.";
+static char __pyx_doc_9csamtools_9Fastafile__isOpen[] = "Fastafile._isOpen(self)\nreturn true if samfile has been opened.";
 static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen");
-  __Pyx_TraceCall("_isOpen", __pyx_f[0], 243);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 265);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":245
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":267
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.fastafile != NULL             # <<<<<<<<<<<<<<
@@ -3582,7 +3782,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self,
  *     def __len__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -3601,7 +3801,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":247
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":269
  *         return self.fastafile != NULL
  * 
  *     def __len__(self):             # <<<<<<<<<<<<<<
@@ -3617,9 +3817,9 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self)
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__len__");
-  __Pyx_TraceCall("__len__", __pyx_f[0], 247);
+  __Pyx_TraceCall("__len__", __pyx_f[0], 269);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":248
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":270
  * 
  *     def __len__(self):
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -3629,29 +3829,29 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self)
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":249
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":271
  *     def __len__(self):
  *         if self.fastafile == NULL:
  *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         return faidx_fetch_nseq(self.fastafile)
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __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 = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":251
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":273
  *             raise ValueError( "calling len() on closed file" )
  * 
  *         return faidx_fetch_nseq(self.fastafile)             # <<<<<<<<<<<<<<
@@ -3674,7 +3874,7 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self)
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":253
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":275
  *         return faidx_fetch_nseq(self.fastafile)
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -3683,7 +3883,7 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self)
  */
 
 static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile__open[] = "open an indexed fasta file.\n\n        This method expects an indexed fasta file.\n        ";
+static char __pyx_doc_9csamtools_9Fastafile__open[] = "Fastafile._open(self, char *filename)\nopen an indexed fasta file.\n\n        This method expects an indexed fasta file.\n        ";
 static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) {
   char *__pyx_v_filename;
   PyObject *__pyx_r = NULL;
@@ -3692,9 +3892,9 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_open");
-  __Pyx_TraceCall("_open", __pyx_f[0], 253);
+  __Pyx_TraceCall("_open", __pyx_f[0], 275);
   assert(__pyx_arg_filename); {
-    __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L3_error:;
@@ -3703,7 +3903,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":261
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":283
  * 
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()             # <<<<<<<<<<<<<<
@@ -3712,9 +3912,9 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
  */
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL);
   if (__pyx_t_1) {
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); 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__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __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 = 261; __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 = 283; __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;
@@ -3722,7 +3922,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":262
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":284
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -3736,7 +3936,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":263
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":285
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)
  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
@@ -3745,7 +3945,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":264
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":286
  *         if self._filename != NULL: free(self._filename)
  *         self._filename = strdup(filename)
  *         self.fastafile = fai_load( filename )             # <<<<<<<<<<<<<<
@@ -3754,7 +3954,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = fai_load(__pyx_v_filename);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":266
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":288
  *         self.fastafile = fai_load( filename )
  * 
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -3764,29 +3964,29 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":267
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":289
  * 
  *         if self.fastafile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __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 = 267; __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 = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); 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);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
@@ -3805,7 +4005,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":269
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":291
  *             raise IOError("could not open file `%s`" % filename )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -3814,14 +4014,15 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, Py
  */
 
 static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_9Fastafile_close[] = "Fastafile.close(self)";
 static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close");
-  __Pyx_TraceCall("close", __pyx_f[0], 269);
+  __Pyx_TraceCall("close", __pyx_f[0], 291);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":270
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":292
  * 
  *     def close( self ):
  *         if self.fastafile != NULL:             # <<<<<<<<<<<<<<
@@ -3831,7 +4032,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CY
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":271
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":293
  *     def close( self ):
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )             # <<<<<<<<<<<<<<
@@ -3840,7 +4041,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CY
  */
     fai_destroy(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":272
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":294
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )
  *             self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -3859,7 +4060,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CY
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":274
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":296
  *             self.fastafile = NULL
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -3874,23 +4075,23 @@ static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self) {
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 274);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 296);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":275
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":297
  * 
  *     def __dealloc__(self):
  *         self.close()             # <<<<<<<<<<<<<<
  *         if self._filename != NULL: free(self._filename)
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __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 = 275; __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 = 297; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":276
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":298
  *     def __dealloc__(self):
  *         self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -3914,7 +4115,7 @@ static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":280
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":302
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -3931,40 +4132,40 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 280);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 302);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":281
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":303
  *         '''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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __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 = 303; __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 = 281; __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 = 303; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __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 = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":282
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":304
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -3972,7 +4173,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -3992,7 +4193,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":284
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":306
  *             return self._filename
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -4001,7 +4202,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
  */
 
 static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile_fetch[] = "*(reference = None, start = None, end = None, region = None)*\n               \n        fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. \n        \n        The region is specified by :term:`reference`, *start* and *end*. \n        \n        fetch returns an empty string if the region is out of range or addresses an unknown *reference*.\n\n        If *reference* is given and *start* is None, the sequence from the \n        first base is returned. Similarly, if *end* is None, the sequence \n        until the last base is returned.\n        \n        Alternatively, a samtools :term:`region` string can be supplied.\n        ";
+static char __pyx_doc_9csamtools_9Fastafile_fetch[] = "Fastafile.fetch(self, reference=None, start=None, end=None, region=None)\n*(reference = None, start = None, end = None, region = None)*\n               \n        fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. \n        \n        The region is specified by :term:`reference`, *start* and *end*. \n        \n        fetch returns an empty string if the region is out of range or addresses an unknown *reference*.\n\n        If *reference* is given and *start* is None, the sequence from the \n        first base is returned. Similarly, if *end* is None, the sequence \n        until the last base is returned.\n        \n        Alternatively, a samtools :term:`region` string can be supplied.\n        ";
 static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
@@ -4019,12 +4220,12 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch");
-  __Pyx_TraceCall("fetch", __pyx_f[0], 284);
+  __Pyx_TraceCall("fetch", __pyx_f[0], 306);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":285
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -4033,7 +4234,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":286
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -4042,7 +4243,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":287
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -4051,7 +4252,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":288
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
  *                start = None,
  *                end = None,
  *                region = None):             # <<<<<<<<<<<<<<
@@ -4090,7 +4291,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -4098,7 +4299,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
     __pyx_v_region = values[3];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":285
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -4107,7 +4308,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":286
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -4116,7 +4317,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":287
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -4125,7 +4326,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":288
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
  *                start = None,
  *                end = None,
  *                region = None):             # <<<<<<<<<<<<<<
@@ -4144,7 +4345,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   }
   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 = 284; __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 = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Fastafile.fetch");
   __Pyx_RefNannyFinishContext();
@@ -4155,57 +4356,57 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   __Pyx_INCREF(__pyx_v_region);
   __pyx_v_py_seq = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":305
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":327
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __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 = 305; __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 = 327; __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 = 305; __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 = 327; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":306
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":328
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         cdef int length
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __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 = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":311
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":333
  *         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 = 311; __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 = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":312
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":334
  * 
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
@@ -4214,22 +4415,22 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_t_3 = (__pyx_v_reference == Py_None);
     if (__pyx_t_3) {
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __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 = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
       PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":313
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":335
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0             # <<<<<<<<<<<<<<
@@ -4245,7 +4446,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":314
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":336
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0
  *             if end is None: end = max_pos -1             # <<<<<<<<<<<<<<
@@ -4254,7 +4455,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_t_3 = (__pyx_v_end == Py_None);
     if (__pyx_t_3) {
-      __pyx_t_2 = PyInt_FromLong((__pyx_v_9csamtools_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong((__pyx_v_9csamtools_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_end);
       __pyx_v_end = __pyx_t_2;
@@ -4263,19 +4464,19 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
     }
     __pyx_L10:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":316
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":338
  *             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 ""
  *             # valid ranges are from 0 to 2^29-1
  */
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __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 = 338; __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 = 316; __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 = 338; __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);
@@ -4283,34 +4484,34 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
       __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_7), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__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 = 316; __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 = 338; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L11;
     }
     __pyx_L11:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":317
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":339
  * 
  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )
  *             if start == end: return ""             # <<<<<<<<<<<<<<
  *             # 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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __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 = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_3) {
       __Pyx_XDECREF(__pyx_r);
@@ -4321,92 +4522,92 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
     }
     __pyx_L12:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":319
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":341
  *             if start == end: return ""
  *             # 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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_start, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
       __Pyx_DECREF(__pyx_t_1);
-      __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __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 = 319; __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 = 341; __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_9), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __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 = 319; __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 = 341; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L13;
     }
     __pyx_L13:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":320
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":342
  *             # 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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_end, Py_LE); 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);
     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
       __Pyx_DECREF(__pyx_t_1);
-      __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, __pyx_t_2, Py_LT); 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_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 = 320; __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 = 342; __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_10), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __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 = 320; __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 = 342; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L14;
     }
     __pyx_L14:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":329
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":351
  *             #                       end-1,
  *             #                       &length)
  *             region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
  *             seq = fai_fetch( self.fastafile,
  *                              region,
  */
-    __pyx_t_1 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __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 = 351; __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 = 329; __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 = 351; __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);
@@ -4417,23 +4618,23 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
     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_11), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = ((PyObject *)__pyx_t_1);
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":331
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":353
  *             region = "%s:%i-%i" % (reference, start+1, end)
  *             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 = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":332
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":354
  *             seq = fai_fetch( self.fastafile,
  *                              region,
  *                              &length )             # <<<<<<<<<<<<<<
@@ -4445,19 +4646,19 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":335
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":357
  *         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 = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_seq = fai_fetch(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile, __pyx_t_5, (&__pyx_v_length));
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":338
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":360
  * 
  *         # copy to python
  *         if seq == NULL:             # <<<<<<<<<<<<<<
@@ -4467,7 +4668,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   __pyx_t_3 = (__pyx_v_seq == NULL);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":339
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":361
  *         # copy to python
  *         if seq == NULL:
  *             return ""             # <<<<<<<<<<<<<<
@@ -4482,7 +4683,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":341
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":363
  *             return ""
  *         else:
  *             try:             # <<<<<<<<<<<<<<
@@ -4491,21 +4692,21 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
  */
     /*try:*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":342
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":364
  *         else:
  *             try:
  *                 py_seq = PyString_FromStringAndSize(seq, length)             # <<<<<<<<<<<<<<
  *             finally:
  *                 free(seq)
  */
-      __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_seq, __pyx_v_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L17;}
+      __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_seq, __pyx_v_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L17;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_v_py_seq);
       __pyx_v_py_seq = __pyx_t_1;
       __pyx_t_1 = 0;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":344
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":366
  *                 py_seq = PyString_FromStringAndSize(seq, length)
  *             finally:
  *                 free(seq)             # <<<<<<<<<<<<<<
@@ -4542,7 +4743,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   }
   __pyx_L15:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":346
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":368
  *                 free(seq)
  * 
  *         return py_seq             # <<<<<<<<<<<<<<
@@ -4572,7 +4773,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":348
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":370
  *         return py_seq
  * 
  *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):             # <<<<<<<<<<<<<<
@@ -4584,9 +4785,9 @@ static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_F
   char *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_fetch");
-  __Pyx_TraceCall("_fetch", __pyx_f[0], 348);
+  __Pyx_TraceCall("_fetch", __pyx_f[0], 370);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":355
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":377
  *                                start,
  *                                end-1,
  *                                length )             # <<<<<<<<<<<<<<
@@ -4603,7 +4804,7 @@ static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_F
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":360
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":382
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int count_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -4616,9 +4817,9 @@ static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *_
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count_callback");
-  __Pyx_TraceCall("count_callback", __pyx_f[0], 360);
+  __Pyx_TraceCall("count_callback", __pyx_f[0], 382);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":363
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":385
  *      '''callback for bam_fetch - count number of reads.
  *      '''
  *      cdef int* counter = (<int*>f)             # <<<<<<<<<<<<<<
@@ -4627,7 +4828,7 @@ static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *_
  */
   __pyx_v_counter = ((int *)__pyx_v_f);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":364
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":386
  *      '''
  *      cdef int* counter = (<int*>f)
  *      counter[0] += 1;             # <<<<<<<<<<<<<<
@@ -4642,7 +4843,7 @@ static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":374
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":396
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int mate_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -4658,9 +4859,9 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("mate_callback");
-  __Pyx_TraceCall("mate_callback", __pyx_f[0], 374);
+  __Pyx_TraceCall("mate_callback", __pyx_f[0], 396);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":377
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":399
  *      '''callback for bam_fetch = filter mate
  *      '''
  *      cdef MateData * d = (<MateData*>f)             # <<<<<<<<<<<<<<
@@ -4669,7 +4870,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
  */
   __pyx_v_d = ((__pyx_t_9csamtools_MateData *)__pyx_v_f);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":382
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":404
  *      #        d.flag, alignment.core.flag, alignment.core.flag & d.flag)
  * 
  *      if d.mate == NULL:             # <<<<<<<<<<<<<<
@@ -4679,7 +4880,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   __pyx_t_1 = (__pyx_v_d->mate == NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":388
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":410
  *          # also, make sure that we get the other read by comparing
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \             # <<<<<<<<<<<<<<
@@ -4689,7 +4890,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
     __pyx_t_1 = ((__pyx_v_alignment->core.flag & __pyx_v_d->flag) != 0);
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":389
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":411
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:             # <<<<<<<<<<<<<<
@@ -4703,7 +4904,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
     }
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":390
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":412
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:
  *              d.mate = bam_dup1( alignment )             # <<<<<<<<<<<<<<
@@ -4724,8 +4925,8 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":442
- *     cdef char * mode
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":455
+ *     '''
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
  *         self.samfile = NULL
@@ -4742,7 +4943,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 442);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 455);
   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;
@@ -4750,7 +4951,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   __Pyx_INCREF(__pyx_args);
   __pyx_v_args = __pyx_args;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":443
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":456
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -4759,7 +4960,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":444
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":457
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
@@ -4768,7 +4969,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":445
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":458
  *         self.samfile = NULL
  *         self._filename = NULL
  *         self.isbam = False             # <<<<<<<<<<<<<<
@@ -4777,24 +4978,24 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":446
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":459
  *         self._filename = NULL
  *         self.isbam = False
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *         # allocate memory for iterator
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __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 = 446; __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 = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":449
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":462
  * 
  *         # allocate memory for iterator
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -4819,7 +5020,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":451
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":464
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -4828,15 +5029,15 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile__isOpen[] = "return true if samfile has been opened.";
+static char __pyx_doc_9csamtools_7Samfile__isOpen[] = "Samfile._isOpen(self)\nreturn true if samfile has been opened.";
 static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen");
-  __Pyx_TraceCall("_isOpen", __pyx_f[0], 451);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 464);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":453
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":466
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.samfile != NULL             # <<<<<<<<<<<<<<
@@ -4844,7 +5045,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CY
  *     def _hasIndex( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -4863,7 +5064,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CY
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":455
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":468
  *         return self.samfile != NULL
  * 
  *     def _hasIndex( self ):             # <<<<<<<<<<<<<<
@@ -4872,15 +5073,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CY
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile__hasIndex[] = "return true if samfile has an existing (and opened) index.";
+static char __pyx_doc_9csamtools_7Samfile__hasIndex[] = "Samfile._hasIndex(self)\nreturn true if samfile has an existing (and opened) index.";
 static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_hasIndex");
-  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 455);
+  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 468);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":457
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":470
  *     def _hasIndex( self ):
  *         '''return true if samfile has an existing (and opened) index.'''
  *         return self.index != NULL             # <<<<<<<<<<<<<<
@@ -4888,7 +5089,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self,
  *     def _open( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -4907,16 +5108,16 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":459
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":472
  *         return self.index != NULL
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
  *                char * filename,
- *                mode = 'r',
+ *                mode = None,
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile__open[] = "open a sam/bam file.\n\n        If _open is called on an existing bamfile, the current file will be\n        closed and a new file will be opened.\n        ";
+static char __pyx_doc_9csamtools_7Samfile__open[] = "Samfile._open(self, char *filename, mode=None, Samfile template=None, referencenames=None, referencelengths=None, text=None, header=None, port=None)\nopen a sam/bam file.\n\n        If _open is called on an existing bamfile, the current file will be\n        closed and a new file will be opened.\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   char *__pyx_v_filename;
   PyObject *__pyx_v_mode = 0;
@@ -4926,6 +5127,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
   PyObject *__pyx_v_text = 0;
   PyObject *__pyx_v_header = 0;
   PyObject *__pyx_v_port = 0;
+  PyObject *__pyx_v_msg;
   bam_header_t *__pyx_v_header_to_write;
   char *__pyx_v_ctext;
   PyObject *__pyx_v_n;
@@ -4933,41 +5135,50 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
   PyObject *__pyx_v_name;
   PyObject *__pyx_v_store;
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  int __pyx_t_4;
-  int __pyx_t_5;
-  Py_ssize_t __pyx_t_6;
-  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  int __pyx_t_7;
   int __pyx_t_8;
   Py_ssize_t __pyx_t_9;
-  size_t __pyx_t_10;
-  int32_t __pyx_t_11;
-  long __pyx_t_12;
-  uint32_t __pyx_t_13;
-  char *__pyx_t_14;
-  int __pyx_t_15;
+  Py_ssize_t __pyx_t_10;
+  size_t __pyx_t_11;
+  int32_t __pyx_t_12;
+  long __pyx_t_13;
+  uint32_t __pyx_t_14;
+  char *__pyx_t_15;
+  int __pyx_t_16;
   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,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_open");
-  __Pyx_TraceCall("_open", __pyx_f[0], 459);
+  __Pyx_TraceCall("_open", __pyx_f[0], 472);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[8] = {0,0,0,0,0,0,0,0};
-    values[1] = ((PyObject *)__pyx_n_s__r);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":462
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
+ *     def _open( self,
+ *                char * filename,
+ *                mode = None,             # <<<<<<<<<<<<<<
+ *                Samfile template = None,
+ *                referencenames = None,
+ */
+    values[1] = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
  *                char * filename,
- *                mode = 'r',
+ *                mode = None,
  *                Samfile template = None,             # <<<<<<<<<<<<<<
  *                referencenames = None,
  *                referencelengths = None,
  */
     values[2] = (PyObject *)((struct __pyx_obj_9csamtools_Samfile *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":463
- *                mode = 'r',
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
+ *                mode = None,
  *                Samfile template = None,
  *                referencenames = None,             # <<<<<<<<<<<<<<
  *                referencelengths = None,
@@ -4975,7 +5186,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":464
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
  *                Samfile template = None,
  *                referencenames = None,
  *                referencelengths = None,             # <<<<<<<<<<<<<<
@@ -4984,7 +5195,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     values[4] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":465
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
  *                referencenames = None,
  *                referencelengths = None,
  *                text = None,             # <<<<<<<<<<<<<<
@@ -4993,7 +5204,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     values[5] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":466
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
  *                referencelengths = None,
  *                text = None,
  *                header = None,             # <<<<<<<<<<<<<<
@@ -5002,7 +5213,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     values[6] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":467
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
  *                text = None,
  *                header = None,
  *                port = None,             # <<<<<<<<<<<<<<
@@ -5064,9 +5275,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_mode = values[1];
     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)values[2]);
     __pyx_v_referencenames = values[3];
@@ -5075,19 +5286,27 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
     __pyx_v_header = values[6];
     __pyx_v_port = values[7];
   } else {
-    __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":462
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
+ *     def _open( self,
+ *                char * filename,
+ *                mode = None,             # <<<<<<<<<<<<<<
+ *                Samfile template = None,
+ *                referencenames = None,
+ */
+    __pyx_v_mode = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
  *                char * filename,
- *                mode = 'r',
+ *                mode = None,
  *                Samfile template = None,             # <<<<<<<<<<<<<<
  *                referencenames = None,
  *                referencelengths = None,
  */
     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":463
- *                mode = 'r',
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
+ *                mode = None,
  *                Samfile template = None,
  *                referencenames = None,             # <<<<<<<<<<<<<<
  *                referencelengths = None,
@@ -5095,7 +5314,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_referencenames = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":464
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
  *                Samfile template = None,
  *                referencenames = None,
  *                referencelengths = None,             # <<<<<<<<<<<<<<
@@ -5104,7 +5323,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_referencelengths = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":465
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
  *                referencenames = None,
  *                referencelengths = None,
  *                text = None,             # <<<<<<<<<<<<<<
@@ -5113,7 +5332,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_text = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":466
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
  *                referencelengths = None,
  *                text = None,
  *                header = None,             # <<<<<<<<<<<<<<
@@ -5122,7 +5341,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_header = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":467
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
  *                text = None,
  *                header = None,
  *                port = None,             # <<<<<<<<<<<<<<
@@ -5138,27 +5357,246 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
       case  4: __pyx_v_referencenames = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 2));
       case  2: __pyx_v_mode = PyTuple_GET_ITEM(__pyx_args, 1);
-      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._open");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
+  __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_name = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":475
- *         '''
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":489
+ * 
+ *         # read mode autodetection
+ *         if mode is None:             # <<<<<<<<<<<<<<
+ *             try:
+ *                 self._open(filename, 'r', template=template,
+ */
+  __pyx_t_1 = (__pyx_v_mode == Py_None);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":490
+ *         # read mode autodetection
+ *         if mode is None:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 self._open(filename, 'r', template=template,
+ *                            referencenames=referencenames,
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":491
+ *         if mode is None:
+ *             try:
+ *                 self._open(filename, 'r', template=template,             # <<<<<<<<<<<<<<
+ *                            referencenames=referencenames,
+ *                            referencelengths=referencelengths,
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+        __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
+        PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
+        __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
+        __pyx_t_3 = 0;
+        __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":492
+ *             try:
+ *                 self._open(filename, 'r', template=template,
+ *                            referencenames=referencenames,             # <<<<<<<<<<<<<<
+ *                            referencelengths=referencelengths,
+ *                            text=text, header=header, port=port)
+ */
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":493
+ *                 self._open(filename, 'r', template=template,
+ *                            referencenames=referencenames,
+ *                            referencelengths=referencelengths,             # <<<<<<<<<<<<<<
+ *                            text=text, header=header, port=port)
+ *                 return
+ */
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":494
+ *                            referencenames=referencenames,
+ *                            referencelengths=referencelengths,
+ *                            text=text, header=header, port=port)             # <<<<<<<<<<<<<<
+ *                 return
+ *             except ValueError, msg:
+ */
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":495
+ *                            referencelengths=referencelengths,
+ *                            text=text, header=header, port=port)
+ *                 return             # <<<<<<<<<<<<<<
+ *             except ValueError, msg:
+ *                 pass
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+        goto __pyx_L11_try_return;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L14_try_end;
+      __pyx_L11_try_return:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L0;
+      __pyx_L7_error:;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":496
+ *                            text=text, header=header, port=port)
+ *                 return
+ *             except ValueError, msg:             # <<<<<<<<<<<<<<
+ *                 pass
+ *             self._open(filename, 'rb', template=template,
+ */
+      __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+      if (__pyx_t_6) {
+        __Pyx_AddTraceback("csamtools.Samfile._open");
+        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_v_msg);
+        __pyx_v_msg = __pyx_t_3;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        goto __pyx_L8_exception_handled;
+      }
+      __pyx_L9_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L8_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L14_try_end:;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":498
+ *             except ValueError, msg:
+ *                 pass
+ *             self._open(filename, 'rb', template=template,             # <<<<<<<<<<<<<<
+ *                        referencenames=referencenames,
+ *                        referencelengths=referencelengths,
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
+    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__rb));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":499
+ *                 pass
+ *             self._open(filename, 'rb', template=template,
+ *                        referencenames=referencenames,             # <<<<<<<<<<<<<<
+ *                        referencelengths=referencelengths,
+ *                        text=text, header=header, port=port)
+ */
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":500
+ *             self._open(filename, 'rb', template=template,
+ *                        referencenames=referencenames,
+ *                        referencelengths=referencelengths,             # <<<<<<<<<<<<<<
+ *                        text=text, header=header, port=port)
+ *             return
+ */
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":501
+ *                        referencenames=referencenames,
+ *                        referencelengths=referencelengths,
+ *                        text=text, header=header, port=port)             # <<<<<<<<<<<<<<
+ *             return
+ * 
+ */
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":502
+ *                        referencelengths=referencelengths,
+ *                        text=text, header=header, port=port)
+ *             return             # <<<<<<<<<<<<<<
+ * 
+ *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":504
+ *             return
  * 
  *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
  *         assert filename != NULL
@@ -5166,73 +5604,73 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
   #ifndef PYREX_WITHOUT_ASSERTIONS
   __Pyx_INCREF(__pyx_v_mode);
-  __pyx_t_1 = __pyx_v_mode;
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __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_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __pyx_t_3;
-    __pyx_t_3 = __pyx_t_5;
+  __pyx_t_2 = __pyx_v_mode;
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_7 = __pyx_t_1;
+  if (!__pyx_t_7) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __pyx_t_1;
+    __pyx_t_1 = __pyx_t_8;
   } else {
-    __pyx_t_3 = __pyx_t_4;
+    __pyx_t_1 = __pyx_t_7;
   }
-  if (!__pyx_t_3) {
-    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__rb), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __pyx_t_4;
-    __pyx_t_4 = __pyx_t_5;
+  if (!__pyx_t_1) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__rb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __pyx_t_7;
+    __pyx_t_7 = __pyx_t_8;
   } else {
-    __pyx_t_4 = __pyx_t_3;
+    __pyx_t_7 = __pyx_t_1;
   }
-  if (!__pyx_t_4) {
-    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__wb), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __pyx_t_3;
-    __pyx_t_3 = __pyx_t_5;
+  if (!__pyx_t_7) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __pyx_t_1;
+    __pyx_t_1 = __pyx_t_8;
   } else {
-    __pyx_t_3 = __pyx_t_4;
+    __pyx_t_1 = __pyx_t_7;
   }
-  if (!__pyx_t_3) {
-    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__wh), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __pyx_t_4;
-    __pyx_t_4 = __pyx_t_5;
+  if (!__pyx_t_1) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wh), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __pyx_t_7;
+    __pyx_t_7 = __pyx_t_8;
   } else {
-    __pyx_t_4 = __pyx_t_3;
+    __pyx_t_7 = __pyx_t_1;
   }
-  if (!__pyx_t_4) {
-    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__wbu), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __pyx_t_3;
-    __pyx_t_3 = __pyx_t_5;
+  if (!__pyx_t_7) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wbu), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_8 = __pyx_t_1;
+    __pyx_t_1 = __pyx_t_8;
   } else {
-    __pyx_t_3 = __pyx_t_4;
+    __pyx_t_1 = __pyx_t_7;
   }
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (unlikely(!__pyx_t_3)) {
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_v_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __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 = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (unlikely(!__pyx_t_1)) {
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":476
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":505
  * 
  *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
  *         assert filename != NULL             # <<<<<<<<<<<<<<
@@ -5242,30 +5680,30 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
   #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_filename != NULL))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":479
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":508
  * 
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()             # <<<<<<<<<<<<<<
  *         self.samfile = NULL
  * 
  */
-  __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
-  if (__pyx_t_3) {
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __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 = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
+  if (__pyx_t_1) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __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 = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    goto __pyx_L6;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L17;
   }
-  __pyx_L6:;
+  __pyx_L17:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":480
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":509
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -5274,7 +5712,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":483
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":512
  * 
  *         cdef bam_header_t * header_to_write
  *         header_to_write = NULL             # <<<<<<<<<<<<<<
@@ -5283,21 +5721,21 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
   __pyx_v_header_to_write = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":485
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":514
  *         header_to_write = NULL
  * 
  *         if self._filename != NULL: free(self._filename )             # <<<<<<<<<<<<<<
  *         self._filename = strdup( filename )
  * 
  */
-  __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
-  if (__pyx_t_3) {
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
+  if (__pyx_t_1) {
     free(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename);
-    goto __pyx_L7;
+    goto __pyx_L18;
   }
-  __pyx_L7:;
+  __pyx_L18:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":486
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":515
  * 
  *         if self._filename != NULL: free(self._filename )
  *         self._filename = strdup( filename )             # <<<<<<<<<<<<<<
@@ -5306,67 +5744,67 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":488
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":517
  *         self._filename = strdup( filename )
  * 
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'             # <<<<<<<<<<<<<<
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  */
-  __pyx_t_6 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyBool_FromLong((__pyx_t_6 > 1)); 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_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_t_3) {
+  __pyx_t_9 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyBool_FromLong((__pyx_t_9 > 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__b), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__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_7 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__b), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_7);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = __pyx_t_7;
-    __pyx_t_7 = 0;
+    __pyx_t_2 = __pyx_t_5;
+    __pyx_t_5 = 0;
   } else {
-    __pyx_t_1 = __pyx_t_2;
-    __pyx_t_2 = 0;
+    __pyx_t_2 = __pyx_t_3;
+    __pyx_t_3 = 0;
   }
-  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = __pyx_t_8;
+  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = __pyx_t_6;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":490
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
  *             strncmp(filename,"ftp:",4) == 0
  * 
  */
-  __pyx_t_3 = (strncmp(__pyx_v_filename, __pyx_k_13, 5) == 0);
-  if (!__pyx_t_3) {
+  __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_13, 5) == 0);
+  if (!__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":491
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":520
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  *             strncmp(filename,"ftp:",4) == 0             # <<<<<<<<<<<<<<
  * 
  *         cdef char * ctext
  */
-    __pyx_t_4 = (strncmp(__pyx_v_filename, __pyx_k_14, 4) == 0);
-    __pyx_t_5 = __pyx_t_4;
+    __pyx_t_7 = (strncmp(__pyx_v_filename, __pyx_k_14, 4) == 0);
+    __pyx_t_8 = __pyx_t_7;
   } else {
-    __pyx_t_5 = __pyx_t_3;
+    __pyx_t_8 = __pyx_t_1;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":490
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
  *             strncmp(filename,"ftp:",4) == 0
  * 
  */
-  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote = __pyx_t_5;
+  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote = __pyx_t_8;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":494
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":523
  * 
  *         cdef char * ctext
  *         ctext = NULL             # <<<<<<<<<<<<<<
@@ -5375,33 +5813,33 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
   __pyx_v_ctext = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":496
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":525
  *         ctext = NULL
  * 
  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
  *             # open file for writing
  * 
  */
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (__pyx_t_5) {
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_8) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":500
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":529
  * 
  *             # header structure (used for writing)
  *             if template:             # <<<<<<<<<<<<<<
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header
  */
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (__pyx_t_5) {
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":502
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":531
  *             if template:
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header             # <<<<<<<<<<<<<<
@@ -5409,20 +5847,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *             elif header:
  */
       __pyx_v_header_to_write = __pyx_v_template->samfile->header;
-      goto __pyx_L9;
+      goto __pyx_L20;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":504
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":533
  *                 header_to_write = template.samfile.header
  * 
  *             elif header:             # <<<<<<<<<<<<<<
  *                 header_to_write = self._buildHeader( header )
  * 
  */
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (__pyx_t_5) {
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":505
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":534
  * 
  *             elif header:
  *                 header_to_write = self._buildHeader( header )             # <<<<<<<<<<<<<<
@@ -5430,11 +5868,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *             else:
  */
       __pyx_v_header_to_write = ((struct __pyx_vtabstruct_9csamtools_Samfile *)((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->__pyx_vtab)->_buildHeader(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self), __pyx_v_header);
-      goto __pyx_L9;
+      goto __pyx_L20;
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":509
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":538
  *             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"             # <<<<<<<<<<<<<<
@@ -5442,20 +5880,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  * 
  */
       #ifndef PYREX_WITHOUT_ASSERTIONS
-      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      if (__pyx_t_5) {
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_4 = __pyx_t_3;
+      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_8) {
+        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __pyx_t_1;
       } else {
-        __pyx_t_4 = __pyx_t_5;
+        __pyx_t_7 = __pyx_t_8;
       }
-      if (unlikely(!__pyx_t_4)) {
+      if (unlikely(!__pyx_t_7)) {
         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_15));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":510
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":539
  *                 # 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"             # <<<<<<<<<<<<<<
@@ -5463,15 +5901,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *                 # allocate and fill header
  */
       #ifndef PYREX_WITHOUT_ASSERTIONS
-      __pyx_t_6 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_9 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      if (unlikely(!(__pyx_t_6 == __pyx_t_9))) {
+      __pyx_t_9 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (unlikely(!(__pyx_t_9 == __pyx_t_10))) {
         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_16));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":513
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":542
  * 
  *                 # allocate and fill header
  *                 header_to_write = bam_header_init()             # <<<<<<<<<<<<<<
@@ -5480,17 +5918,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
       __pyx_v_header_to_write = bam_header_init();
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":514
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":543
  *                 # allocate and fill header
  *                 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_9 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_v_header_to_write->n_targets = __pyx_t_9;
+      __pyx_t_10 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_header_to_write->n_targets = __pyx_t_10;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":515
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":544
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0             # <<<<<<<<<<<<<<
@@ -5501,7 +5939,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
       __Pyx_DECREF(__pyx_v_n);
       __pyx_v_n = __pyx_int_0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":516
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":545
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1             # <<<<<<<<<<<<<<
@@ -5509,165 +5947,165 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  */
       if (PyList_CheckExact(__pyx_v_referencenames) || PyTuple_CheckExact(__pyx_v_referencenames)) {
-        __pyx_t_9 = 0; __pyx_t_2 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_2);
+        __pyx_t_10 = 0; __pyx_t_3 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_3);
       } else {
-        __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
       }
       for (;;) {
-        if (likely(PyList_CheckExact(__pyx_t_2))) {
-          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
-          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++;
-        } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
-          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
-          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++;
+        if (likely(PyList_CheckExact(__pyx_t_3))) {
+          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
+          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
+        } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
         } else {
-          __pyx_t_1 = PyIter_Next(__pyx_t_2);
-          if (!__pyx_t_1) {
-            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PyIter_Next(__pyx_t_3);
+          if (!__pyx_t_2) {
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             break;
           }
-          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_GOTREF(__pyx_t_2);
         }
         __Pyx_DECREF(__pyx_v_x);
-        __pyx_v_x = __pyx_t_1;
-        __pyx_t_1 = 0;
-        __pyx_t_6 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_6 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_v_x = __pyx_t_2;
+        __pyx_t_2 = 0;
+        __pyx_t_9 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_9 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_v_n);
-        __pyx_v_n = __pyx_t_7;
-        __pyx_t_7 = 0;
+        __pyx_v_n = __pyx_t_5;
+        __pyx_t_5 = 0;
       }
-      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":517
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":546
  *                 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_10 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_v_header_to_write->target_name = ((char **)calloc(__pyx_t_10, (sizeof(char *))));
+      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_header_to_write->target_name = ((char **)calloc(__pyx_t_11, (sizeof(char *))));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":518
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":547
  *                 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_10 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_v_header_to_write->target_len = ((uint32_t *)calloc(__pyx_t_10, (sizeof(uint32_t))));
+      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_header_to_write->target_len = ((uint32_t *)calloc(__pyx_t_11, (sizeof(uint32_t))));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":519
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
  *                 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_11 = __pyx_v_header_to_write->n_targets;
-      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12++) {
-        __pyx_t_2 = PyInt_FromLong(__pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_12 = __pyx_v_header_to_write->n_targets;
+      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
+        __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_v_x);
-        __pyx_v_x = __pyx_t_2;
-        __pyx_t_2 = 0;
+        __pyx_v_x = __pyx_t_3;
+        __pyx_t_3 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":520
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":549
  *                 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_2 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        (__pyx_v_header_to_write->target_len[__pyx_t_9]) = __pyx_t_13;
+        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_14 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        (__pyx_v_header_to_write->target_len[__pyx_t_10]) = __pyx_t_14;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":521
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":550
  *                 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_2 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_v_name);
-        __pyx_v_name = __pyx_t_2;
-        __pyx_t_2 = 0;
+        __pyx_v_name = __pyx_t_3;
+        __pyx_t_3 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":522
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":551
  *                     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_9 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        (__pyx_v_header_to_write->target_name[__pyx_t_6]) = ((char *)calloc((__pyx_t_9 + 1), (sizeof(char))));
+        __pyx_t_10 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        (__pyx_v_header_to_write->target_name[__pyx_t_9]) = ((char *)calloc((__pyx_t_10 + 1), (sizeof(char))));
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":523
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":552
  *                     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) )             # <<<<<<<<<<<<<<
  * 
  *                 if text != None:
  */
-        __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_14 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_6 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        strncpy((__pyx_v_header_to_write->target_name[__pyx_t_9]), __pyx_t_14, __pyx_t_6);
-        __pyx_t_12 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_12 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        strncpy((__pyx_v_header_to_write->target_name[__pyx_t_10]), __pyx_t_15, __pyx_t_9);
+        __pyx_t_13 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_13 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":519
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
  *                 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_2 = PyInt_FromLong(__pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_v_x);
-      __pyx_v_x = __pyx_t_2;
-      __pyx_t_2 = 0;
+      __pyx_v_x = __pyx_t_3;
+      __pyx_t_3 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":525
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":554
  *                     strncpy( header_to_write.target_name[x], name, len(name) )
  * 
  *                 if text != None:             # <<<<<<<<<<<<<<
  *                     # copy without \0
  *                     ctext = text
  */
-      __pyx_t_2 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      if (__pyx_t_4) {
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      if (__pyx_t_7) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":527
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":556
  *                 if text != None:
  *                     # copy without \0
  *                     ctext = text             # <<<<<<<<<<<<<<
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
  */
-        __pyx_t_14 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_v_ctext = __pyx_t_14;
+        __pyx_t_15 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_v_ctext = __pyx_t_15;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":528
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":557
  *                     # copy without \0
  *                     ctext = text
  *                     header_to_write.l_text = strlen(ctext)             # <<<<<<<<<<<<<<
@@ -5676,7 +6114,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
         __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext);
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":529
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":558
  *                     ctext = text
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )             # <<<<<<<<<<<<<<
@@ -5685,7 +6123,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
         __pyx_v_header_to_write->text = ((char *)calloc(strlen(__pyx_v_ctext), (sizeof(char))));
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":530
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":559
  *                     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) )             # <<<<<<<<<<<<<<
@@ -5693,11 +6131,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *                 header_to_write.hash = NULL
  */
         memcpy(__pyx_v_header_to_write->text, __pyx_v_ctext, strlen(__pyx_v_ctext));
-        goto __pyx_L14;
+        goto __pyx_L25;
       }
-      __pyx_L14:;
+      __pyx_L25:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":532
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":561
  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
  * 
  *                 header_to_write.hash = NULL             # <<<<<<<<<<<<<<
@@ -5706,7 +6144,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
       __pyx_v_header_to_write->hash = NULL;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":533
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":562
  * 
  *                 header_to_write.hash = NULL
  *                 header_to_write.rg2lib = NULL             # <<<<<<<<<<<<<<
@@ -5715,66 +6153,66 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
       __pyx_v_header_to_write->rg2lib = NULL;
     }
-    __pyx_L9:;
+    __pyx_L20:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":537
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":566
  *             # 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, mode, header_to_write )
  *             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 = 537; __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 = 537; __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_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_store);
-    __pyx_v_store = __pyx_t_7;
-    __pyx_t_7 = 0;
+    __pyx_v_store = __pyx_t_5;
+    __pyx_t_5 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":538
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":567
  *             # and sam files (in the latter case, the mode needs to be wh)
  *             store = StderrStore()
  *             self.samfile = samopen( filename, mode, header_to_write )             # <<<<<<<<<<<<<<
  *             store.release()
  * 
  */
-    __pyx_t_14 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_14, __pyx_v_header_to_write);
+    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, __pyx_v_header_to_write);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":539
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":568
  *             store = StderrStore()
  *             self.samfile = samopen( filename, mode, 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 = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":542
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":571
  * 
  *             # 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_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_5 = (!__pyx_t_4);
-    if (__pyx_t_5) {
-      __pyx_t_4 = (__pyx_v_header_to_write != NULL);
-      __pyx_t_3 = __pyx_t_4;
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = (!__pyx_t_7);
+    if (__pyx_t_8) {
+      __pyx_t_7 = (__pyx_v_header_to_write != NULL);
+      __pyx_t_1 = __pyx_t_7;
     } else {
-      __pyx_t_3 = __pyx_t_5;
+      __pyx_t_1 = __pyx_t_8;
     }
-    if (__pyx_t_3) {
+    if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":543
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":572
  *             # 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 )             # <<<<<<<<<<<<<<
@@ -5782,326 +6220,332 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *         elif mode[0] == "r":
  */
       bam_header_destroy(__pyx_v_header_to_write);
-      goto __pyx_L15;
+      goto __pyx_L26;
     }
-    __pyx_L15:;
-    goto __pyx_L8;
+    __pyx_L26:;
+    goto __pyx_L19;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":545
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":574
  *                 bam_header_destroy( header_to_write )
  * 
  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  */
-  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __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 = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-  if (__pyx_t_3) {
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":547
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":576
  *         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_3 = (strncmp(__pyx_v_filename, __pyx_k_17, 1) != 0);
-    if (__pyx_t_3) {
+    __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_17, 1) != 0);
+    if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":548
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":577
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  *                     not self.isremote and \             # <<<<<<<<<<<<<<
  *                     not os.path.exists( filename ):
  *                 raise IOError( "file `%s` not found" % filename)
  */
-      __pyx_t_5 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
-      if (__pyx_t_5) {
+      __pyx_t_8 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
+      if (__pyx_t_8) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":549
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":578
  *             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 = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_2 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __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_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __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 = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __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 = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __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 = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        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_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __pyx_t_15 = (!__pyx_t_4);
-        __pyx_t_4 = __pyx_t_15;
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_16 = (!__pyx_t_7);
+        __pyx_t_7 = __pyx_t_16;
       } else {
-        __pyx_t_4 = __pyx_t_5;
+        __pyx_t_7 = __pyx_t_8;
       }
-      __pyx_t_5 = __pyx_t_4;
+      __pyx_t_8 = __pyx_t_7;
     } else {
-      __pyx_t_5 = __pyx_t_3;
+      __pyx_t_8 = __pyx_t_1;
     }
-    if (__pyx_t_5) {
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":550
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":579
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):
  *                 raise IOError( "file `%s` not found" % filename)             # <<<<<<<<<<<<<<
  * 
  *             # try to detect errors
  */
-      __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __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 = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __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 = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __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_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __Pyx_Raise(__pyx_t_1, 0, 0);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L16;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L27;
     }
-    __pyx_L16:;
+    __pyx_L27:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":553
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":582
  * 
  *             # try to detect errors
  *             self.samfile = samopen( filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             if self.samfile == NULL:
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+ *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  */
-    __pyx_t_14 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_14, NULL);
+    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, NULL);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":554
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":583
  *             # try to detect errors
  *             self.samfile = samopen( filename, mode, NULL )
  *             if self.samfile == NULL:             # <<<<<<<<<<<<<<
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+ *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  */
-    __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
-    if (__pyx_t_5) {
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":555
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":584
  *             self.samfile = samopen( filename, mode, NULL )
  *             if self.samfile == NULL:
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header == NULL:
  */
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_19));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __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_3); __pyx_t_3 = 0;
       __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L17;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L28;
     }
-    __pyx_L17:;
+    __pyx_L28:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":557
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":586
+ *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  *             if self.samfile.header == NULL:             # <<<<<<<<<<<<<<
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+ *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )
  * 
  */
-    __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL);
-    if (__pyx_t_5) {
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL);
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":558
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":587
  * 
  *             if self.samfile.header == NULL:
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )             # <<<<<<<<<<<<<<
  * 
- *             if self.samfile.header.n_targets == 0:
+ *             #disabled for autodetection to work
  */
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_19));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __Pyx_Raise(__pyx_t_1, 0, 0);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L18;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L29;
     }
-    __pyx_L18:;
+    __pyx_L29:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":560
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":590
  * 
+ *             #disabled for autodetection to work
  *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  */
-    __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
-    if (__pyx_t_5) {
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
+    if (__pyx_t_8) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":561
- * 
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":591
+ *             #disabled for autodetection to work
  *             if self.samfile.header.n_targets == 0:
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
  * 
  *         if self.samfile == NULL:
  */
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_19));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __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_3); __pyx_t_3 = 0;
       __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L19;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L30;
     }
-    __pyx_L19:;
-    goto __pyx_L8;
+    __pyx_L30:;
+    goto __pyx_L19;
   }
-  __pyx_L8:;
+  __pyx_L19:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":563
- *                 raise ValueError( "could not open file - is it SAM/BAM format?")
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":593
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  *         if self.samfile == NULL:             # <<<<<<<<<<<<<<
  *             raise IOError("could not open file `%s`" % filename )
  * 
  */
-  __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
-  if (__pyx_t_5) {
+  __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
+  if (__pyx_t_8) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":564
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":594
  * 
  *         if self.samfile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *         # check for index and open if present
  */
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_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_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __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 = 564; __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 = 594; __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_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
+    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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L20;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L31;
   }
-  __pyx_L20:;
+  __pyx_L31:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":567
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":597
  * 
  *         # check for index and open if present
  *         if mode[0] == "r" and self.isbam:             # <<<<<<<<<<<<<<
  * 
  *             if not self.isremote:
  */
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__r), Py_EQ); 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_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 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;
-  if (__pyx_t_5) {
-    __pyx_t_3 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam;
+  if (__pyx_t_8) {
+    __pyx_t_1 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam;
   } else {
-    __pyx_t_3 = __pyx_t_5;
+    __pyx_t_1 = __pyx_t_8;
   }
-  if (__pyx_t_3) {
+  if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":569
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":599
  *         if mode[0] == "r" and self.isbam:
  * 
  *             if not self.isremote:             # <<<<<<<<<<<<<<
  *                 if not os.path.exists(filename +".bai"):
  *                     self.index = NULL
  */
-    __pyx_t_3 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
-    if (__pyx_t_3) {
+    __pyx_t_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
+    if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":570
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":600
  * 
  *             if not self.isremote:
  *                 if not os.path.exists(filename +".bai"):             # <<<<<<<<<<<<<<
  *                     self.index = NULL
  *                 else:
  */
-      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-      __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __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 = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
-      __Pyx_GIVEREF(__pyx_t_7);
-      __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_kp_s_22)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __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 = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_5);
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_5 = (!__pyx_t_3);
-      if (__pyx_t_5) {
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_8 = (!__pyx_t_1);
+      if (__pyx_t_8) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":571
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":601
  *             if not self.isremote:
  *                 if not os.path.exists(filename +".bai"):
  *                     self.index = NULL             # <<<<<<<<<<<<<<
@@ -6109,11 +6553,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  *                     # returns NULL if there is no index or index could not be opened
  */
         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = NULL;
-        goto __pyx_L23;
+        goto __pyx_L34;
       }
       /*else*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":574
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":604
  *                 else:
  *                     # returns NULL if there is no index or index could not be opened
  *                     self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
@@ -6122,49 +6566,49 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":575
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":605
  *                     # 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 )
  *             else:
  */
-        __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
-        if (__pyx_t_5) {
+        __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
+        if (__pyx_t_8) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":576
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":606
  *                     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_7 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-          __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-          __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 = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_7);
-          PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_1));
-          __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
-          __pyx_t_1 = 0;
-          __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_1);
-          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-          __Pyx_Raise(__pyx_t_1, 0, 0);
-          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          goto __pyx_L24;
+          __pyx_t_5 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+          __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+          __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 = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+          __pyx_t_3 = 0;
+          __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_Raise(__pyx_t_3, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          goto __pyx_L35;
         }
-        __pyx_L24:;
+        __pyx_L35:;
       }
-      __pyx_L23:;
-      goto __pyx_L22;
+      __pyx_L34:;
+      goto __pyx_L33;
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":578
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":608
  *                         raise IOError("error while opening index `%s` " % filename )
  *             else:
  *                 self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
@@ -6173,57 +6617,59 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
  */
       ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":579
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":609
  *             else:
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:             # <<<<<<<<<<<<<<
  *                     raise IOError("error while opening index `%s` " % filename )
  * 
  */
-      __pyx_t_5 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
-      if (__pyx_t_5) {
+      __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
+      if (__pyx_t_8) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":580
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":610
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:
  *                     raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
  * 
- *     def getrname( self, tid ):
+ *     def gettid( self, reference ):
  */
-        __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        __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 = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_1);
-        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_7));
-        __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
-        __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __Pyx_Raise(__pyx_t_7, 0, 0);
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        goto __pyx_L25;
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+        __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 = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+        __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_Raise(__pyx_t_5, 0, 0);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        goto __pyx_L36;
       }
-      __pyx_L25:;
+      __pyx_L36:;
     }
-    __pyx_L22:;
-    goto __pyx_L21;
+    __pyx_L33:;
+    goto __pyx_L32;
   }
-  __pyx_L21:;
+  __pyx_L32:;
 
   __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_7);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
   __Pyx_AddTraceback("csamtools.Samfile._open");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_msg);
   __Pyx_DECREF(__pyx_v_n);
   __Pyx_DECREF(__pyx_v_x);
   __Pyx_DECREF(__pyx_v_name);
@@ -6234,120 +6680,209 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":582
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":612
  *                     raise IOError("error while opening index `%s` " % filename )
  * 
- *     def getrname( self, tid ):             # <<<<<<<<<<<<<<
+ *     def gettid( self, reference ):             # <<<<<<<<<<<<<<
  *         '''
- *         convert numerical :term:`tid` into :term:`reference` name.'''
+ *         convert :term:`reference` name into numerical :term:`tid`
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_getrname[] = "\n        convert numerical :term:`tid` into :term:`reference` name.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_gettid[] = "Samfile.gettid(self, reference)\n\n        convert :term:`reference` name into numerical :term:`tid`\n\n        returns -1 if reference is not known.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
   int __pyx_t_4;
-  Py_ssize_t __pyx_t_5;
+  char *__pyx_t_5;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("getrname");
-  __Pyx_TraceCall("getrname", __pyx_f[0], 582);
+  __Pyx_RefNannySetupContext("gettid");
+  __Pyx_TraceCall("gettid", __pyx_f[0], 612);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":585
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":618
+ *         returns -1 if reference is not known.
  *         '''
- *         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 out of range 0<=tid<%i" % self.samfile.header.n_targets )
- */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *         return pysam_reference2tid( self.samfile.header, reference )
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __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 = 618; __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 = 618; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":619
+ *         '''
+ *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+ *         return pysam_reference2tid( self.samfile.header, reference )             # <<<<<<<<<<<<<<
+ * 
+ *     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 = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(pysam_reference2tid(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header, __pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __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_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.Samfile.gettid");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":621
+ *         return pysam_reference2tid( self.samfile.header, reference )
+ * 
+ *     def getrname( self, tid ):             # <<<<<<<<<<<<<<
+ *         '''
+ *         convert numerical :term:`tid` into :term:`reference` name.'''
+ */
+
+static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_getrname[] = "Samfile.getrname(self, tid)\n\n        convert numerical :term:`tid` into :term:`reference` name.";
+static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("getrname");
+  __Pyx_TraceCall("getrname", __pyx_f[0], 621);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":624
+ *         '''
+ *         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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __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 = 585; __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 = 624; __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 = 585; __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 = 624; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __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 = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":586
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":625
  *         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 out of range 0<=tid<%i" % 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_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
     __Pyx_DECREF(__pyx_t_1);
-    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __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 = 586; __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 = 625; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":587
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":626
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:
- *             raise ValueError( "tid out of range 0<=tid<%i" % 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_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__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 = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __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 = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(__pyx_v_tid);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_tid);
+    __Pyx_GIVEREF(__pyx_v_tid);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__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 = 626; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":588
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":627
  *         if not 0 <= tid < self.samfile.header.n_targets:
- *             raise ValueError( "tid out of range 0<=tid<%i" % 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]             # <<<<<<<<<<<<<<
  * 
- *     def gettid( self, reference ):
+ *     cdef char * _getrname( self, int tid ):
  */
   __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 = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __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 = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __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);
@@ -6364,89 +6899,133 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":590
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":629
  *         return self.samfile.header.target_name[tid]
  * 
- *     def gettid( self, reference ):             # <<<<<<<<<<<<<<
+ *     cdef char * _getrname( self, int tid ):             # <<<<<<<<<<<<<<
  *         '''
- *         convert :term:`reference` name into numerical :term:`tid`
+ *         convert numerical :term:`tid` into :term:`reference` name.'''
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_gettid[] = "\n        convert :term:`reference` name into numerical :term:`tid`\n\n        returns -1 if reference is not known.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
-  PyObject *__pyx_r = NULL;
+static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, int __pyx_v_tid) {
+  char *__pyx_r;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
   int __pyx_t_4;
-  char *__pyx_t_5;
+  PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("gettid");
-  __Pyx_TraceCall("gettid", __pyx_f[0], 590);
+  __Pyx_RefNannySetupContext("_getrname");
+  __Pyx_TraceCall("_getrname", __pyx_f[0], 629);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":596
- *         returns -1 if reference is not known.
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":632
  *         '''
+ *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         return pysam_reference2tid( self.samfile.header, reference )
- * 
+ *         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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __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 = 632; __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 = 596; __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 = 632; __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 = 596; __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 = 632; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __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 = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
   }
-  __pyx_L5:;
+  __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":597
- *         '''
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":633
+ *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *         return pysam_reference2tid( self.samfile.header, reference )             # <<<<<<<<<<<<<<
+ *         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_4 = (0 <= __pyx_v_tid);
+  if (__pyx_t_4) {
+    __pyx_t_4 = (__pyx_v_tid < __pyx_v_self->samfile->header->n_targets);
+  }
+  __pyx_t_3 = (!__pyx_t_4);
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":634
+ *         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_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __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 = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_1 = 0;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(__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 = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":635
+ *         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]             # <<<<<<<<<<<<<<
  * 
  *     def _parseRegion( self,
  */
-  __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 = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = PyInt_FromLong(pysam_reference2tid(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header, __pyx_t_5)); 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_r = __pyx_t_1;
-  __pyx_t_1 = 0;
+  __pyx_r = (__pyx_v_self->samfile->header->target_name[__pyx_v_tid]);
   goto __pyx_L0;
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.Samfile.gettid");
-  __pyx_r = NULL;
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_WriteUnraisable("csamtools.Samfile._getrname");
+  __pyx_r = 0;
   __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":599
- *         return pysam_reference2tid( self.samfile.header, reference )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":637
+ *         return self.samfile.header.target_name[tid]
  * 
  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
  *                       reference = None,
@@ -6454,34 +7033,36 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyO
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile__parseRegion[] = "\n        parse region information.\n\n        raise ValueError for for invalid regions.\n\n        returns a tuple of flag, tid, start and end. Flag indicates\n        whether some coordinates were supplied.\n\n        Note that regions are 1-based, while start,end are python coordinates.\n        ";
+static char __pyx_doc_9csamtools_7Samfile__parseRegion[] = "Samfile._parseRegion(self, reference=None, start=None, end=None, region=None)\n\n        parse region information.\n\n        raise ValueError for for invalid regions.\n\n        returns a tuple of flag, tid, start and end. Flag indicates\n        whether some coordinates were supplied.\n\n        Note that regions are 1-based, while start,end are python coordinates.\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
   PyObject *__pyx_v_region = 0;
   int __pyx_v_rtid;
-  int __pyx_v_rstart;
-  int __pyx_v_rend;
+  PY_LONG_LONG __pyx_v_rstart;
+  PY_LONG_LONG __pyx_v_rend;
   PyObject *__pyx_v_parts;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   int __pyx_t_2;
-  int __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
+  PY_LONG_LONG __pyx_t_3;
+  int __pyx_t_4;
   PyObject *__pyx_t_5 = NULL;
-  Py_ssize_t __pyx_t_6;
-  int __pyx_t_7;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
   PyObject *__pyx_t_8 = NULL;
+  Py_ssize_t __pyx_t_9;
+  int __pyx_t_10;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_parseRegion");
-  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 599);
+  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 637);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":600
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -6490,7 +7071,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":601
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -6499,7 +7080,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":602
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -6508,7 +7089,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":603
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -6547,7 +7128,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -6555,7 +7136,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
     __pyx_v_region = values[3];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":600
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -6564,7 +7145,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":601
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -6573,7 +7154,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":602
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -6582,7 +7163,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":603
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -6601,7 +7182,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
   }
   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 = 599; __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 = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
   __Pyx_RefNannyFinishContext();
@@ -6610,8 +7191,8 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
   __Pyx_INCREF(__pyx_v_reference);
   __pyx_v_parts = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":622
- *         cdef int rend
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":660
+ *         cdef long long rend
  * 
  *         rtid = -1             # <<<<<<<<<<<<<<
  *         rstart = 0
@@ -6619,183 +7200,355 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
   __pyx_v_rtid = -1;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":623
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":661
  * 
  *         rtid = -1
  *         rstart = 0             # <<<<<<<<<<<<<<
  *         rend = max_pos
- *         if start != None: rstart = start
+ *         if start != None:
  */
   __pyx_v_rstart = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":624
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":662
  *         rtid = -1
  *         rstart = 0
  *         rend = max_pos             # <<<<<<<<<<<<<<
- *         if start != None: rstart = start
- *         if end != None: rend = end
+ *         if start != None:
+ *             try:
  */
   __pyx_v_rend = __pyx_v_9csamtools_max_pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":625
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":663
  *         rstart = 0
  *         rend = max_pos
- *         if start != None: rstart = start             # <<<<<<<<<<<<<<
- *         if end != None: rend = end
- * 
+ *         if start != None:             # <<<<<<<<<<<<<<
+ *             try:
+ *                 rstart = start
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __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 = 625; __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 = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
-    __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_start); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_v_rstart = __pyx_t_3;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":664
+ *         rend = max_pos
+ *         if start != None:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 rstart = start
+ *             except OverflowError:
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":665
+ *         if start != None:
+ *             try:
+ *                 rstart = start             # <<<<<<<<<<<<<<
+ *             except OverflowError:
+ *                 raise ValueError( 'start out of range (%i)' % start )
+ */
+        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_start); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_v_rstart = __pyx_t_3;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L14_try_end;
+      __pyx_L7_error:;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":666
+ *             try:
+ *                 rstart = start
+ *             except OverflowError:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( 'start out of range (%i)' % start )
+ * 
+ */
+      __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
+      if (__pyx_t_4) {
+        __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
+        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GOTREF(__pyx_t_6);
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":667
+ *                 rstart = start
+ *             except OverflowError:
+ *                 raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
+ * 
+ *         if end != None:
+ */
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_7, 0, 0);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        goto __pyx_L8_exception_handled;
+      }
+      __pyx_L9_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L8_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L14_try_end:;
+    }
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":626
- *         rend = max_pos
- *         if start != None: rstart = start
- *         if end != None: rend = end             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":669
+ *                 raise ValueError( 'start out of range (%i)' % start )
  * 
- *         if region:
+ *         if end != None:             # <<<<<<<<<<<<<<
+ *             try:
+ *                 rend = end
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __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 = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_6 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
   if (__pyx_t_2) {
-    __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_end); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_v_rend = __pyx_t_3;
-    goto __pyx_L7;
-  }
-  __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":628
- *         if end != None: rend = end
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":670
+ * 
+ *         if end != None:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 rend = end
+ *             except OverflowError:
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":671
+ *         if end != None:
+ *             try:
+ *                 rend = end             # <<<<<<<<<<<<<<
+ *             except OverflowError:
+ *                 raise ValueError( 'end out of range (%i)' % end )
+ */
+        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_end); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
+        __pyx_v_rend = __pyx_t_3;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L25_try_end;
+      __pyx_L18_error:;
+      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":672
+ *             try:
+ *                 rend = end
+ *             except OverflowError:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( 'end out of range (%i)' % end )
+ * 
+ */
+      __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
+      if (__pyx_t_4) {
+        __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
+        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_GOTREF(__pyx_t_1);
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":673
+ *                 rend = end
+ *             except OverflowError:
+ *                 raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
+ * 
+ *         if region:
+ */
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_Raise(__pyx_t_7, 0, 0);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        goto __pyx_L19_exception_handled;
+      }
+      __pyx_L20_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L19_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L25_try_end:;
+    }
+    goto __pyx_L17;
+  }
+  __pyx_L17:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":675
+ *                 raise ValueError( 'end out of range (%i)' % end )
  * 
  *         if region:             # <<<<<<<<<<<<<<
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]
  */
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __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 = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":629
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":676
  * 
  *         if 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 = 629; __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 = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
     __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 = 629; __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 = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_23));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_25));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
     __Pyx_INCREF(__pyx_v_region);
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_region);
     __Pyx_GIVEREF(__pyx_v_region);
-    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_6 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_parts);
-    __pyx_v_parts = __pyx_t_5;
-    __pyx_t_5 = 0;
+    __pyx_v_parts = __pyx_t_6;
+    __pyx_t_6 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":630
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":677
  *         if 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_5 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_v_reference);
-    __pyx_v_reference = __pyx_t_5;
-    __pyx_t_5 = 0;
+    __pyx_v_reference = __pyx_t_6;
+    __pyx_t_6 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":631
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":678
  *             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_6 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_2 = (__pyx_t_6 >= 2);
+    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = (__pyx_t_9 >= 2);
     if (__pyx_t_2) {
-      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
-      __Pyx_GIVEREF(__pyx_t_5);
-      __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_6);
+      __pyx_t_6 = 0;
+      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Subtract(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rstart = __pyx_t_3;
-      goto __pyx_L9;
+      goto __pyx_L29;
     }
-    __pyx_L9:;
+    __pyx_L29:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":632
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":679
  *             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_6 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_2 = (__pyx_t_6 >= 3);
+    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = (__pyx_t_9 >= 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 = 632; __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 = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __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);
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rend = __pyx_t_3;
-      goto __pyx_L10;
+      goto __pyx_L30;
     }
-    __pyx_L10:;
-    goto __pyx_L8;
+    __pyx_L30:;
+    goto __pyx_L28;
   }
-  __pyx_L8:;
+  __pyx_L28:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":634
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":681
  *             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 = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_7 = (!__pyx_t_2);
-  if (__pyx_t_7) {
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = (!__pyx_t_2);
+  if (__pyx_t_10) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __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 = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_int_0);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
@@ -6812,131 +7565,131 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
     __pyx_r = __pyx_t_1;
     __pyx_t_1 = 0;
     goto __pyx_L0;
-    goto __pyx_L11;
+    goto __pyx_L31;
   }
-  __pyx_L11:;
+  __pyx_L31:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":636
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":683
  *         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(__pyx_v_self, __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_v_reference);
-  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
-  __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_v_rtid = __pyx_t_3;
+  __pyx_v_rtid = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":637
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":684
  * 
  *         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) )
  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
  */
-  __pyx_t_7 = (__pyx_v_rtid < 0);
-  if (__pyx_t_7) {
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_v_reference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __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 = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = (__pyx_v_rtid < 0);
+  if (__pyx_t_10) {
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_reference); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_Raise(__pyx_t_4, 0, 0);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L12;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L32;
   }
-  __pyx_L12:;
+  __pyx_L32:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":638
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":685
  *         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) )             # <<<<<<<<<<<<<<
  *         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 )
  */
-  __pyx_t_7 = (__pyx_v_rstart > __pyx_v_rend);
-  if (__pyx_t_7) {
-    __pyx_t_4 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = (__pyx_v_rstart > __pyx_v_rend);
+  if (__pyx_t_10) {
+    __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __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 = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
-    __Pyx_GIVEREF(__pyx_t_4);
-    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
     __Pyx_GIVEREF(__pyx_t_5);
-    __pyx_t_4 = 0;
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_6);
     __pyx_t_5 = 0;
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_6 = 0;
+    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__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 = 638; __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 = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
-    __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+    __pyx_t_6 = 0;
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_5, 0, 0);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L13;
+    __Pyx_Raise(__pyx_t_6, 0, 0);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L33;
   }
-  __pyx_L13:;
+  __pyx_L33:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":639
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":686
  *         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 )             # <<<<<<<<<<<<<<
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
  * 
  */
-  __pyx_t_7 = (0 <= __pyx_v_rstart);
-  if (__pyx_t_7) {
-    __pyx_t_7 = (__pyx_v_rstart < __pyx_v_9csamtools_max_pos);
+  __pyx_t_10 = (0 <= __pyx_v_rstart);
+  if (__pyx_t_10) {
+    __pyx_t_10 = (__pyx_v_rstart < __pyx_v_9csamtools_max_pos);
   }
-  __pyx_t_2 = (!__pyx_t_7);
+  __pyx_t_2 = (!__pyx_t_10);
   if (__pyx_t_2) {
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __Pyx_DECREF(__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 = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__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 = 686; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L14;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L34;
   }
-  __pyx_L14:;
+  __pyx_L34:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":640
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":687
  *         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 )             # <<<<<<<<<<<<<<
@@ -6947,29 +7700,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
   if (__pyx_t_2) {
     __pyx_t_2 = (__pyx_v_rend <= __pyx_v_9csamtools_max_pos);
   }
-  __pyx_t_7 = (!__pyx_t_2);
-  if (__pyx_t_7) {
-    __pyx_t_1 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = (!__pyx_t_2);
+  if (__pyx_t_10) {
+    __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__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 = 640; __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 = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
-    __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+    __pyx_t_6 = 0;
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_5, 0, 0);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L15;
+    __Pyx_Raise(__pyx_t_6, 0, 0);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L35;
   }
-  __pyx_L15:;
+  __pyx_L35:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":642
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":689
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
  * 
  *         return 1, rtid, rstart, rend             # <<<<<<<<<<<<<<
@@ -6977,36 +7730,37 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  *     def seek( self, uint64_t offset, int where = 0):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __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 = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_8);
+  __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
   __Pyx_INCREF(__pyx_int_1);
-  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_1);
   __Pyx_GIVEREF(__pyx_int_1);
-  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
-  __Pyx_GIVEREF(__pyx_t_5);
-  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
-  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_4);
-  __Pyx_GIVEREF(__pyx_t_4);
-  __pyx_t_5 = 0;
+  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __pyx_t_6 = 0;
   __pyx_t_1 = 0;
-  __pyx_t_4 = 0;
-  __pyx_r = __pyx_t_8;
-  __pyx_t_8 = 0;
+  __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_7;
+  __pyx_t_7 = 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_4);
   __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
   __Pyx_XDECREF(__pyx_t_8);
   __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
   __pyx_r = NULL;
@@ -7019,7 +7773,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":644
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":691
  *         return 1, rtid, rstart, rend
  * 
  *     def seek( self, uint64_t offset, int where = 0):             # <<<<<<<<<<<<<<
@@ -7028,7 +7782,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_sel
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_seek[] = "\n        move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.\n        ";
+static char __pyx_doc_9csamtools_7Samfile_seek[] = "Samfile.seek(self, uint64_t offset, int where=0)\n\n        move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   uint64_t __pyx_v_offset;
   int __pyx_v_where;
@@ -7040,7 +7794,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__offset,&__pyx_n_s__where,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("seek");
-  __Pyx_TraceCall("seek", __pyx_f[0], 644);
+  __Pyx_TraceCall("seek", __pyx_f[0], 691);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -7062,72 +7816,72 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __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 = 644; __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 = 691; __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 = 644; __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 = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_where = ((int)0);
     }
   } else {
     __pyx_v_where = ((int)0);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: __pyx_v_where = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  1: __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_where = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   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 = 644; __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 = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.seek");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":649
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":696
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __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 = 649; __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 = 696; __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 = 649; __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 = 696; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":650
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":697
  * 
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __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 = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":651
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":698
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
@@ -7137,29 +7891,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":652
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":699
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  *         return bam_seek( self.samfile.x.bam, offset, where )
  * 
  */
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __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 = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_26));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_26));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_26));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":653
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":700
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  *         return bam_seek( self.samfile.x.bam, offset, where )             # <<<<<<<<<<<<<<
@@ -7167,7 +7921,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
  *     def tell( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -7187,7 +7941,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":655
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":702
  *         return bam_seek( self.samfile.x.bam, offset, where )
  * 
  *     def tell( self ):             # <<<<<<<<<<<<<<
@@ -7196,7 +7950,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObj
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_tell[] = "\n        return current file position\n        ";
+static char __pyx_doc_9csamtools_7Samfile_tell[] = "Samfile.tell(self)\n\n        return current file position\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
@@ -7205,48 +7959,48 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHO
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("tell");
-  __Pyx_TraceCall("tell", __pyx_f[0], 655);
+  __Pyx_TraceCall("tell", __pyx_f[0], 702);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":659
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":706
  *         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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __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 = 659; __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 = 706; __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 = 659; __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 = 706; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":660
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":707
  *         '''
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __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 = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":661
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":708
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
@@ -7256,29 +8010,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHO
   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":662
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":709
  *             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_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __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 = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_26));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_26));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_26));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":664
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":711
  *             raise NotImplementedError("seek only available in bam files")
  * 
  *         return bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
@@ -7286,7 +8040,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHO
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -7306,7 +8060,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHO
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":666
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":713
  *         return bam_tell( self.samfile.x.bam )
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -7315,7 +8069,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHO
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_fetch[] = "\n        fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can \n        be supplied.\n\n        Without *reference* or *region* all reads will be fetched. The reads will be returned\n        ordered by reference sequence, which will not necessarily be the order within the file.\n        If *until_eof* is given, all reads from the current file position will be returned\n        *in order as they are within the file*.  \n        \n        If only *reference* is set, all reads aligned to *reference* will be fetched.\n\n        The method returns an iterator of type :class:`pysam.IteratorRow` unless\n        a *callback is provided. If *callback* is given, the callback will be executed \n        for each position within the :term:`region`. Note that callbacks currently work\n        only, if *region* or *reference* is given.\n\n        Note that a :term:`SAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
+static char __pyx_doc_9csamtools_7Samfile_fetch[] = "Samfile.fetch(self, reference=None, start=None, end=None, region=None, callback=None, until_eof=False)\n\n        fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can \n        be supplied.\n\n        Without *reference* or *region* all reads will be fetched. The reads will be returned\n        ordered by reference sequence, which will not necessarily be the order within the file.\n        If *until_eof* is given, all reads from the current file position will be returned\n        *in order as they are within the file*.  \n        \n        If only *reference* is set, all reads aligned to *reference* will be fetched.\n\n        The method returns an iterator of type :class:`pysam.IteratorRow` unless\n        a *callback is provided. If *callback* is given, the callback will be executed \n        for each position within the :term:`region`. Note that callbacks currently work\n        only, if *region* or *reference* is given.\n\n        Note that a :term:`SAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
@@ -7345,12 +8099,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
   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};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch");
-  __Pyx_TraceCall("fetch", __pyx_f[0], 666);
+  __Pyx_TraceCall("fetch", __pyx_f[0], 713);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[6] = {0,0,0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":667
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -7359,7 +8113,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":668
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -7368,7 +8122,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":669
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -7377,7 +8131,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":670
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -7386,7 +8140,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":671
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
  *                end = None,
  *                region = None,
  *                callback = None,             # <<<<<<<<<<<<<<
@@ -7394,7 +8148,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *         '''
  */
     values[4] = ((PyObject *)Py_None);
-    values[5] = __pyx_k_27;
+    values[5] = __pyx_k_29;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
@@ -7438,7 +8192,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -7448,7 +8202,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     __pyx_v_until_eof = values[5];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":667
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -7457,7 +8211,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":668
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -7466,7 +8220,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":669
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -7475,7 +8229,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":670
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -7484,7 +8238,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_region = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":671
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
  *                end = None,
  *                region = None,
  *                callback = None,             # <<<<<<<<<<<<<<
@@ -7492,7 +8246,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *         '''
  */
     __pyx_v_callback = ((PyObject *)Py_None);
-    __pyx_v_until_eof = __pyx_k_27;
+    __pyx_v_until_eof = __pyx_k_29;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  6: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 5);
       case  5: __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 4);
@@ -7506,62 +8260,62 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
   }
   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 = 666; __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 = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.fetch");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":695
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":742
  *         cdef int rtid, rstart, rend, has_coord
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __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 = 695; __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 = 742; __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 = 695; __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 = 742; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":696
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":743
  * 
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __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 = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":698
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":745
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __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 = 698; __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 = 745; __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);
@@ -7575,23 +8329,23 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
     PyObject* tuple = __pyx_t_5;
     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_v_has_coord = __pyx_t_8;
@@ -7599,26 +8353,26 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     __pyx_v_rstart = __pyx_t_10;
     __pyx_v_rend = __pyx_t_11;
   } else {
-    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_12);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __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 = 698; __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 = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __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 = 698; __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 = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
     __pyx_v_has_coord = __pyx_t_11;
     __pyx_v_rtid = __pyx_t_10;
@@ -7626,7 +8380,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":700
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":747
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -7635,22 +8389,22 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":701
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":748
  * 
  *         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 = 701; __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 = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __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 = 701; __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 = 748; __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 = 701; __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 = 748; __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) {
@@ -7665,39 +8419,39 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     }
     if (__pyx_t_13) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":702
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":749
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __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 = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
-      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_28));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":704
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":751
  *                 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_13 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_13) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":705
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":752
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -7706,53 +8460,53 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
       __pyx_t_13 = (!__pyx_v_has_coord);
       if (__pyx_t_13) {
-        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __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 = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_29));
-        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_29));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_29));
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L10;
       }
       __pyx_L10:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":706
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":753
  *             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(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __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 = 706; __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 = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_t_3 = (!__pyx_t_13);
       if (__pyx_t_3) {
-        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __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 = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
-        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_30));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L11;
       }
       __pyx_L11:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":707
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":754
  *                 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,             # <<<<<<<<<<<<<<
@@ -7761,14 +8515,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":713
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":760
  *                                  rend,
  *                                  <void*>callback,
  *                                  fetch_callback )             # <<<<<<<<<<<<<<
  *             else:
  *                 if has_coord:
  */
-      __pyx_t_7 = PyInt_FromLong(bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyInt_FromLong(bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __pyx_r = __pyx_t_7;
       __pyx_t_7 = 0;
@@ -7777,7 +8531,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":715
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":762
  *                                  fetch_callback )
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
@@ -7786,7 +8540,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
       if (__pyx_v_has_coord) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":716
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":763
  *             else:
  *                 if has_coord:
  *                     return IteratorRowRegion( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
@@ -7794,13 +8548,13 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *                     if until_eof:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_7 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __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 = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __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 = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_INCREF(__pyx_v_self);
         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
@@ -7814,7 +8568,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
         __pyx_t_7 = 0;
         __pyx_t_5 = 0;
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __pyx_r = __pyx_t_6;
@@ -7824,17 +8578,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
       }
       /*else*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":718
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":765
  *                     return IteratorRowRegion( self, rtid, rstart, rend )
  *                 else:
  *                     if until_eof:             # <<<<<<<<<<<<<<
  *                         return IteratorRowAll( self )
  *                     else:
  */
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __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 = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":719
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":766
  *                 else:
  *                     if until_eof:
  *                         return IteratorRowAll( self )             # <<<<<<<<<<<<<<
@@ -7842,12 +8596,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *                         return IteratorRowAllRefs(self)
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __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 = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_self);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
           __Pyx_GIVEREF(__pyx_v_self);
-          __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           __pyx_r = __pyx_t_1;
@@ -7857,7 +8611,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
         }
         /*else*/ {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":721
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":768
  *                         return IteratorRowAll( self )
  *                     else:
  *                         return IteratorRowAllRefs(self)             # <<<<<<<<<<<<<<
@@ -7865,12 +8619,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *             # check if header is present - otherwise sam_read1 aborts
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __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 = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_INCREF(__pyx_v_self);
           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
           __Pyx_GIVEREF(__pyx_v_self);
-          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAllRefs)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAllRefs)), __pyx_t_1, NULL); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __pyx_r = __pyx_t_6;
@@ -7886,7 +8640,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":725
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":772
  *             # check if header is present - otherwise sam_read1 aborts
  *             # this happens if a bamfile is opened with mode 'r'
  *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
@@ -7896,96 +8650,96 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
     __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":726
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":773
  *             # this happens if a bamfile is opened with mode 'r'
  *             if self.samfile.header.n_targets == 0:
  *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
  * 
  *             if region != None:
  */
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __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 = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
-      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_31));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_33));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L14;
     }
     __pyx_L14:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":728
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":775
  *                 raise ValueError( "fetch called for samfile without header")
  * 
  *             if region != None:             # <<<<<<<<<<<<<<
  *                 raise ValueError ("fetch for a region is not available for sam files" )
  *             if callback:
  */
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_region, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_region, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __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 = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":729
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":776
  * 
  *             if region != None:
  *                 raise ValueError ("fetch for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  *             if callback:
  *                 raise NotImplementedError( "callback not implemented yet" )
  */
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __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 = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_32));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_34));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_Raise(__pyx_t_6, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L15;
     }
     __pyx_L15:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":730
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":777
  *             if region != None:
  *                 raise ValueError ("fetch for a region is not available for sam files" )
  *             if callback:             # <<<<<<<<<<<<<<
  *                 raise NotImplementedError( "callback not implemented yet" )
  *             else:
  */
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __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 = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":731
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":778
  *                 raise ValueError ("fetch for a region is not available for sam files" )
  *             if callback:
  *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
  *             else:
  *                 return IteratorRowAll( self )
  */
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __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 = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
-      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_33));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_35));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L16;
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":733
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":780
  *                 raise NotImplementedError( "callback not implemented yet" )
  *             else:
  *                 return IteratorRowAll( self )             # <<<<<<<<<<<<<<
@@ -7993,12 +8747,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  *     def mate( self,
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __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 = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_INCREF(__pyx_v_self);
       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
       __Pyx_GIVEREF(__pyx_v_self);
-      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_r = __pyx_t_6;
@@ -8027,7 +8781,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":735
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":782
  *                 return IteratorRowAll( self )
  * 
  *     def mate( self,             # <<<<<<<<<<<<<<
@@ -8036,93 +8790,105 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyOb
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_mate[] = "return the mate of :class:`AlignedRead` *read*.\n\n        Throws a ValueError if read is unpaired or the mate\n        is unmapped.\n\n        .. note::\n            Calling this method will change the file position.\n            This might interfere with any iterators that have\n            not re-opened the file.\n\n        ";
+static char __pyx_doc_9csamtools_7Samfile_mate[] = "Samfile.mate(self, AlignedRead read)\nreturn the mate of :class:`AlignedRead` *read*.\n\n        Throws a ValueError if read is unpaired or the mate\n        is unmapped.\n\n        .. note::\n            Calling this method will change the file position.\n            This might interfere with any iterators that have\n            not re-opened the file.\n\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
+  uint32_t __pyx_v_flag;
   __pyx_t_9csamtools_MateData __pyx_v_mate_data;
   int __pyx_v_x;
   struct __pyx_obj_9csamtools_AlignedRead *__pyx_v_dest = 0;
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
-  int __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("mate");
-  __Pyx_TraceCall("mate", __pyx_f[0], 735);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("mate", __pyx_f[0], 782);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":748
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":795
  * 
  *         '''
- *         if not read.is_paired:             # <<<<<<<<<<<<<<
- *             raise ValueError( "read is unpaired" )
- *         if read.mate_is_unmapped:
+ *         cdef uint32_t flag = read._delegate.core.flag             # <<<<<<<<<<<<<<
+ * 
+ *         if flag & BAM_FPAIRED == 0:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__is_paired); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __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 = 748; __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_v_flag = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.flag;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":749
- *         '''
- *         if not read.is_paired:
- *             raise ValueError( "read is unpaired" )             # <<<<<<<<<<<<<<
- *         if read.mate_is_unmapped:
- *             raise ValueError( "mate is unmapped" )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":797
+ *         cdef uint32_t flag = read._delegate.core.flag
+ * 
+ *         if flag & BAM_FPAIRED == 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "read %s: is unpaired" % (read.qname))
+ *         if flag & BAM_FMUNMAP != 0:
  */
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_34));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_4, 0, 0);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((__pyx_v_flag & 1) == 0);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":798
+ * 
+ *         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_2 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __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 = 798; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":750
- *         if not read.is_paired:
- *             raise ValueError( "read is unpaired" )
- *         if read.mate_is_unmapped:             # <<<<<<<<<<<<<<
- *             raise ValueError( "mate is unmapped" )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":799
+ *         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_4 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__mate_is_unmapped); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (__pyx_t_3) {
+  __pyx_t_1 = ((__pyx_v_flag & 8) != 0);
+  if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":751
- *             raise ValueError( "read is unpaired" )
- *         if read.mate_is_unmapped:
- *             raise ValueError( "mate is unmapped" )             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":800
+ *             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 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
-    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_35));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_37), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__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 = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_Raise(__pyx_t_2, 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;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":755
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":804
  *         cdef MateData mate_data
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)             # <<<<<<<<<<<<<<
@@ -8131,7 +8897,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
  */
   __pyx_v_mate_data.name = bam1_qname(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":756
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":805
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)
  *         mate_data.mate = NULL             # <<<<<<<<<<<<<<
@@ -8140,25 +8906,25 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
  */
   __pyx_v_mate_data.mate = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":758
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":807
  *         mate_data.mate = NULL
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2             # <<<<<<<<<<<<<<
- *         mate_data.flag = ( read._delegate.core.flag ^ x) & x
+ *         mate_data.flag = ( flag ^ x) & x
  * 
  */
   __pyx_v_x = 192;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":759
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":808
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2
- *         mate_data.flag = ( read._delegate.core.flag ^ x) & x             # <<<<<<<<<<<<<<
+ *         mate_data.flag = ( flag ^ x) & x             # <<<<<<<<<<<<<<
  * 
  *         bam_fetch(self.samfile.x.bam,
  */
-  __pyx_v_mate_data.flag = ((((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.flag ^ __pyx_v_x) & __pyx_v_x);
+  __pyx_v_mate_data.flag = ((__pyx_v_flag ^ __pyx_v_x) & __pyx_v_x);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":767
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":816
  *                   read._delegate.core.mpos + 1,
  *                   <void*>&mate_data,
  *                   mate_callback )             # <<<<<<<<<<<<<<
@@ -8167,52 +8933,52 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
  */
   bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mtid, ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mpos, (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mpos + 1), ((void *)(&__pyx_v_mate_data)), __pyx_f_9csamtools_mate_callback);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":769
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":818
  *                   mate_callback )
  * 
  *         if mate_data.mate == NULL:             # <<<<<<<<<<<<<<
  *             raise ValueError( "mate not found" )
  * 
  */
-  __pyx_t_3 = (__pyx_v_mate_data.mate == NULL);
-  if (__pyx_t_3) {
+  __pyx_t_1 = (__pyx_v_mate_data.mate == NULL);
+  if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":770
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":819
  * 
  *         if mate_data.mate == NULL:
  *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  */
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_36));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_36));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_36));
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_4, 0, 0);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __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 = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_38));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":772
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":821
  *             raise ValueError( "mate not found" )
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
  *         dest._delegate = mate_data.mate
  *         return dest
  */
-  __pyx_t_4 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_4);
-  __pyx_t_4 = 0;
+  __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":773
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":822
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate             # <<<<<<<<<<<<<<
@@ -8221,7 +8987,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
  */
   __pyx_v_dest->_delegate = __pyx_v_mate_data.mate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":774
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":823
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate
  *         return dest             # <<<<<<<<<<<<<<
@@ -8236,8 +9002,8 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("csamtools.Samfile.mate");
   __pyx_r = NULL;
   __pyx_L0:;
@@ -8248,7 +9014,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":776
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":825
  *         return dest
  * 
  *     def count( self,             # <<<<<<<<<<<<<<
@@ -8257,7 +9023,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObj
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_count[] = "*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*\n               \n        count  reads :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied.\n\n        Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
+static char __pyx_doc_9csamtools_7Samfile_count[] = "Samfile.count(self, reference=None, start=None, end=None, region=None, until_eof=False)\n*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*\n               \n        count  reads :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied.\n\n        Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
@@ -8285,12 +9051,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   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};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count");
-  __Pyx_TraceCall("count", __pyx_f[0], 776);
+  __Pyx_TraceCall("count", __pyx_f[0], 825);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":777
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
  * 
  *     def count( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -8299,7 +9065,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":778
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
  *     def count( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -8308,7 +9074,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":779
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -8317,7 +9083,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":780
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -8325,7 +9091,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  */
     values[3] = ((PyObject *)Py_None);
-    values[4] = __pyx_k_37;
+    values[4] = __pyx_k_39;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
@@ -8363,7 +9129,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -8372,7 +9138,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
     __pyx_v_until_eof = values[4];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":777
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
  * 
  *     def count( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -8381,7 +9147,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":778
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
  *     def count( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -8390,7 +9156,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":779
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -8399,7 +9165,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":780
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -8407,7 +9173,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  */
     __pyx_v_region = ((PyObject *)Py_None);
-    __pyx_v_until_eof = __pyx_k_37;
+    __pyx_v_until_eof = __pyx_k_39;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 4);
       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
@@ -8420,7 +9186,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   }
   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 = 776; __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 = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.count");
   __Pyx_RefNannyFinishContext();
@@ -8428,55 +9194,55 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":794
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":843
  *         cdef int rend
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __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 = 794; __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 = 843; __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 = 794; __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 = 843; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":795
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":844
  * 
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __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 = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":797
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":846
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         cdef int counter
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __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 = 797; __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 = 846; __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);
@@ -8490,7 +9256,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -8498,13 +9264,13 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
     PyObject* tuple = __pyx_t_5;
     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_v_region);
@@ -8514,24 +9280,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
     __pyx_v_rstart = __pyx_t_9;
     __pyx_v_rend = __pyx_t_10;
   } else {
-    __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_11);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __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 = 797; __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 = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_11, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_11, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = __pyx_t_2;
@@ -8541,7 +9307,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":800
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":849
  * 
  *         cdef int counter
  *         counter = 0;             # <<<<<<<<<<<<<<
@@ -8550,7 +9316,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
   __pyx_v_counter = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":802
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":851
  *         counter = 0;
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -8559,22 +9325,22 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":803
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":852
  * 
  *         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 = 803; __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 = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __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 = 803; __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 = 852; __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 = 803; __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 = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_12 = (!__pyx_t_4);
       if (__pyx_t_12) {
@@ -8589,93 +9355,93 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
     }
     if (__pyx_t_12) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":804
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":853
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __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 = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
-      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_28));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":806
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":855
  *                 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_12 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_12);
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":807
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":856
  * 
  *             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_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __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 = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
-      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_38));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_40));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); 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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_7, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":808
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":857
  *             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(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __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 = 808; __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 = 857; __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 = 808; __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 = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_12 = (!__pyx_t_3);
     if (__pyx_t_12) {
-      __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 = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
-      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_30));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_7, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L10;
     }
     __pyx_L10:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":815
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":864
  *                              rend,
  *                              <void*>&counter,
  *                              count_callback )             # <<<<<<<<<<<<<<
@@ -8684,7 +9450,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
     bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)(&__pyx_v_counter)), __pyx_f_9csamtools_count_callback);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":816
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":865
  *                              <void*>&counter,
  *                              count_callback )
  *             return counter             # <<<<<<<<<<<<<<
@@ -8692,7 +9458,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  *             raise ValueError ("count for a region is not available for sam files" )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_7 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __pyx_r = __pyx_t_7;
     __pyx_t_7 = 0;
@@ -8701,24 +9467,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":818
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":867
  *             return counter
  *         else:
  *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
- * 
+ *     def pileup( self,
  */
-    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __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 = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
-    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_39));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
+    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_41));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, 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(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L7:;
 
@@ -8741,8 +9507,8 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":821
- * 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":869
+ *             raise ValueError ("count for a region is not available for sam files" )
  * 
  *     def pileup( self,             # <<<<<<<<<<<<<<
  *                 reference = None,
@@ -8750,7 +9516,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyOb
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_pileup[] = "\n        perform a :term:`pileup` within a :term:`region`. The region is specified by\n        :term:`reference`, *start* and *end* (using 0-based indexing). \n        Alternatively, a samtools *region* string can be supplied.\n\n        Without *reference* or *region* all reads will be used for the pileup. The reads will be returned\n        ordered by :term:`reference` sequence, which will not necessarily be the order within the file.\n\n        The method returns an iterator of type :class:`pysam.IteratorColumn` unless\n        a *callback is provided. If a *callback* is given, the callback will be executed \n        for each column within the :term:`region`. \n\n        Note that :term:`SAM` formatted files do not allow random access. \n        In these files, if a *region* or *reference* are given an exception is raised.\n        \n        Optional *kwargs* to the iterator:\n\n        stepper\n           The stepper controlls how the iterator advances. \n           Possible options for the stepper are \n       \n           ``all``\n              use all reads for pileup.\n           ``samtools``\n              same filter and read processing as in :term:`csamtools` pileup\n\n        fastafile\n           A :class:`FastaFile` object\n\n         mask\n           Skip all reads with bits set in mask.\n\n\n        .. note::\n\n            *all* reads which overlap the region are returned. The first base returned will be the \n            first base of the first read *not* necessarily the first base of the region used in the query.\n\n        ";
+static char __pyx_doc_9csamtools_7Samfile_pileup[] = "Samfile.pileup(self, reference=None, start=None, end=None, region=None, callback=None, **kwargs)\n\n        perform a :term:`pileup` within a :term:`region`. The region is specified by\n        :term:`reference`, *start* and *end* (using 0-based indexing). \n        Alternatively, a samtools *region* string can be supplied.\n\n        Without *reference* or *region* all reads will be used for the pileup. The reads will be returned\n        ordered by :term:`reference` sequence, which will not necessarily be the order within the file.\n\n        The method returns an iterator of type :class:`pysam.IteratorColumn` unless\n        a *callback is provided. If a *callback* is given, the callback will be executed \n        for each column within the :term:`region`. \n\n        Note that :term:`SAM` formatted files do not allow random access. \n        In these files, if a *region* or *reference* are given an exception is raised.\n        \n        Optional *kwargs* to the iterator:\n\n        stepper\n           The stepper controlls how the iterator advances. \n           Possible options for the stepper are \n       \n           ``all``\n              use all reads for pileup.\n           ``samtools``\n              same filter and read processing as in :term:`csamtools` pileup\n\n        fastafile\n           A :class:`FastaFile` object\n\n         mask\n           Skip all reads with bits set in mask.\n\n\n        .. note::\n\n            *all* reads which overlap the region are returned. The first base returned will be the \n            first base of the first read *not* necessarily the first base of the region used in the query.\n\n            The maximum number of reads considered for pileup is *8000*. This limit is set by\n            :term:`csamtools`.\n\n        ";
 static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
@@ -8779,14 +9545,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   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};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup");
-  __Pyx_TraceCall("pileup", __pyx_f[0], 821);
+  __Pyx_TraceCall("pileup", __pyx_f[0], 869);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":822
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
  * 
  *     def pileup( self,
  *                 reference = None,             # <<<<<<<<<<<<<<
@@ -8795,7 +9561,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":823
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
  *     def pileup( self,
  *                 reference = None,
  *                 start = None,             # <<<<<<<<<<<<<<
@@ -8804,7 +9570,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":824
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
  *                 reference = None,
  *                 start = None,
  *                 end = None,             # <<<<<<<<<<<<<<
@@ -8813,7 +9579,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":825
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
  *                 start = None,
  *                 end = None,
  *                 region = None,             # <<<<<<<<<<<<<<
@@ -8822,7 +9588,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":826
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
  *                 end = None,
  *                 region = None,
  *                 callback = None,             # <<<<<<<<<<<<<<
@@ -8867,7 +9633,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -8876,7 +9642,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
     __pyx_v_callback = values[4];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":822
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
  * 
  *     def pileup( self,
  *                 reference = None,             # <<<<<<<<<<<<<<
@@ -8885,7 +9651,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":823
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
  *     def pileup( self,
  *                 reference = None,
  *                 start = None,             # <<<<<<<<<<<<<<
@@ -8894,7 +9660,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":824
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
  *                 reference = None,
  *                 start = None,
  *                 end = None,             # <<<<<<<<<<<<<<
@@ -8903,7 +9669,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":825
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
  *                 start = None,
  *                 end = None,
  *                 region = None,             # <<<<<<<<<<<<<<
@@ -8912,7 +9678,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_region = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":826
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
  *                 end = None,
  *                 region = None,
  *                 callback = None,             # <<<<<<<<<<<<<<
@@ -8932,7 +9698,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   }
   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 = 821; __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 = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.Samfile.pileup");
@@ -8940,55 +9706,55 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":870
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":921
  *         cdef bam_plbuf_t *buf
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __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 = 870; __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 = 921; __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 = 870; __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 = 921; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":871
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":922
  * 
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __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 = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":873
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":924
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); 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 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __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 = 924; __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);
@@ -9002,23 +9768,23 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
     PyObject* tuple = __pyx_t_5;
     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__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_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_v_has_coord = __pyx_t_8;
@@ -9026,26 +9792,26 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
     __pyx_v_rstart = __pyx_t_10;
     __pyx_v_rend = __pyx_t_11;
   } else {
-    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_12);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); 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_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __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 = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); 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_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __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 = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
     __pyx_v_has_coord = __pyx_t_11;
     __pyx_v_rtid = __pyx_t_10;
@@ -9053,7 +9819,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":875
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":926
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -9062,48 +9828,48 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":876
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":927
  * 
  *         if self.isbam:
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __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 = 876; __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 = 927; __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 = 876; __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 = 927; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __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 = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
-      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_40));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_42));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":878
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":929
  *             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 = 878; __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 = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":879
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":930
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -9112,22 +9878,22 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
       __pyx_t_3 = (!__pyx_v_has_coord);
       if (__pyx_t_3) {
-        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __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 = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_29));
-        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_29));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_29));
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L10;
       }
       __pyx_L10:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":881
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":932
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  * 
  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )             # <<<<<<<<<<<<<<
@@ -9136,7 +9902,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
       __pyx_v_buf = bam_plbuf_init(((bam_pileup_f)__pyx_f_9csamtools_pileup_callback), ((void *)__pyx_v_callback));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":884
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":935
  *                 bam_fetch(self.samfile.x.bam,
  *                           self.index, rtid, rstart, rend,
  *                           buf, pileup_fetch_callback )             # <<<<<<<<<<<<<<
@@ -9145,7 +9911,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
       bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, __pyx_v_buf, __pyx_f_9csamtools_pileup_fetch_callback);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":887
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":938
  * 
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)             # <<<<<<<<<<<<<<
@@ -9154,7 +9920,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
       bam_plbuf_push(NULL, __pyx_v_buf);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":888
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":939
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)
  *                 bam_plbuf_destroy(buf)             # <<<<<<<<<<<<<<
@@ -9166,7 +9932,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":890
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":941
  *                 bam_plbuf_destroy(buf)
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
@@ -9175,7 +9941,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
       if (__pyx_v_has_coord) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":891
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":942
  *             else:
  *                 if has_coord:
  *                     return IteratorColumnRegion( self,             # <<<<<<<<<<<<<<
@@ -9183,59 +9949,59 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  *                                                  start = rstart,
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_v_self);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
         __Pyx_GIVEREF(__pyx_v_self);
-        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":892
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":943
  *                 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 = 892; __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 = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":893
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":944
  *                     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 = 893; __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 = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":894
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":945
  *                                                  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 = 894; __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 = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":895
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":946
  *                                                  start = rstart,
  *                                                  end = rend,
  *                                                  **kwargs )             # <<<<<<<<<<<<<<
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )
  */
-        if (PyDict_Update(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_6 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnRegion)), __pyx_t_7, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_Update(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnRegion)), __pyx_t_7, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
@@ -9246,7 +10012,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
       }
       /*else*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":897
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":948
  *                                                  **kwargs )
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )             # <<<<<<<<<<<<<<
@@ -9254,12 +10020,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  *         else:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __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 = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_self);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
         __Pyx_GIVEREF(__pyx_v_self);
-        __pyx_t_5 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnAllRefs)), __pyx_t_6, ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnAllRefs)), __pyx_t_6, ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __pyx_r = __pyx_t_5;
@@ -9273,24 +10039,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":900
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":951
  * 
  *         else:
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __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 = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_41));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
-    __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_43));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_6, 0, 0);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L7:;
 
@@ -9313,7 +10079,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":902
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":953
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -9322,15 +10088,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyO
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_close[] = "\n        closes the :class:`pysam.Samfile`.";
+static char __pyx_doc_9csamtools_7Samfile_close[] = "Samfile.close(self)\n\n        closes the :class:`pysam.Samfile`.";
 static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close");
-  __Pyx_TraceCall("close", __pyx_f[0], 902);
+  __Pyx_TraceCall("close", __pyx_f[0], 953);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":905
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":956
  *         '''
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:             # <<<<<<<<<<<<<<
@@ -9340,7 +10106,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTH
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":906
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":957
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:
  *             samclose( self.samfile )             # <<<<<<<<<<<<<<
@@ -9349,7 +10115,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTH
  */
     samclose(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":907
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":958
  *         if self.samfile != NULL:
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);             # <<<<<<<<<<<<<<
@@ -9358,7 +10124,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTH
  */
     bam_index_destroy(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":908
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":959
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);
  *             self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -9377,7 +10143,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTH
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":910
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":961
  *             self.samfile = NULL
  * 
  *     def __dealloc__( self ):             # <<<<<<<<<<<<<<
@@ -9392,23 +10158,23 @@ static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) {
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 910);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 961);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":914
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":965
  *         # 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(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __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 = 914; __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 = 965; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":915
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":966
  *         # note: __del__ is not called.
  *         self.close()
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -9417,12 +10183,12 @@ static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) {
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":916
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":967
  *         self.close()
  *         bam_destroy1(self.b)
  *         if self._filename != NULL: free( self._filename )             # <<<<<<<<<<<<<<
  * 
- *     def write( self, AlignedRead read ):
+ *     cpdef int write( self, AlignedRead read ) except -1:
  */
   __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
   if (__pyx_t_3) {
@@ -9441,75 +10207,123 @@ static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":918
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
  *         if self._filename != NULL: free( self._filename )
  * 
- *     def write( self, AlignedRead read ):             # <<<<<<<<<<<<<<
+ *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
  *         '''
  *         write a single :class:`pysam.AlignedRead` to disk.
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_write[] = "\n        write a single :class:`pysam.AlignedRead` to disk.\n\n        returns the number of bytes written.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
-  PyObject *__pyx_r = NULL;
+static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, struct __pyx_obj_9csamtools_AlignedRead *__pyx_v_read, int __pyx_skip_dispatch) {
+  int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
+  PyObject *__pyx_t_3 = NULL;
   int __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write");
-  __Pyx_TraceCall("write", __pyx_f[0], 918);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("write", __pyx_f[0], 969);
+  /* Check if called by wrapper */
+  if (unlikely(__pyx_skip_dispatch)) ;
+  /* Check if overriden 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 = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_9csamtools_7Samfile_write)) {
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __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_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __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;
+      goto __pyx_L0;
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":924
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":975
  *         returns the number of bytes written.
  *         '''
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
- *             raise ValueError( "I/O operation on closed file" )
+ *             return 0
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__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_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __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 = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  __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 = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __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 = 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_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":925
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":976
  *         '''
  *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *             return 0             # <<<<<<<<<<<<<<
  * 
  *         return samwrite( self.samfile, read._delegate )
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
-    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
+    __pyx_r = 0;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":927
- *             raise ValueError( "I/O operation on closed file" )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":978
+ *             return 0
  * 
  *         return samwrite( self.samfile, read._delegate )             # <<<<<<<<<<<<<<
  * 
  *     def __enter__(self):
  */
+  __pyx_r = samwrite(__pyx_v_self->samfile, __pyx_v_read->_delegate);
+  goto __pyx_L0;
+
+  __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_WriteUnraisable("csamtools.Samfile.write");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
+ *         if self._filename != NULL: free( self._filename )
+ * 
+ *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
+ *         '''
+ *         write a single :class:`pysam.AlignedRead` to disk.
+ */
+
+static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_write[] = "Samfile.write(self, AlignedRead read) -> int\n\n        write a single :class:`pysam.AlignedRead` to disk.\n\n        returns the number of bytes written.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("write");
+  __Pyx_TraceCall("write", __pyx_f[0], 969);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(samwrite(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile, ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_9csamtools_Samfile *)((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->__pyx_vtab)->write(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self), ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9519,7 +10333,6 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyOb
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_AddTraceback("csamtools.Samfile.write");
   __pyx_r = NULL;
   __pyx_L0:;
@@ -9529,7 +10342,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":929
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":980
  *         return samwrite( self.samfile, read._delegate )
  * 
  *     def __enter__(self):             # <<<<<<<<<<<<<<
@@ -9538,13 +10351,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyOb
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile___enter__[] = "Samfile.__enter__(self)";
 static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__enter__");
-  __Pyx_TraceCall("__enter__", __pyx_f[0], 929);
+  __Pyx_TraceCall("__enter__", __pyx_f[0], 980);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":930
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":981
  * 
  *     def __enter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -9564,7 +10378,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":932
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":983
  *         return self
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
@@ -9573,6 +10387,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self,
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile___exit__[] = "Samfile.__exit__(self, exc_type, exc_value, traceback)";
 static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_exc_type = 0;
   PyObject *__pyx_v_exc_value = 0;
@@ -9583,7 +10398,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, P
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__exc_type,&__pyx_n_s__exc_value,&__pyx_n_s__traceback,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__exit__");
-  __Pyx_TraceCall("__exit__", __pyx_f[0], 932);
+  __Pyx_TraceCall("__exit__", __pyx_f[0], 983);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
@@ -9603,17 +10418,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, P
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_value);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__traceback);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_exc_type = values[0];
     __pyx_v_exc_value = values[1];
@@ -9627,28 +10442,28 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, P
   }
   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 = 932; __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 = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.__exit__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":933
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":984
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()             # <<<<<<<<<<<<<<
  *         return False
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); 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_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __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 = 984; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":934
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":985
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()
  *         return False             # <<<<<<<<<<<<<<
@@ -9656,7 +10471,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, P
  *     ###############################################################
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __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 = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -9676,7 +10491,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":943
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":994
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -9693,40 +10508,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 943);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 994);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":944
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":995
  *         '''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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __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 = 944; __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 = 995; __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 = 944; __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 = 995; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __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 = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":945
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":996
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -9734,7 +10549,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
  *     property nreferences:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -9754,7 +10569,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":949
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1000
  *     property nreferences:
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -9771,40 +10586,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 949);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1000);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":950
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1001
  *         '''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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__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 = 950; __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 = 950; __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) {
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __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 = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":951
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1002
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self.samfile.header.n_targets             # <<<<<<<<<<<<<<
@@ -9812,7 +10627,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
  *     property references:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -9832,7 +10647,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":955
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1006
  *     property references:
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -9853,54 +10668,54 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 955);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1006);
   __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":956
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1007
  *         """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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __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 = 956; __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 = 1007; __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 = 956; __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 = 1007; __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 = 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 = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":957
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1008
  *         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_name[x] )
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __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 = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_t));
   __pyx_v_t = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":958
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1009
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -9910,7 +10725,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":959
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1010
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_name[x] )             # <<<<<<<<<<<<<<
@@ -9918,15 +10733,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
  * 
  */
     if (unlikely(__pyx_v_t == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":960
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1011
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_name[x] )
  *             return tuple(t)             # <<<<<<<<<<<<<<
@@ -9935,9 +10750,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
  */
   __Pyx_XDECREF(__pyx_r);
   if (unlikely(__pyx_v_t == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -9958,7 +10773,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":966
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1017
  *         :attr:`pysam.Samfile.references`
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -9979,54 +10794,54 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 966);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1017);
   __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":967
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1018
  *         """
  *         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(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __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 = 967; __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 = 1018; __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 = 967; __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 = 1018; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __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 = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":968
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1019
  *         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_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __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 = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_t));
   __pyx_v_t = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":969
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1020
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -10036,7 +10851,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":970
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1021
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )             # <<<<<<<<<<<<<<
@@ -10044,15 +10859,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
  * 
  */
     if (unlikely(__pyx_v_t == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":971
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1022
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )
  *             return tuple(t)             # <<<<<<<<<<<<<<
@@ -10061,9 +10876,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
  */
   __Pyx_XDECREF(__pyx_r);
   if (unlikely(__pyx_v_t == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -10084,7 +10899,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":975
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1026
  *     property text:
  *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10101,40 +10916,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_se
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 975);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1026);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":976
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1027
  *         '''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 PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __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 = 976; __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 = 1027; __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 = 976; __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 = 1027; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __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 = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":977
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1028
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)             # <<<<<<<<<<<<<<
@@ -10142,7 +10957,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_se
  *     property header:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->l_text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->l_text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -10162,7 +10977,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":983
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1034
  *         a two-level dictionary.
  *         '''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10194,7 +11009,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   PyObject *__pyx_t_10 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 983);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1034);
   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
@@ -10205,51 +11020,51 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":984
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1035
  *         '''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *             result = {}
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__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_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 = 984; __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 = 1035; __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 = 984; __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 = 1035; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __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 = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":986
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1037
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  * 
  *             result = {}             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header.text != NULL:
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
   __pyx_v_result = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":988
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1039
  *             result = {}
  * 
  *             if self.samfile.header.text != NULL:             # <<<<<<<<<<<<<<
@@ -10259,41 +11074,41 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   __pyx_t_4 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text != NULL);
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":990
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1041
  *             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_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_v_t);
     __pyx_v_t = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":991
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1042
  *                 # 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_1 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __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 = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
-    __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
       __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2);
     } else {
-      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
     }
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -10307,7 +11122,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       } else {
         __pyx_t_6 = PyIter_Next(__pyx_t_2);
         if (!__pyx_t_6) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_6);
@@ -10316,19 +11131,19 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       __pyx_v_line = __pyx_t_6;
       __pyx_t_6 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":992
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1043
  *                 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_6 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __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 = 1043; __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) {
@@ -10337,7 +11152,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       }
       __pyx_L9:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":993
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1044
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
@@ -10345,46 +11160,46 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  *                     record = fields[0]
  */
       #ifndef PYREX_WITHOUT_ASSERTIONS
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __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 = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
-      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_42));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
-      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_44));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_44));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44));
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __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 = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (unlikely(!__pyx_t_3)) {
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_43), __pyx_v_line); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_v_line); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
         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 = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":994
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1045
  *                     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_7 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __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 = 994; __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 = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
-      __pyx_t_1 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
@@ -10392,20 +11207,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       __pyx_v_fields = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":995
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1046
  *                     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 = 995; __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 = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_v_record);
       __pyx_v_record = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":996
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1047
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)             # <<<<<<<<<<<<<<
@@ -10413,12 +11228,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  *                     # treat comments
  */
       #ifndef PYREX_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 = 996; __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 = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = ((PySequence_Contains(__pyx_t_1, __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = ((PySequence_Contains(__pyx_t_1, __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __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 = 996; __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 = 1047; __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);
@@ -10426,29 +11241,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
         __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_44), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
         __Pyx_DECREF(__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 = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":999
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1050
  * 
  *                     # 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); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __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 = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (__pyx_t_3) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1000
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1051
  *                     # treat comments
  *                     if record == "CO":
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
@@ -10456,48 +11271,48 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  *                         continue
  */
         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
-          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         } else {
-          __pyx_t_3 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_3 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __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 = 1000; __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 = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__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 = 1000; __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 = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           goto __pyx_L11;
         }
         __pyx_L11:;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1001
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1052
  *                     if record == "CO":
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )             # <<<<<<<<<<<<<<
  *                         continue
  * 
  */
-        __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __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 = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_6 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __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 = 1001; __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 = 1052; __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);
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __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_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1002
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1053
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )
  *                         continue             # <<<<<<<<<<<<<<
@@ -10509,32 +11324,32 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       }
       __pyx_L10:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1005
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1056
  * 
  *                     # the following is clumsy as generators do not work?
  *                     x = {}             # <<<<<<<<<<<<<<
  *                     for field in fields[1:]:
  *                         key, value = field.split(":",1)
  */
-      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_8));
       __Pyx_DECREF(((PyObject *)__pyx_v_x));
       __pyx_v_x = __pyx_t_8;
       __pyx_t_8 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1006
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1057
  *                     # the following is clumsy as generators do not work?
  *                     x = {}
  *                     for field in fields[1:]:             # <<<<<<<<<<<<<<
  *                         key, value = field.split(":",1)
- *                         if key not in VALID_HEADER_FIELDS[record]:
+ *                         # uppercase keys must be valid
  */
-      __pyx_t_8 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       if (PyList_CheckExact(__pyx_t_8) || PyTuple_CheckExact(__pyx_t_8)) {
         __pyx_t_9 = 0; __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6);
       } else {
-        __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
@@ -10548,7 +11363,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
         } else {
           __pyx_t_8 = PyIter_Next(__pyx_t_6);
           if (!__pyx_t_8) {
-            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             break;
           }
           __Pyx_GOTREF(__pyx_t_8);
@@ -10557,24 +11372,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
         __pyx_v_field = __pyx_t_8;
         __pyx_t_8 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1007
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1058
  *                     x = {}
  *                     for field in fields[1:]:
  *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
- *                         if key not in VALID_HEADER_FIELDS[record]:
- *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
+ *                         # uppercase keys must be valid
+ *                         # lowercase are permitted for user fields
  */
-        __pyx_t_8 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __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 = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_45));
-        PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_45));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_45));
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
+        PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_47));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
         __Pyx_INCREF(__pyx_int_1);
         PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_1);
         __Pyx_GIVEREF(__pyx_int_1);
-        __pyx_t_1 = PyObject_Call(__pyx_t_8, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_t_8, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
@@ -10590,14 +11405,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
           __pyx_v_value = __pyx_t_8;
           __pyx_t_8 = 0;
         } else {
-          __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_10);
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          if (__Pyx_EndUnpack(__pyx_t_10, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (__Pyx_EndUnpack(__pyx_t_10, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
           __Pyx_DECREF(__pyx_v_key);
           __pyx_v_key = __pyx_t_7;
@@ -10607,104 +11422,134 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
           __pyx_t_8 = 0;
         }
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1008
- *                     for field in fields[1:]:
- *                         key, value = field.split(":",1)
- *                         if key not in VALID_HEADER_FIELDS[record]:             # <<<<<<<<<<<<<<
- *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
- *                         x[key] = VALID_HEADER_FIELDS[record][key](value)
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1061
+ *                         # 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_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __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 = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __pyx_t_3 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_8, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = ((PySequence_Contains(__pyx_t_8, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         if (__pyx_t_3) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1009
- *                         key, value = field.split(":",1)
- *                         if key not in VALID_HEADER_FIELDS[record]:
- *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )             # <<<<<<<<<<<<<<
- *                         x[key] = VALID_HEADER_FIELDS[record][key](value)
- * 
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1062
+ *                         # 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_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          __Pyx_INCREF(__pyx_v_key);
-          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_key);
-          __Pyx_GIVEREF(__pyx_v_key);
-          __Pyx_INCREF(__pyx_v_record);
-          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_record);
-          __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+          __pyx_t_1 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
           __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 = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_1));
-          __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
-          __pyx_t_1 = 0;
-          __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __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 = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_INCREF(__pyx_v_value);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
+          __Pyx_GIVEREF(__pyx_v_value);
+          __pyx_t_7 = PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_7);
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-          __Pyx_Raise(__pyx_t_1, 0, 0);
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           goto __pyx_L14;
         }
-        __pyx_L14:;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1010
- *                         if key not in VALID_HEADER_FIELDS[record]:
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1063
+ *                         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_7 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __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 = 1063; __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) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1064
+ *                             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) )
- *                         x[key] = VALID_HEADER_FIELDS[record][key](value)             # <<<<<<<<<<<<<<
+ */
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          goto __pyx_L14;
+        }
+        /*else*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1066
+ *                             x[key] = value
+ *                         else:
+ *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )             # <<<<<<<<<<<<<<
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  */
-        __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 = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_8);
-        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_GetItem(__pyx_t_8, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_1);
-        __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 = 1010; __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_7 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_INCREF(__pyx_v_key);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
+          __Pyx_GIVEREF(__pyx_v_key);
+          __Pyx_INCREF(__pyx_v_record);
+          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
+          __Pyx_GIVEREF(__pyx_v_record);
+          __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+          __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 = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_7));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+          __pyx_t_7 = 0;
+          __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_Raise(__pyx_t_7, 0, 0);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        __pyx_L14:;
       }
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1012
- *                         x[key] = VALID_HEADER_FIELDS[record][key](value)
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1068
+ *                             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_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __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_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyDict_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyDict_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      if (__pyx_t_3) {
+      if (__pyx_t_4) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1013
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1069
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  *                         if record in result:             # <<<<<<<<<<<<<<
@@ -10712,67 +11557,67 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  *                         result[record] = x
  */
         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
-          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         } else {
-          __pyx_t_3 = ((PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = ((PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        if (__pyx_t_3) {
+        if (__pyx_t_4) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1014
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1070
  *                     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_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_v_record); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_v_record); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __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 = 1070; __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, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_Raise(__pyx_t_6, 0, 0);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L16;
         }
         __pyx_L16:;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1015
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1071
  *                         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 = 1015; __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 = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L15;
       }
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1016
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1072
  *                             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_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __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_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyList_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyList_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      if (__pyx_t_3) {
+      if (__pyx_t_4) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1017
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1073
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
@@ -10780,29 +11625,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  * 
  */
         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
-          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         } else {
-          __pyx_t_3 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        if (__pyx_t_3) {
-          __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__pyx_t_4) {
+          __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
           goto __pyx_L17;
         }
         __pyx_L17:;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1018
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1074
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []
  *                         result[record].append( x )             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-        __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_7 = __Pyx_PyObject_Append(__pyx_t_6, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyObject_Append(__pyx_t_6, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
@@ -10816,7 +11661,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1020
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1076
  *                         result[record].append( x )
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -10855,7 +11700,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1022
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1078
  *             return result
  * 
  *     def _buildLine( self, fields, record ):             # <<<<<<<<<<<<<<
@@ -10864,7 +11709,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  */
 
 static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile__buildLine[] = "build a header line from *fields* dictionary for *record*";
+static char __pyx_doc_9csamtools_7Samfile__buildLine[] = "Samfile._buildLine(self, fields, record)\nbuild a header line from *fields* dictionary for *record*";
 static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_fields = 0;
   PyObject *__pyx_v_record = 0;
@@ -10877,10 +11722,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
   int __pyx_t_4;
   Py_ssize_t __pyx_t_5;
   PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fields,&__pyx_n_s__record,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildLine");
-  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1022);
+  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1078);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -10899,11 +11745,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__record);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_fields = values[0];
     __pyx_v_record = values[1];
@@ -10915,7 +11761,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
   }
   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 = 1022; __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 = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._buildLine");
   __Pyx_RefNannyFinishContext();
@@ -10924,16 +11770,16 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
   __pyx_v_line = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1026
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1082
  * 
  *         # TODO: add checking for field and sort order
  *         line = ["@%s" % record ]             # <<<<<<<<<<<<<<
  *         if record == "CO":
  *             line.append( fields )
  */
-  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __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 = 1026; __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 = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
@@ -10942,50 +11788,50 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
   __pyx_v_line = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1027
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1083
  *         # TODO: add checking for field and sort order
  *         line = ["@%s" % record ]
  *         if record == "CO":             # <<<<<<<<<<<<<<
  *             line.append( fields )
  *         else:
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __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 = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1028
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1084
  *         line = ["@%s" % record ]
  *         if record == "CO":
  *             line.append( fields )             # <<<<<<<<<<<<<<
  *         else:
- *             for key in VALID_HEADER_ORDER[record]:
+ *             # write fields of the specification
  */
     if (unlikely(__pyx_v_line == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1030
- *             line.append( fields )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1087
  *         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_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __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_5 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
     } 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 = 1030; __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 = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -10999,7 +11845,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
       } else {
         __pyx_t_1 = PyIter_Next(__pyx_t_2);
         if (!__pyx_t_1) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_1);
@@ -11008,37 +11854,37 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
       __pyx_v_key = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1031
- *         else:
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1088
+ *             # write fields of the specification
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:             # <<<<<<<<<<<<<<
  *                     line.append( "%s:%s" % (key, str(fields[key])))
- *         return "\t".join( line )
+ *             # write user fields
  */
-      __pyx_t_3 = ((PySequence_Contains(__pyx_v_fields, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = ((PySequence_Contains(__pyx_v_fields, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_3) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1032
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1089
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:
  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
- *         return "\t".join( line )
- * 
+ *             # write user fields
+ *             for key in fields:
  */
         if (unlikely(__pyx_v_line == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
         }
-        __pyx_t_1 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __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 = 1089; __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);
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __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 = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
@@ -11046,40 +11892,128 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
         PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
         __Pyx_GIVEREF(__pyx_t_1);
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_51), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-        __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
         goto __pyx_L9;
       }
       __pyx_L9:;
     }
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1091
+ *                     line.append( "%s:%s" % (key, str(fields[key])))
+ *             # write user fields
+ *             for key in fields:             # <<<<<<<<<<<<<<
+ *                 if not key.isupper():
+ *                     line.append( "%s:%s" % (key, str(fields[key])))
+ */
+    if (PyList_CheckExact(__pyx_v_fields) || PyTuple_CheckExact(__pyx_v_fields)) {
+      __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
+      } else {
+        __pyx_t_1 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_1) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_1);
+      }
+      __Pyx_DECREF(__pyx_v_key);
+      __pyx_v_key = __pyx_t_1;
+      __pyx_t_1 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1092
+ *             # write user fields
+ *             for key in fields:
+ *                 if not key.isupper():             # <<<<<<<<<<<<<<
+ *                     line.append( "%s:%s" % (key, str(fields[key])))
+ * 
+ */
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_7 = (!__pyx_t_3);
+      if (__pyx_t_7) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1093
+ *             for key in fields:
+ *                 if not key.isupper():
+ *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
+ * 
+ *         return "\t".join( line )
+ */
+        if (unlikely(__pyx_v_line == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_6 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __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(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_INCREF(__pyx_v_key);
+        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
+        __Pyx_GIVEREF(__pyx_v_key);
+        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_51), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+        goto __pyx_L12;
+      }
+      __pyx_L12:;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1033
- *                 if key in fields:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1095
  *                     line.append( "%s:%s" % (key, str(fields[key])))
+ * 
  *         return "\t".join( line )             # <<<<<<<<<<<<<<
  * 
  *     cdef bam_header_t * _buildHeader( self, new_header ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __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 = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(((PyObject *)__pyx_v_line));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_line));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_line));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_line));
-  __pyx_t_6 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __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;
-  __pyx_r = __pyx_t_6;
-  __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -11099,7 +12033,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1035
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1097
  *         return "\t".join( line )
  * 
  *     cdef bam_header_t * _buildHeader( self, new_header ):             # <<<<<<<<<<<<<<
@@ -11135,7 +12069,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   uint32_t __pyx_t_13;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildHeader");
-  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1035);
+  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1097);
   __pyx_v_lines = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_record = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_ttype = Py_None; __Pyx_INCREF(Py_None);
@@ -11146,20 +12080,20 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   __pyx_v_seqname = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_seqlen = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1041
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1103
  *         '''
  * 
  *         lines = []             # <<<<<<<<<<<<<<
  * 
  *         # check if hash exists
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __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 = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_lines));
   __pyx_v_lines = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1048
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1110
  *         cdef bam_header_t * dest
  * 
  *         dest = bam_header_init()             # <<<<<<<<<<<<<<
@@ -11168,19 +12102,19 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
   __pyx_v_dest = bam_header_init();
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1050
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1112
  *         dest = bam_header_init()
  * 
  *         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 = 1050; __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 = 1112; __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 = 0; __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3);
   } else {
-    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -11194,7 +12128,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     } else {
       __pyx_t_1 = PyIter_Next(__pyx_t_3);
       if (!__pyx_t_1) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_1);
@@ -11203,71 +12137,71 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     __pyx_v_record = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1051
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1113
  * 
  *         for record in VALID_HEADERS:
  *             if record in new_header:             # <<<<<<<<<<<<<<
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]
  */
-    __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_4) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1052
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1114
  *         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 = 1052; __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 = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_5 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_DECREF(__pyx_v_ttype);
       __pyx_v_ttype = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1053
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1115
  *             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_5 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_v_data);
       __pyx_v_data = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1054
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1116
  *                 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 ) == types.DictType:
  */
-      __pyx_t_5 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_5)), Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_5)), Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __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 = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_4) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1055
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1117
  *                 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 ) == types.DictType:
  *                     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 = 1055; __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 = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __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 = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
@@ -11279,44 +12213,44 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         PyTuple_SET_ITEM(__pyx_t_5, 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_50), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
         __Pyx_DECREF(__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 = 1055; __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 = 1117; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_1, 0, 0);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L6;
       }
       __pyx_L6:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1056
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1118
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) == types.DictType:             # <<<<<<<<<<<<<<
  *                     lines.append( self._buildLine( data, record ) )
  *                 else:
  */
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DictType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DictType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __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_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __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 = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_4) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1057
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1119
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) == types.DictType:
  *                     lines.append( self._buildLine( data, record ) )             # <<<<<<<<<<<<<<
@@ -11324,11 +12258,11 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *                     for fields in new_header[record]:
  */
         if (unlikely(__pyx_v_lines == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __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 = 1057; __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 = 1119; __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 = 1057; __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 = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_INCREF(__pyx_v_data);
         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data);
@@ -11336,29 +12270,29 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
-        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         goto __pyx_L7;
       }
       /*else*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1059
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1121
  *                     lines.append( self._buildLine( data, record ) )
  *                 else:
  *                     for fields in new_header[record]:             # <<<<<<<<<<<<<<
  *                         lines.append( self._buildLine( fields, record ) )
  * 
  */
-        __pyx_t_6 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __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 = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
           __pyx_t_8 = 0; __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5);
         } else {
-          __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_5);
         }
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -11372,7 +12306,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           } else {
             __pyx_t_6 = PyIter_Next(__pyx_t_5);
             if (!__pyx_t_6) {
-              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               break;
             }
             __Pyx_GOTREF(__pyx_t_6);
@@ -11381,7 +12315,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           __pyx_v_fields = __pyx_t_6;
           __pyx_t_6 = 0;
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1060
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1122
  *                 else:
  *                     for fields in new_header[record]:
  *                         lines.append( self._buildLine( fields, record ) )             # <<<<<<<<<<<<<<
@@ -11389,11 +12323,11 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *         text = "\n".join(lines) + "\n"
  */
           if (unlikely(__pyx_v_lines == Py_None)) {
-            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __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 = 1060; __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 = 1122; __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 = 1060; __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 = 1122; __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);
@@ -11401,11 +12335,11 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           __Pyx_INCREF(__pyx_v_record);
           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
           __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_9 = PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_9); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_9); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         }
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -11417,32 +12351,32 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   }
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1062
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1124
  *                         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_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __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 = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_INCREF(((PyObject *)__pyx_v_lines));
   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_lines));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_lines));
-  __pyx_t_9 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_5 = PyNumber_Add(__pyx_t_9, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyNumber_Add(__pyx_t_9, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
   __Pyx_DECREF(__pyx_v_text);
   __pyx_v_text = __pyx_t_5;
   __pyx_t_5 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1063
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1125
  * 
  *         text = "\n".join(lines) + "\n"
  *         if dest.text != NULL: free( dest.text )             # <<<<<<<<<<<<<<
@@ -11456,72 +12390,72 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   }
   __pyx_L10:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1064
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1126
  *         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)
  *         strncpy( dest.text, text, dest.l_text )
  */
-  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->text = ((char *)calloc(__pyx_t_2, (sizeof(char))));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1065
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1127
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)             # <<<<<<<<<<<<<<
  *         strncpy( dest.text, text, dest.l_text )
  * 
  */
-  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->l_text = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1066
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1128
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)
  *         strncpy( dest.text, text, dest.l_text )             # <<<<<<<<<<<<<<
  * 
  *         # collect targets
  */
-  __pyx_t_10 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_dest->text, __pyx_t_10, __pyx_v_dest->l_text);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1069
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1131
  * 
  *         # collect targets
  *         if "SQ" in new_header:             # <<<<<<<<<<<<<<
  *             seqs = []
  *             for fields in new_header["SQ"]:
  */
-  __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1070
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1132
  *         # collect targets
  *         if "SQ" in new_header:
  *             seqs = []             # <<<<<<<<<<<<<<
  *             for fields in new_header["SQ"]:
  *                 try:
  */
-    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __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 = 1132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
     __Pyx_DECREF(((PyObject *)__pyx_v_seqs));
     __pyx_v_seqs = __pyx_t_5;
     __pyx_t_5 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1071
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1133
  *         if "SQ" in new_header:
  *             seqs = []
  *             for fields in new_header["SQ"]:             # <<<<<<<<<<<<<<
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  */
-    __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
       __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_5; __Pyx_INCREF(__pyx_t_9);
     } else {
-      __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
     }
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -11535,7 +12469,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
       } else {
         __pyx_t_5 = PyIter_Next(__pyx_t_9);
         if (!__pyx_t_5) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_5);
@@ -11544,7 +12478,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
       __pyx_v_fields = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1072
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1134
  *             seqs = []
  *             for fields in new_header["SQ"]:
  *                 try:             # <<<<<<<<<<<<<<
@@ -11559,7 +12493,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __Pyx_XGOTREF(__pyx_save_exc_tb);
         /*try:*/ {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1073
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1135
  *             for fields in new_header["SQ"]:
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )             # <<<<<<<<<<<<<<
@@ -11567,13 +12501,13 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  */
           if (unlikely(__pyx_v_seqs == Py_None)) {
-            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L14_error;} 
+            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;} 
           }
-          __pyx_t_5 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_5 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_GOTREF(__pyx_t_5);
-          __pyx_t_3 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_3 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_GOTREF(__pyx_t_3);
-          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_GOTREF(__pyx_t_1);
           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
           __Pyx_GIVEREF(__pyx_t_5);
@@ -11581,7 +12515,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           __Pyx_GIVEREF(__pyx_t_3);
           __pyx_t_5 = 0;
           __pyx_t_3 = 0;
-          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_seqs), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_seqs), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         }
         __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
@@ -11594,7 +12528,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1074
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1136
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:             # <<<<<<<<<<<<<<
@@ -11604,40 +12538,40 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
         if (__pyx_t_7) {
           __Pyx_AddTraceback("csamtools.Samfile._buildHeader");
-          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_GOTREF(__pyx_t_3);
           __Pyx_GOTREF(__pyx_t_5);
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1075
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1137
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))             # <<<<<<<<<<<<<<
  * 
  *             dest.n_targets = len(seqs)
  */
-          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_fields);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fields);
           __Pyx_GIVEREF(__pyx_v_fields);
-          __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_11);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_51), __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
-          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_11);
           PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_6));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
           __pyx_t_6 = 0;
-          __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
           __Pyx_Raise(__pyx_t_6, 0, 0);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -11659,7 +12593,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     }
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1077
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1139
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  * 
  *             dest.n_targets = len(seqs)             # <<<<<<<<<<<<<<
@@ -11667,12 +12601,12 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  */
     if (unlikely(__pyx_v_seqs == Py_None)) {
-      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
     __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_seqs)); 
     __pyx_v_dest->n_targets = __pyx_t_2;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1078
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1140
  * 
  *             dest.n_targets = len(seqs)
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )             # <<<<<<<<<<<<<<
@@ -11681,7 +12615,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
     __pyx_v_dest->target_name = ((char **)calloc(__pyx_v_dest->n_targets, (sizeof(char *))));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1079
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1141
  *             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) )             # <<<<<<<<<<<<<<
@@ -11690,7 +12624,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
     __pyx_v_dest->target_len = ((uint32_t *)calloc(__pyx_v_dest->n_targets, (sizeof(uint32_t))));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1081
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1143
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  * 
  *             for x from 0 <= x < dest.n_targets:             # <<<<<<<<<<<<<<
@@ -11700,14 +12634,14 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     __pyx_t_12 = __pyx_v_dest->n_targets;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_12; __pyx_v_x++) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1082
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1144
  * 
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]             # <<<<<<<<<<<<<<
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  */
-      __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       if (PyTuple_CheckExact(__pyx_t_9) && likely(PyTuple_GET_SIZE(__pyx_t_9) == 2)) {
         PyObject* tuple = __pyx_t_9;
@@ -11721,14 +12655,14 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_v_seqlen = __pyx_t_3;
         __pyx_t_3 = 0;
       } else {
-        __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __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 = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_1, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_1, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        if (__Pyx_EndUnpack(__pyx_t_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_EndUnpack(__pyx_t_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_v_seqname);
         __pyx_v_seqname = __pyx_t_5;
@@ -11738,42 +12672,42 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_t_3 = 0;
       }
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1083
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1145
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )             # <<<<<<<<<<<<<<
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen
  */
-      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_name[__pyx_v_x]) = ((char *)calloc((__pyx_t_2 + 1), (sizeof(char))));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1084
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1146
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )             # <<<<<<<<<<<<<<
  *                 dest.target_len[x] = seqlen
  * 
  */
-      __pyx_t_10 = PyBytes_AsString(__pyx_v_seqname); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyBytes_AsString(__pyx_v_seqname); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       strncpy((__pyx_v_dest->target_name[__pyx_v_x]), __pyx_t_10, (__pyx_t_2 + 1));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1085
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1147
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen             # <<<<<<<<<<<<<<
  * 
  *         return dest
  */
-      __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_len[__pyx_v_x]) = __pyx_t_13;
     }
     goto __pyx_L11;
   }
   __pyx_L11:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1087
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1149
  *                 dest.target_len[x] = seqlen
  * 
  *         return dest             # <<<<<<<<<<<<<<
@@ -11809,7 +12743,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1097
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1159
  *     ## Possible solutions: deprecate or open new file handle
  *     ###############################################################
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -11826,40 +12760,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self) {
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1097);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1159);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1098
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1160
  *     ###############################################################
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         return self
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __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 = 1098; __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 = 1160; __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 = 1098; __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 = 1160; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __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 = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1099
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1161
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         return self             # <<<<<<<<<<<<<<
@@ -11885,7 +12819,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1101
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1163
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -11897,9 +12831,9 @@ static  bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtoo
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1101);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1163);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1102
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1164
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -11916,7 +12850,7 @@ static  bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtoo
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1104
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1166
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -11928,9 +12862,9 @@ static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfil
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1104);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1166);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1109
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1171
  *         '''
  *         cdef int ret
  *         return samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -11947,7 +12881,7 @@ static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfil
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1111
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1173
  *         return samread(self.samfile, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -11965,9 +12899,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1111);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1173);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1116
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1178
  *         """
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -11976,7 +12910,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
  */
   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1117
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1179
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -11986,7 +12920,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1118
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1180
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -11994,7 +12928,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -12003,7 +12937,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1120
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1182
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -12011,7 +12945,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
  * ##-------------------------------------------------------------------
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L5:;
 
@@ -12028,8 +12962,8 @@ static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1170
- *     cdef samfile_t              * fp
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1234
+ *     cdef int owns_samfile
  * 
  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):             # <<<<<<<<<<<<<<
  * 
@@ -12054,7 +12988,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__tid,&__pyx_n_s__beg,&__pyx_n_s__end,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1170);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1234);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
@@ -12076,19 +13010,19 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beg);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  3:
       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
       if (likely(values[3])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  4:
       if (kw_args > 0) {
@@ -12097,14 +13031,14 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_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 = 1170; __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 = 1170; __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 = 1170; __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 = 1234; __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 = 1234; __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 = 1234; __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 = 1170; __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 = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_reopen = ((int)1);
     }
@@ -12112,11 +13046,11 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
     __pyx_v_reopen = ((int)1);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5:
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  4:
-      __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      __pyx_v_beg = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_beg = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -12124,7 +13058,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   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 = 1170; __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 = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowRegion.__cinit__");
   __Pyx_RefNannyFinishContext();
@@ -12132,87 +13066,87 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1172
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1236
  *     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 = 1172; __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 = 1236; __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 = 1172; __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 = 1236; __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 = 1172; __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 = 1236; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1173
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1237
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._hasIndex():
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __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 = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1175
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1239
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if not samfile._hasIndex():             # <<<<<<<<<<<<<<
  *             raise ValueError( "no index available for iteration" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __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 = 1175; __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 = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __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 = 1175; __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 = 1239; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1176
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1240
  * 
  *         if not samfile._hasIndex():
  *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
  * 
  *         # makes sure that samfile stays alive as long as the
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __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 = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_52));
-    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_52));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_52));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_54));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_54));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_54));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1180
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1244
  *         # makes sure that samfile stays alive as long as the
  *         # iterator is alive
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -12225,7 +13159,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile));
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1182
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1246
  *         self.samfile = samfile
  * 
  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
@@ -12240,7 +13174,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1183
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1247
  * 
  *         if samfile.isbam: mode = "rb"
  *         else: mode = "r"             # <<<<<<<<<<<<<<
@@ -12253,7 +13187,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1187
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1251
  *         # reopen the file - note that this makes the iterator
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -12262,65 +13196,94 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   if (__pyx_v_reopen) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1188
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1252
  *         # 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 = 1188; __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 = 1252; __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 = 1188; __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 = 1252; __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_store);
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1189
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1253
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1190
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1254
  *             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 = 1190; __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 = 1254; __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 = 1190; __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 = 1254; __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;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1191
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1255
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
- * 
- *         self.retval = 0
+ *             self.owns_samfile = True
+ *         else:
  */
     #ifndef PYREX_WITHOUT_ASSERTIONS
     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1256
+ *             store.release()
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.fp = self.samfile.samfile
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile = 1;
     goto __pyx_L9;
   }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1258
+ *             self.owns_samfile = True
+ *         else:
+ *             self.fp = self.samfile.samfile             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = False
+ * 
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile->samfile;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1259
+ *         else:
+ *             self.fp = self.samfile.samfile
+ *             self.owns_samfile = False             # <<<<<<<<<<<<<<
+ * 
+ *         self.retval = 0
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile = 0;
+  }
   __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1193
- *             assert self.fp != NULL
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1261
+ *             self.owns_samfile = False
  * 
  *         self.retval = 0             # <<<<<<<<<<<<<<
  * 
@@ -12328,7 +13291,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1195
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1263
  *         self.retval = 0
  * 
  *         self.iter = bam_iter_query(self.samfile.index,             # <<<<<<<<<<<<<<
@@ -12337,7 +13300,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->iter = bam_iter_query(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile->index, __pyx_v_tid, __pyx_v_beg, __pyx_v_end);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1199
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1267
  *                                    beg,
  *                                    end)
  *         self.b = bam_init1()             # <<<<<<<<<<<<<<
@@ -12361,7 +13324,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1201
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1269
  *         self.b = bam_init1()
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -12374,9 +13337,9 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__py
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1201);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1269);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1202
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1270
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -12396,7 +13359,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1204
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1272
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -12408,9 +13371,9 @@ static  bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_o
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1204);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1272);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1205
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1273
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -12427,7 +13390,7 @@ static  bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_o
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1207
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1275
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -12439,9 +13402,9 @@ static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamt
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1207);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1275);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1209
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1277
  *     cdef int cnext(self):
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         self.retval = bam_iter_read( self.fp.x.bam,             # <<<<<<<<<<<<<<
@@ -12456,7 +13419,7 @@ static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamt
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1213
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1281
  *                                      self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -12473,9 +13436,9 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1213);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1281);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1216
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1284
  *         """python version of next().
  *         """
  *         self.cnext()             # <<<<<<<<<<<<<<
@@ -12484,7 +13447,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__py
  */
   ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1217
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1285
  *         """
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration             # <<<<<<<<<<<<<<
@@ -12494,12 +13457,12 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__py
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval < 0);
   if (__pyx_t_1) {
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1218
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1286
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration
  *         return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -12507,7 +13470,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__py
  *     def __dealloc__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -12526,44 +13489,48 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1220
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1288
  *         return makeAlignedRead( self.b )
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
  *         bam_destroy1(self.b)
- *         samclose( self.fp )
+ *         if self.owns_samfile: samclose( self.fp )
  */
 
 static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self); /*proto*/
 static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1220);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1288);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1221
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1289
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
- *         samclose( self.fp )
+ *         if self.owns_samfile: samclose( self.fp )
  * 
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1222
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1290
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
- *         samclose( self.fp )             # <<<<<<<<<<<<<<
+ *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
  * 
  * cdef class IteratorRowAll(IteratorRow):
  */
-  samclose(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp);
+  if (((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile) {
+    samclose(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
 
   __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1237
- *     cdef samfile_t * fp
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1307
+ *     cdef int owns_samfile
  * 
  *     def __cinit__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
  * 
@@ -12585,7 +13552,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1237);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1307);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -12607,18 +13574,18 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_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 = 1237; __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 = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_reopen = ((int)1);
     }
   } else {
     __pyx_v_reopen = ((int)1);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -12626,7 +13593,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   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 = 1237; __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 = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowAll.__cinit__");
   __Pyx_RefNannyFinishContext();
@@ -12634,48 +13601,48 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1239
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1309
  *     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 = 1239; __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 = 1309; __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 = 1309; __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 = 1309; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1240
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1310
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if samfile.isbam: mode = "rb"
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __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 = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1242
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1312
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
@@ -12690,7 +13657,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1243
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1313
  * 
  *         if samfile.isbam: mode = "rb"
  *         else: mode = "r"             # <<<<<<<<<<<<<<
@@ -12703,7 +13670,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1246
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1316
  * 
  *         # reopen the file to avoid iterator conflict
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -12712,64 +13679,93 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
  */
   if (__pyx_v_reopen) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1247
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1317
  *         # 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 = 1247; __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 = 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 = 1247; __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_DECREF(__pyx_v_store);
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1248
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1318
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1249
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1319
  *             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 = 1249; __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 = 1319; __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 = 1249; __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 = 1319; __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;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1250
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1320
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
- * 
- *         # allocate memory for alignment
+ *             self.owns_samfile = True
+ *         else:
  */
     #ifndef PYREX_WITHOUT_ASSERTIONS
     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1321
+ *             store.release()
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.fp = samfile.samfile
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile = 1;
     goto __pyx_L8;
   }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1323
+ *             self.owns_samfile = True
+ *         else:
+ *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = False
+ * 
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1324
+ *         else:
+ *             self.fp = samfile.samfile
+ *             self.owns_samfile = False             # <<<<<<<<<<<<<<
+ * 
+ *         # allocate memory for alignment
+ */
+    ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile = 0;
+  }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1253
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1327
  * 
  *         # allocate memory for alignment
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -12793,7 +13789,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1255
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1329
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -12806,9 +13802,9 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1255);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1329);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1256
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1330
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -12828,7 +13824,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1258
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1332
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -12840,9 +13836,9 @@ static  bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1258);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1332);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1259
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1333
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -12859,7 +13855,7 @@ static  bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1261
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1335
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -12871,9 +13867,9 @@ static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtool
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1261);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1335);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1264
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1338
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         cdef int ret
  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -12890,7 +13886,7 @@ static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtool
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1266
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1340
  *         return samread(self.fp, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -12908,9 +13904,9 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1266);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1340);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1272
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1346
  *         """
  *         cdef int ret
  *         ret = samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -12919,7 +13915,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
  */
   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp, ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1273
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1347
  *         cdef int ret
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -12929,7 +13925,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1274
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1348
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -12937,7 +13933,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -12946,7 +13942,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1276
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1350
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -12954,7 +13950,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
  *     def __dealloc__(self):
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L5:;
 
@@ -12971,43 +13967,47 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1278
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1352
  *             raise StopIteration
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
  *         bam_destroy1(self.b)
- *         samclose( self.fp )
+ *         if self.owns_samfile: samclose( self.fp )
  */
 
 static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self); /*proto*/
 static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1278);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1352);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1279
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1353
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
- *         samclose( self.fp )
+ *         if self.owns_samfile: samclose( self.fp )
  * 
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1280
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1354
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
- *         samclose( self.fp )             # <<<<<<<<<<<<<<
- * 
+ *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
  * 
+ * cdef class IteratorRowAllRefs(IteratorRow):
  */
-  samclose(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp);
+  if (((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile) {
+    samclose(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
 
   __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1290
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1363
  *     cdef IteratorRowRegion rowiter
  * 
  *     def __cinit__(self, Samfile samfile):             # <<<<<<<<<<<<<<
@@ -13026,7 +14026,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1290);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1363);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[1] = {0};
@@ -13042,7 +14042,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -13052,15 +14052,15 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   }
   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 = 1290; __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 = 1363; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1291
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1364
  * 
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()             # <<<<<<<<<<<<<<
@@ -13068,51 +14068,51 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
  *         self.samfile = samfile
  */
   #ifndef PYREX_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 = 1291; __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 = 1364; __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 = 1291; __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 = 1364; __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 = 1291; __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 = 1364; __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 = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1292
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1365
  *     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 = 1292; __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 = 1365; __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 = 1292; __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 = 1365; __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 = 1292; __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 = 1365; __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 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __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 = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_30));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_32));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, 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_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1293
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1366
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -13125,7 +14125,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
   ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1294
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1367
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile
  *         self.tid = -1             # <<<<<<<<<<<<<<
@@ -13147,7 +14147,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1296
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1369
  *         self.tid = -1
  * 
  *     def nextiter(self):             # <<<<<<<<<<<<<<
@@ -13156,24 +14156,25 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
  */
 
 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter[] = "IteratorRowAllRefs.nextiter(self)";
 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("nextiter");
-  __Pyx_TraceCall("nextiter", __pyx_f[0], 1296);
+  __Pyx_TraceCall("nextiter", __pyx_f[0], 1369);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1297
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1370
  * 
  *     def nextiter(self):
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)             # <<<<<<<<<<<<<<
  * 
  *     def __iter__(self):
  */
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __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 = 1297; __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 = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
@@ -13187,7 +14188,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__p
   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_9csamtools_IteratorRowRegion)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_GIVEREF(__pyx_t_1);
@@ -13210,7 +14211,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1299
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1372
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -13223,9 +14224,9 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__p
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1299);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1372);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1300
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1373
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -13245,7 +14246,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1302
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1375
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -13265,9 +14266,9 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1302);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1375);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1308
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1381
  *         """
  *         # Create an initial iterator
  *         if self.tid==-1:             # <<<<<<<<<<<<<<
@@ -13277,21 +14278,21 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid == -1);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1309
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1382
  *         # Create an initial iterator
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 raise StopIteration
  *             self.tid = 0
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __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 = 1309; __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 = 1382; __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) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1310
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1383
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -13299,12 +14300,12 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
  *             self.nextiter()
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L6;
     }
     __pyx_L6:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1311
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1384
  *             if not self.samfile.nreferences:
  *                 raise StopIteration
  *             self.tid = 0             # <<<<<<<<<<<<<<
@@ -13313,16 +14314,16 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
  */
     ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1312
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1385
  *                 raise StopIteration
  *             self.tid = 0
  *             self.nextiter()             # <<<<<<<<<<<<<<
  * 
  *         while 1:
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __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 = 1312; __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 = 1385; __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;
@@ -13330,7 +14331,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1314
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1387
  *             self.nextiter()
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -13340,7 +14341,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
   while (1) {
     if (!1) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1315
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1388
  * 
  *         while 1:
  *             self.rowiter.cnext()             # <<<<<<<<<<<<<<
@@ -13349,7 +14350,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1318
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1391
  * 
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:             # <<<<<<<<<<<<<<
@@ -13359,7 +14360,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
     __pyx_t_3 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->retval > 0);
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1319
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1392
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:
  *                 return makeAlignedRead(self.rowiter.b)             # <<<<<<<<<<<<<<
@@ -13367,7 +14368,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
  *             self.tid += 1
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_4 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __pyx_r = __pyx_t_4;
       __pyx_t_4 = 0;
@@ -13376,7 +14377,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1321
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1394
  *                 return makeAlignedRead(self.rowiter.b)
  * 
  *             self.tid += 1             # <<<<<<<<<<<<<<
@@ -13385,35 +14386,35 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
  */
     ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid += 1;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1324
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1397
  * 
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 self.nextiter()
  *             else:
  */
-    __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __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); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __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 = 1324; __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 = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1325
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1398
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:
  *                 self.nextiter()             # <<<<<<<<<<<<<<
  *             else:
  *                 raise StopIteration
  */
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __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 = 1325; __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 = 1398; __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;
@@ -13421,15 +14422,15 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1327
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1400
  *                 self.nextiter()
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
  * 
- * ##-------------------------------------------------------------------
+ * cdef class IteratorRowSelection(IteratorRow):
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L10:;
   }
@@ -13449,409 +14450,473 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1340
- *     int seq_len
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1415
+ *     cdef int owns_samfile
  * 
- * cdef int __advance_all( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
- *     '''advance without any read filtering.
- *     '''
+ *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):             # <<<<<<<<<<<<<<
+ * 
+ *         if not samfile._isOpen():
  */
 
-static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v_b) {
-  __pyx_t_9csamtools___iterdata *__pyx_v_d;
+static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
+  PyObject *__pyx_v_positions = 0;
+  int __pyx_v_reopen;
+  PyObject *__pyx_v_mode;
+  PyObject *__pyx_v_store;
   int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  char *__pyx_t_5;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__positions,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__advance_all");
-  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1340);
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1415);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__positions);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
+        if (value) { values[2] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_samfile = ((struct __pyx_obj_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 = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_reopen = ((int)1);
+    }
+  } else {
+    __pyx_v_reopen = ((int)1);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3:
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2:
+      __pyx_v_positions = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  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 = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.IteratorRowSelection.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1344
- *     '''
- *     cdef __iterdata * d
- *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
- *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1417
+ *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):
+ * 
+ *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
+ *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
+  __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 = 1417; __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_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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = (!__pyx_t_3);
+  if (__pyx_t_4) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1345
- *     cdef __iterdata * d
- *     d = <__iterdata*>data
- *     return bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1418
  * 
- * cdef int __advance_snpcalls( void * data, bam1_t * b ):
+ *         if not samfile._isOpen():
+ *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ * 
+ *         if not samfile._isOpen():
  */
-  __pyx_r = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
-  goto __pyx_L0;
-
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1347
- *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1420
+ *             raise ValueError( "I/O operation on closed file" )
+ * 
+ *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
+ *             raise ValueError( "I/O operation on closed file" )
  * 
- * cdef int __advance_snpcalls( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
- *     '''advance using same filter and read processing as in
- *     the samtools pileup.
  */
+  __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 = 1420; __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 = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __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 = 1420; __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) {
 
-static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__pyx_v_b) {
-  __pyx_t_9csamtools___iterdata *__pyx_v_d;
-  int __pyx_v_ret;
-  int __pyx_v_skip;
-  int __pyx_v_q;
-  int __pyx_v_is_cns;
-  int __pyx_v_is_nobaq;
-  int __pyx_v_capQ_thres;
-  int __pyx_r;
-  int __pyx_t_1;
-  int __pyx_t_2;
-  int __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  long __pyx_t_7;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__advance_snpcalls");
-  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1347);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1352
- *     '''
- *     cdef __iterdata * d
- *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1421
  * 
- *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
+ *         if not samfile._isOpen():
+ *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ * 
+ *         assert samfile.isbam, "can only use this iterator on bam files"
  */
-  __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1354
- *     d = <__iterdata*>data
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1423
+ *             raise ValueError( "I/O operation on closed file" )
+ * 
+ *         assert samfile.isbam, "can only use this iterator on bam files"             # <<<<<<<<<<<<<<
+ *         mode = "rb"
  * 
- *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
- *     cdef int skip = 0
- *     cdef int q
  */
-  __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!__pyx_v_samfile->isbam)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_55));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1355
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1424
  * 
- *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
- *     cdef int skip = 0             # <<<<<<<<<<<<<<
- *     cdef int q
- *     cdef int is_cns = 1
+ *         assert samfile.isbam, "can only use this iterator on bam files"
+ *         mode = "rb"             # <<<<<<<<<<<<<<
+ * 
+ *         # reopen the file to avoid iterator conflict
  */
-  __pyx_v_skip = 0;
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
+  __Pyx_DECREF(__pyx_v_mode);
+  __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1357
- *     cdef int skip = 0
- *     cdef int q
- *     cdef int is_cns = 1             # <<<<<<<<<<<<<<
- *     cdef int is_nobaq = 0
- *     cdef int capQ_thres = 0
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1427
+ * 
+ *         # reopen the file to avoid iterator conflict
+ *         if reopen:             # <<<<<<<<<<<<<<
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )
  */
-  __pyx_v_is_cns = 1;
+  if (__pyx_v_reopen) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1358
- *     cdef int q
- *     cdef int is_cns = 1
- *     cdef int is_nobaq = 0             # <<<<<<<<<<<<<<
- *     cdef int capQ_thres = 0
- * 
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1428
+ *         # reopen the file to avoid iterator conflict
+ *         if reopen:
+ *             store = StderrStore()             # <<<<<<<<<<<<<<
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
  */
-  __pyx_v_is_nobaq = 0;
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __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 = 1428; __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_store);
+    __pyx_v_store = __pyx_t_2;
+    __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1359
- *     cdef int is_cns = 1
- *     cdef int is_nobaq = 0
- *     cdef int capQ_thres = 0             # <<<<<<<<<<<<<<
- * 
- *     # reload sequence
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1429
+ *         if reopen:
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
+ *             store.release()
+ *             assert self.fp != NULL
  */
-  __pyx_v_capQ_thres = 0;
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1362
- * 
- *     # reload sequence
- *     if d.fastafile != NULL and b.core.tid != d.tid:             # <<<<<<<<<<<<<<
- *         if d.seq != NULL: free(d.seq)
- *         d.tid = b.core.tid;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1430
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()             # <<<<<<<<<<<<<<
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True
  */
-  __pyx_t_1 = (__pyx_v_d->fastafile != NULL);
-  if (__pyx_t_1) {
-    __pyx_t_2 = (__pyx_v_b->core.tid != __pyx_v_d->tid);
-    __pyx_t_3 = __pyx_t_2;
-  } else {
-    __pyx_t_3 = __pyx_t_1;
-  }
-  if (__pyx_t_3) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __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 = 1430; __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;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1363
- *     # reload sequence
- *     if d.fastafile != NULL and b.core.tid != d.tid:
- *         if d.seq != NULL: free(d.seq)             # <<<<<<<<<<<<<<
- *         d.tid = b.core.tid;
- *         d.seq = faidx_fetch_seq(d.fastafile,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1431
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
+ *             assert self.fp != NULL             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = True
+ *         else:
  */
-    __pyx_t_3 = (__pyx_v_d->seq != NULL);
-    if (__pyx_t_3) {
-      free(__pyx_v_d->seq);
-      goto __pyx_L4;
+    #ifndef PYREX_WITHOUT_ASSERTIONS
+    if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp != NULL))) {
+      PyErr_SetNone(PyExc_AssertionError);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
-    __pyx_L4:;
+    #endif
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1364
- *     if d.fastafile != NULL and b.core.tid != d.tid:
- *         if d.seq != NULL: free(d.seq)
- *         d.tid = b.core.tid;             # <<<<<<<<<<<<<<
- *         d.seq = faidx_fetch_seq(d.fastafile,
- *                                 d.samfile.header.target_name[d.tid],
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1432
+ *             store.release()
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.fp = samfile.samfile
  */
-    __pyx_v_d->tid = __pyx_v_b->core.tid;
+    ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 1;
+    goto __pyx_L8;
+  }
+  /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1365
- *         if d.seq != NULL: free(d.seq)
- *         d.tid = b.core.tid;
- *         d.seq = faidx_fetch_seq(d.fastafile,             # <<<<<<<<<<<<<<
- *                                 d.samfile.header.target_name[d.tid],
- *                                 0, max_pos,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1434
+ *             self.owns_samfile = True
+ *         else:
+ *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = False
+ * 
  */
-    __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_9csamtools_max_pos, (&__pyx_v_d->seq_len));
+    ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1370
- *                                 &d.seq_len)
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1435
+ *         else:
+ *             self.fp = samfile.samfile
+ *             self.owns_samfile = False             # <<<<<<<<<<<<<<
  * 
- *         if d.seq == NULL:             # <<<<<<<<<<<<<<
- *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
- *                                   (d.samfile.header.target_name[d.tid],
+ *         # allocate memory for alignment
  */
-    __pyx_t_3 = (__pyx_v_d->seq == NULL);
-    if (__pyx_t_3) {
+    ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 0;
+  }
+  __pyx_L8:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1372
- *         if d.seq == NULL:
- *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
- *                                   (d.samfile.header.target_name[d.tid],             # <<<<<<<<<<<<<<
- *                                    d.tid))
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1438
+ * 
+ *         # allocate memory for alignment
+ *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
  * 
+ *         self.positions = positions
  */
-      __pyx_t_4 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1373
- *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
- *                                   (d.samfile.header.target_name[d.tid],
- *                                    d.tid))             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1440
+ *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
+ *         self.positions = positions             # <<<<<<<<<<<<<<
+ *         self.current_pos = 0
  * 
  */
-      __pyx_t_5 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_6);
-      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
-      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
-      __Pyx_GIVEREF(__pyx_t_5);
-      __pyx_t_4 = 0;
-      __pyx_t_5 = 0;
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __Pyx_DECREF(__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 = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_6);
-      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
-      __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __Pyx_Raise(__pyx_t_5, 0, 0);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L5;
-    }
-    __pyx_L5:;
-    goto __pyx_L3;
-  }
-  __pyx_L3:;
+  __Pyx_INCREF(__pyx_v_positions);
+  __Pyx_GIVEREF(__pyx_v_positions);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions);
+  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions);
+  ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions = __pyx_v_positions;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1376
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1441
  * 
- *     while ret >= 0:             # <<<<<<<<<<<<<<
+ *         self.positions = positions
+ *         self.current_pos = 0             # <<<<<<<<<<<<<<
  * 
- *         skip = 0
+ *     def __iter__(self):
  */
-  while (1) {
-    __pyx_t_3 = (__pyx_v_ret >= 0);
-    if (!__pyx_t_3) break;
+  ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->current_pos = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1378
- *     while ret >= 0:
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.IteratorRowSelection.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_mode);
+  __Pyx_DECREF(__pyx_v_store);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1443
+ *         self.current_pos = 0
  * 
- *         skip = 0             # <<<<<<<<<<<<<<
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
  * 
- *         # realign read - changes base qualities
  */
-    __pyx_v_skip = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1381
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__iter__");
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1443);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1444
  * 
- *         # realign read - changes base qualities
- *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )             # <<<<<<<<<<<<<<
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
  * 
- *         if d.seq != NULL and capQ_thres > 10:
+ *     cdef bam1_t * getCurrent( self ):
  */
-    __pyx_t_3 = (__pyx_v_d->seq != NULL);
-    if (__pyx_t_3) {
-      if (__pyx_v_is_cns) {
-        __pyx_t_1 = (!__pyx_v_is_nobaq);
-        __pyx_t_2 = __pyx_t_1;
-      } else {
-        __pyx_t_2 = __pyx_v_is_cns;
-      }
-      __pyx_t_1 = __pyx_t_2;
-    } else {
-      __pyx_t_1 = __pyx_t_3;
-    }
-    if (__pyx_t_1) {
-      bam_prob_realn(__pyx_v_b, __pyx_v_d->seq);
-      goto __pyx_L8;
-    }
-    __pyx_L8:;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1383
- *         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:             # <<<<<<<<<<<<<<
- *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
- *             if q < 0: skip = 1
- */
-    __pyx_t_1 = (__pyx_v_d->seq != NULL);
-    if (__pyx_t_1) {
-      __pyx_t_3 = (__pyx_v_capQ_thres > 10);
-      __pyx_t_2 = __pyx_t_3;
-    } else {
-      __pyx_t_2 = __pyx_t_1;
-    }
-    if (__pyx_t_2) {
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1384
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1446
+ *         return self
+ * 
+ *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
+ *         return self.b
  * 
- *         if d.seq != NULL and capQ_thres > 10:
- *             q = bam_cap_mapQ(b, d.seq, capQ_thres)             # <<<<<<<<<<<<<<
- *             if q < 0: skip = 1
- *             elif b.core.qual > q: b.core.qual = q
  */
-      __pyx_v_q = bam_cap_mapQ(__pyx_v_b, __pyx_v_d->seq, __pyx_v_capQ_thres);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1385
- *         if d.seq != NULL and capQ_thres > 10:
- *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
- *             if q < 0: skip = 1             # <<<<<<<<<<<<<<
- *             elif b.core.qual > q: b.core.qual = q
- *         if b.core.flag & BAM_FUNMAP: skip = 1
- */
-      __pyx_t_2 = (__pyx_v_q < 0);
-      if (__pyx_t_2) {
-        __pyx_v_skip = 1;
-        goto __pyx_L10;
-      }
+static  bam1_t *__pyx_f_9csamtools_20IteratorRowSelection_getCurrent(struct __pyx_obj_9csamtools_IteratorRowSelection *__pyx_v_self) {
+  bam1_t *__pyx_r;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("getCurrent");
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1446);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1386
- *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
- *             if q < 0: skip = 1
- *             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
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1447
+ * 
+ *     cdef bam1_t * getCurrent( self ):
+ *         return self.b             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int cnext(self):
  */
-      __pyx_t_2 = (__pyx_v_b->core.qual > __pyx_v_q);
-      if (__pyx_t_2) {
-        __pyx_v_b->core.qual = __pyx_v_q;
-        goto __pyx_L10;
-      }
-      __pyx_L10:;
-      goto __pyx_L9;
-    }
-    __pyx_L9:;
+  __pyx_r = __pyx_v_self->b;
+  goto __pyx_L0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1387
- *             if q < 0: skip = 1
- *             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
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1449
+ *         return self.b
+ * 
+ *     cdef int cnext(self):             # <<<<<<<<<<<<<<
+ *         '''cversion of iterator'''
  * 
  */
-    __pyx_t_7 = (__pyx_v_b->core.flag & 4);
-    if (__pyx_t_7) {
-      __pyx_v_skip = 1;
-      goto __pyx_L11;
-    }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1388
- *             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             # <<<<<<<<<<<<<<
+static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9csamtools_IteratorRowSelection *__pyx_v_self) {
+  int __pyx_r;
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint64_t __pyx_t_4;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("cnext");
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1449);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1453
  * 
- *         if not skip: break
+ *         # end iteration if out of positions
+ *         if self.current_pos >= len(self.positions): return -1             # <<<<<<<<<<<<<<
+ * 
+ *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  */
-    if ((__pyx_v_b->core.flag & 1)) {
-      __pyx_t_2 = (!(__pyx_v_b->core.flag & 2));
-      __pyx_t_1 = __pyx_t_2;
-    } else {
-      __pyx_t_1 = (__pyx_v_b->core.flag & 1);
-    }
-    if (__pyx_t_1) {
-      __pyx_v_skip = 1;
-      goto __pyx_L11;
-    }
-    __pyx_L11:;
+  __pyx_t_1 = PyObject_Length(__pyx_v_self->positions); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = (__pyx_v_self->current_pos >= __pyx_t_1);
+  if (__pyx_t_2) {
+    __pyx_r = -1;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1390
- *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
- * 
- *         if not skip: break             # <<<<<<<<<<<<<<
- *         # additional filters
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1455
+ *         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_v_skip);
-    if (__pyx_t_1) {
-      goto __pyx_L7_break;
-      goto __pyx_L12;
-    }
-    __pyx_L12:;
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->positions, __pyx_v_self->current_pos, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  bam_seek(__pyx_v_self->fp->x.bam, __pyx_t_4, 0);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1393
- *         # additional filters
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1456
  * 
- *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
+ *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
+ *         self.current_pos += 1             # <<<<<<<<<<<<<<
+ *         return samread(self.fp, self.b)
  * 
- *     return ret
  */
-    __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
-  }
-  __pyx_L7_break:;
+  __pyx_v_self->current_pos += 1;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1395
- *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
- * 
- *     return ret             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1457
+ *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
+ *         self.current_pos += 1
+ *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
  * 
- * cdef class IteratorColumn:
+ *     def __next__(self):
  */
-  __pyx_r = __pyx_v_ret;
+  __pyx_r = samread(__pyx_v_self->fp, __pyx_v_self->b);
   goto __pyx_L0;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_WriteUnraisable("csamtools.__advance_snpcalls");
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_WriteUnraisable("csamtools.IteratorRowSelection.cnext");
   __pyx_r = 0;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -13859,487 +14924,1018 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1454
- *     cdef stepper
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1459
+ *         return samread(self.fp, self.b)
  * 
- *     def __cinit__( self, Samfile samfile, **kwargs ):             # <<<<<<<<<<<<<<
- *         self.samfile = samfile
- *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
- */
-
-static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
-  PyObject *__pyx_v_kwargs = 0;
-  int __pyx_r;
-  PyObject *__pyx_t_1 = NULL;
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_20IteratorRowSelection___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self) {
+  int __pyx_v_ret;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1454);
-  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
-  __Pyx_GOTREF(__pyx_v_kwargs);
-  if (unlikely(__pyx_kwds)) {
-    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[1] = {0};
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
-      case  0: break;
-      default: goto __pyx_L5_argtuple_error;
-    }
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
-      if (likely(values[0])) kw_args--;
-      else goto __pyx_L5_argtuple_error;
-    }
-    if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    }
-    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
-  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
-    goto __pyx_L5_argtuple_error;
-  } else {
-    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
-  }
-  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 = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  __pyx_L3_error:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
-  __Pyx_RefNannyFinishContext();
-  return -1;
-  __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannySetupContext("__next__");
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1459);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1455
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1465
+ *         """
  * 
- *     def __cinit__( self, Samfile samfile, **kwargs ):
- *         self.samfile = samfile             # <<<<<<<<<<<<<<
- *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
- *         self.fastafile = kwargs.get( "fastafile", None )
- */
-  __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
-  __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile);
-  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile));
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile = __pyx_v_samfile;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1456
- *     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 )
+ *         cdef int ret = self.cnext()             # <<<<<<<<<<<<<<
+ *         if (ret > 0):
+ *             return makeAlignedRead( self.b )
  */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __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 = 1456; __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 = 1456; __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 = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->mask = __pyx_t_3;
+  __pyx_v_ret = ((struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *)((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1457
- *         self.samfile = samfile
- *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
- *         self.fastafile = kwargs.get( "fastafile", None )             # <<<<<<<<<<<<<<
- *         self.stepper = kwargs.get( "stepper", None )
- *         self.iterdata.seq = NULL
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1466
+ * 
+ *         cdef int ret = self.cnext()
+ *         if (ret > 0):             # <<<<<<<<<<<<<<
+ *             return makeAlignedRead( self.b )
+ *         else:
  */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __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 = 1457; __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_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GIVEREF(__pyx_t_2);
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
-  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_1 = (__pyx_v_ret > 0);
+  if (__pyx_t_1) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1458
- *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
- *         self.fastafile = kwargs.get( "fastafile", None )
- *         self.stepper = kwargs.get( "stepper", None )             # <<<<<<<<<<<<<<
- *         self.iterdata.seq = NULL
- *         self.tid = 0
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1467
+ *         cdef int ret = self.cnext()
+ *         if (ret > 0):
+ *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
+ *         else:
+ *             raise StopIteration
  */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __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_L5;
   }
-  __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 = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_GIVEREF(__pyx_t_2);
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
-  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper = __pyx_t_2;
-  __pyx_t_2 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1459
- *         self.fastafile = kwargs.get( "fastafile", None )
- *         self.stepper = kwargs.get( "stepper", None )
- *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
- *         self.tid = 0
- *         self.pos = 0
- */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1460
- *         self.stepper = kwargs.get( "stepper", None )
- *         self.iterdata.seq = NULL
- *         self.tid = 0             # <<<<<<<<<<<<<<
- *         self.pos = 0
- *         self.n_plp = 0
- */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->tid = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1461
- *         self.iterdata.seq = NULL
- *         self.tid = 0
- *         self.pos = 0             # <<<<<<<<<<<<<<
- *         self.n_plp = 0
- *         self.plp = NULL
- */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pos = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1462
- *         self.tid = 0
- *         self.pos = 0
- *         self.n_plp = 0             # <<<<<<<<<<<<<<
- *         self.plp = NULL
- *         self.pileup_iter = <bam_plp_t>NULL
- */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->n_plp = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1463
- *         self.pos = 0
- *         self.n_plp = 0
- *         self.plp = NULL             # <<<<<<<<<<<<<<
- *         self.pileup_iter = <bam_plp_t>NULL
- * 
- */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->plp = NULL;
+  /*else*/ {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1464
- *         self.n_plp = 0
- *         self.plp = NULL
- *         self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1469
+ *             return makeAlignedRead( self.b )
+ *         else:
+ *             raise StopIteration             # <<<<<<<<<<<<<<
  * 
- *     def __iter__(self):
+ *     def __dealloc__(self):
  */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL);
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_L5:;
 
-  __pyx_r = 0;
+  __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("csamtools.IteratorColumn.__cinit__");
-  __pyx_r = -1;
+  __Pyx_AddTraceback("csamtools.IteratorRowSelection.__next__");
+  __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_TraceReturn(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1466
- *         self.pileup_iter = <bam_plp_t>NULL
- * 
- *     def __iter__(self):             # <<<<<<<<<<<<<<
- *         return self
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1471
+ *             raise StopIteration
  * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         bam_destroy1(self.b)
+ *         if self.owns_samfile: samclose( self.fp )
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
+static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1466);
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1471);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1467
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1472
  * 
- *     def __iter__(self):
- *         return self             # <<<<<<<<<<<<<<
+ *     def __dealloc__(self):
+ *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
+ *         if self.owns_samfile: samclose( self.fp )
  * 
- *     cdef int cnext(self):
  */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(__pyx_v_self);
-  __pyx_r = __pyx_v_self;
-  goto __pyx_L0;
+  bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b);
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1473
+ *     def __dealloc__(self):
+ *         bam_destroy1(self.b)
+ *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
+ * 
+ * ##-------------------------------------------------------------------
+ */
+  if (((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile) {
+    samclose(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
-  return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1469
- *         return self
- * 
- *     cdef int cnext(self):             # <<<<<<<<<<<<<<
- *         '''perform next iteration.
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1486
+ *     int seq_len
  * 
+ * cdef int __advance_all( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
+ *     '''advance without any read filtering.
+ *     '''
  */
 
-static  int __pyx_f_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
+static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v_b) {
+  __pyx_t_9csamtools___iterdata *__pyx_v_d;
   int __pyx_r;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1469);
+  __Pyx_RefNannySetupContext("__advance_all");
+  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1486);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1475
- *         It has been re-implemented to permit for filtering.
- *         '''
- *         self.plp = bam_plp_auto( self.pileup_iter,             # <<<<<<<<<<<<<<
- *                                  &self.tid,
- *                                  &self.pos,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1490
+ *     '''
+ *     cdef __iterdata * d
+ *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
+ *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
+ * 
  */
-  __pyx_v_self->plp = bam_plp_auto(__pyx_v_self->pileup_iter, (&__pyx_v_self->tid), (&__pyx_v_self->pos), (&__pyx_v_self->n_plp));
+  __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1491
+ *     cdef __iterdata * d
+ *     d = <__iterdata*>data
+ *     return bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
+ * 
+ * cdef int __advance_snpcalls( void * data, bam1_t * b ):
+ */
+  __pyx_r = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
+  goto __pyx_L0;
 
   __pyx_r = 0;
+  __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1480
- *                                  &self.n_plp )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1493
+ *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
  * 
- *     cdef char * getSequence( self ):             # <<<<<<<<<<<<<<
- *         '''return current reference sequence underlying the iterator.
- *         '''
+ * cdef int __advance_snpcalls( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
+ *     '''advance using same filter and read processing as in
+ *     the samtools pileup.
  */
 
-static  char *__pyx_f_9csamtools_14IteratorColumn_getSequence(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
-  char *__pyx_r;
+static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__pyx_v_b) {
+  __pyx_t_9csamtools___iterdata *__pyx_v_d;
+  int __pyx_v_ret;
+  int __pyx_v_skip;
+  int __pyx_v_q;
+  int __pyx_v_is_cns;
+  int __pyx_v_is_nobaq;
+  int __pyx_v_capQ_thres;
+  int __pyx_r;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  long __pyx_t_7;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("getSequence");
-  __Pyx_TraceCall("getSequence", __pyx_f[0], 1480);
+  __Pyx_RefNannySetupContext("__advance_snpcalls");
+  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1493);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1483
- *         '''return current reference sequence underlying the iterator.
- *         '''
- *         return self.iterdata.seq             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1498
+ *     '''
+ *     cdef __iterdata * d
+ *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
  * 
- *     property seq_len:
+ *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
  */
-  __pyx_r = __pyx_v_self->iterdata.seq;
-  goto __pyx_L0;
-
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1487
- *     property seq_len:
- *         '''current sequence length.'''
- *         def __get__(self): return self.iterdata.seq_len             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1500
+ *     d = <__iterdata*>data
  * 
- *     def addReference( self, Fastafile fastafile ):
+ *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
+ *     cdef int skip = 0
+ *     cdef int q
  */
+  __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1487);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __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("csamtools.IteratorColumn.seq_len.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1489
- *         def __get__(self): return self.iterdata.seq_len
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1501
  * 
- *     def addReference( self, Fastafile fastafile ):             # <<<<<<<<<<<<<<
- *        '''
- *        add reference sequences in *fastafile* to iterator.'''
- */
-
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile); /*proto*/
-static char __pyx_doc_9csamtools_14IteratorColumn_addReference[] = "\n       add reference sequences in *fastafile* to iterator.";
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile) {
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("addReference");
-  __Pyx_TraceCall("addReference", __pyx_f[0], 1489);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1492
- *        '''
- *        add reference sequences in *fastafile* to iterator.'''
- *        self.fastafile = fastafile             # <<<<<<<<<<<<<<
- *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
- *        self.iterdata.tid = -1
+ *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
+ *     cdef int skip = 0             # <<<<<<<<<<<<<<
+ *     cdef int q
+ *     cdef int is_cns = 1
  */
-  __Pyx_INCREF(__pyx_v_fastafile);
-  __Pyx_GIVEREF(__pyx_v_fastafile);
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
-  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_fastafile);
+  __pyx_v_skip = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1493
- *        add reference sequences in *fastafile* to iterator.'''
- *        self.fastafile = fastafile
- *        if self.iterdata.seq != NULL: free(self.iterdata.seq)             # <<<<<<<<<<<<<<
- *        self.iterdata.tid = -1
- *        self.iterdata.fastafile = self.fastafile.fastafile
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1503
+ *     cdef int skip = 0
+ *     cdef int q
+ *     cdef int is_cns = 1             # <<<<<<<<<<<<<<
+ *     cdef int is_nobaq = 0
+ *     cdef int capQ_thres = 0
  */
-  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
-  if (__pyx_t_1) {
-    free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
+  __pyx_v_is_cns = 1;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1494
- *        self.fastafile = fastafile
- *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
- *        self.iterdata.tid = -1             # <<<<<<<<<<<<<<
- *        self.iterdata.fastafile = self.fastafile.fastafile
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1504
+ *     cdef int q
+ *     cdef int is_cns = 1
+ *     cdef int is_nobaq = 0             # <<<<<<<<<<<<<<
+ *     cdef int capQ_thres = 0
  * 
  */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.tid = -1;
+  __pyx_v_is_nobaq = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1495
- *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
- *        self.iterdata.tid = -1
- *        self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1505
+ *     cdef int is_cns = 1
+ *     cdef int is_nobaq = 0
+ *     cdef int capQ_thres = 0             # <<<<<<<<<<<<<<
  * 
- *     def hasReference( self ):
+ *     # reload sequence
  */
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.fastafile = ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile->fastafile;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.IteratorColumn.addReference");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  __pyx_v_capQ_thres = 0;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1497
- *        self.iterdata.fastafile = self.fastafile.fastafile
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1508
  * 
- *     def hasReference( self ):             # <<<<<<<<<<<<<<
- *         '''
- *         return true if iterator is associated with a reference'''
+ *     # reload sequence
+ *     if d.fastafile != NULL and b.core.tid != d.tid:             # <<<<<<<<<<<<<<
+ *         if d.seq != NULL: free(d.seq)
+ *         d.tid = b.core.tid
  */
+  __pyx_t_1 = (__pyx_v_d->fastafile != NULL);
+  if (__pyx_t_1) {
+    __pyx_t_2 = (__pyx_v_b->core.tid != __pyx_v_d->tid);
+    __pyx_t_3 = __pyx_t_2;
+  } else {
+    __pyx_t_3 = __pyx_t_1;
+  }
+  if (__pyx_t_3) {
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_14IteratorColumn_hasReference[] = "\n        return true if iterator is associated with a reference";
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  PyObject *__pyx_r = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("hasReference");
-  __Pyx_TraceCall("hasReference", __pyx_f[0], 1497);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1500
- *         '''
- *         return true if iterator is associated with a reference'''
- *         return self.fastafile             # <<<<<<<<<<<<<<
- * 
- *     cdef setMask( self, mask ):
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1509
+ *     # reload sequence
+ *     if d.fastafile != NULL and b.core.tid != d.tid:
+ *         if d.seq != NULL: free(d.seq)             # <<<<<<<<<<<<<<
+ *         d.tid = b.core.tid
+ *         d.seq = faidx_fetch_seq(d.fastafile,
  */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
-  __pyx_r = ((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
-  goto __pyx_L0;
+    __pyx_t_3 = (__pyx_v_d->seq != NULL);
+    if (__pyx_t_3) {
+      free(__pyx_v_d->seq);
+      goto __pyx_L4;
+    }
+    __pyx_L4:;
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1510
+ *     if d.fastafile != NULL and b.core.tid != d.tid:
+ *         if d.seq != NULL: free(d.seq)
+ *         d.tid = b.core.tid             # <<<<<<<<<<<<<<
+ *         d.seq = faidx_fetch_seq(d.fastafile,
+ *                                 d.samfile.header.target_name[d.tid],
+ */
+    __pyx_v_d->tid = __pyx_v_b->core.tid;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1502
- *         return self.fastafile
- * 
- *     cdef setMask( self, mask ):             # <<<<<<<<<<<<<<
- *         '''set masking flag in iterator.
- * 
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1511
+ *         if d.seq != NULL: free(d.seq)
+ *         d.tid = b.core.tid
+ *         d.seq = faidx_fetch_seq(d.fastafile,             # <<<<<<<<<<<<<<
+ *                                 d.samfile.header.target_name[d.tid],
+ *                                 0, max_pos,
  */
+    __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_9csamtools_max_pos, (&__pyx_v_d->seq_len));
 
-static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setMask(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, PyObject *__pyx_v_mask) {
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("setMask");
-  __Pyx_TraceCall("setMask", __pyx_f[0], 1502);
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1515
+ *                                 0, max_pos,
+ *                                 &d.seq_len)
+ *         if d.seq == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
+ *                                   (d.samfile.header.target_name[d.tid],
+ */
+    __pyx_t_3 = (__pyx_v_d->seq == NULL);
+    if (__pyx_t_3) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1507
- *         reads with bits set in *mask* will be skipped.
- *         '''
- *         self.mask = mask             # <<<<<<<<<<<<<<
- *         bam_plp_set_mask( self.pileup_iter, self.mask )
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1517
+ *         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_1 = __Pyx_PyInt_AsInt(__pyx_v_mask); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_self->mask = __pyx_t_1;
+      __pyx_t_4 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1508
- *         '''
- *         self.mask = mask
- *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1518
+ *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
+ *                                   (d.samfile.header.target_name[d.tid],
+ *                                    d.tid))             # <<<<<<<<<<<<<<
+ * 
  * 
- *     cdef setupIteratorData( self,
  */
-  bam_plp_set_mask(__pyx_v_self->pileup_iter, __pyx_v_self->mask);
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.IteratorColumn.setMask");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+      __pyx_t_5 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_5);
+      __pyx_t_4 = 0;
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_56), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+      __Pyx_DECREF(__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 = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L5;
+    }
+    __pyx_L5:;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1521
+ * 
+ * 
+ *     while ret >= 0:             # <<<<<<<<<<<<<<
+ * 
+ *         skip = 0
+ */
+  while (1) {
+    __pyx_t_3 = (__pyx_v_ret >= 0);
+    if (!__pyx_t_3) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1523
+ *     while ret >= 0:
+ * 
+ *         skip = 0             # <<<<<<<<<<<<<<
+ * 
+ *         # realign read - changes base qualities
+ */
+    __pyx_v_skip = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1526
+ * 
+ *         # realign read - changes base qualities
+ *         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:
+ */
+    __pyx_t_3 = (__pyx_v_d->seq != NULL);
+    if (__pyx_t_3) {
+      if (__pyx_v_is_cns) {
+        __pyx_t_1 = (!__pyx_v_is_nobaq);
+        __pyx_t_2 = __pyx_t_1;
+      } else {
+        __pyx_t_2 = __pyx_v_is_cns;
+      }
+      __pyx_t_1 = __pyx_t_2;
+    } else {
+      __pyx_t_1 = __pyx_t_3;
+    }
+    if (__pyx_t_1) {
+      bam_prob_realn(__pyx_v_b, __pyx_v_d->seq);
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1528
+ *         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:             # <<<<<<<<<<<<<<
+ *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
+ *             if q < 0: skip = 1
+ */
+    __pyx_t_1 = (__pyx_v_d->seq != NULL);
+    if (__pyx_t_1) {
+      __pyx_t_3 = (__pyx_v_capQ_thres > 10);
+      __pyx_t_2 = __pyx_t_3;
+    } else {
+      __pyx_t_2 = __pyx_t_1;
+    }
+    if (__pyx_t_2) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1529
+ * 
+ *         if d.seq != NULL and capQ_thres > 10:
+ *             q = bam_cap_mapQ(b, d.seq, capQ_thres)             # <<<<<<<<<<<<<<
+ *             if q < 0: skip = 1
+ *             elif b.core.qual > q: b.core.qual = q
+ */
+      __pyx_v_q = bam_cap_mapQ(__pyx_v_b, __pyx_v_d->seq, __pyx_v_capQ_thres);
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1530
+ *         if d.seq != NULL and capQ_thres > 10:
+ *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
+ *             if q < 0: skip = 1             # <<<<<<<<<<<<<<
+ *             elif b.core.qual > q: b.core.qual = q
+ *         if b.core.flag & BAM_FUNMAP: skip = 1
+ */
+      __pyx_t_2 = (__pyx_v_q < 0);
+      if (__pyx_t_2) {
+        __pyx_v_skip = 1;
+        goto __pyx_L10;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1531
+ *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
+ *             if q < 0: skip = 1
+ *             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
+ */
+      __pyx_t_2 = (__pyx_v_b->core.qual > __pyx_v_q);
+      if (__pyx_t_2) {
+        __pyx_v_b->core.qual = __pyx_v_q;
+        goto __pyx_L10;
+      }
+      __pyx_L10:;
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1532
+ *             if q < 0: skip = 1
+ *             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
+ * 
+ */
+    __pyx_t_7 = (__pyx_v_b->core.flag & 4);
+    if (__pyx_t_7) {
+      __pyx_v_skip = 1;
+      goto __pyx_L11;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1533
+ *             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             # <<<<<<<<<<<<<<
+ * 
+ *         if not skip: break
+ */
+    if ((__pyx_v_b->core.flag & 1)) {
+      __pyx_t_2 = (!(__pyx_v_b->core.flag & 2));
+      __pyx_t_1 = __pyx_t_2;
+    } else {
+      __pyx_t_1 = (__pyx_v_b->core.flag & 1);
+    }
+    if (__pyx_t_1) {
+      __pyx_v_skip = 1;
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1535
+ *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
+ * 
+ *         if not skip: break             # <<<<<<<<<<<<<<
+ *         # additional filters
+ * 
+ */
+    __pyx_t_1 = (!__pyx_v_skip);
+    if (__pyx_t_1) {
+      goto __pyx_L7_break;
+      goto __pyx_L12;
+    }
+    __pyx_L12:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1538
+ *         # additional filters
+ * 
+ *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
+ * 
+ *     return ret
+ */
+    __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
+  }
+  __pyx_L7_break:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1540
+ *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
+ * 
+ *     return ret             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IteratorColumn:
+ */
+  __pyx_r = __pyx_v_ret;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_WriteUnraisable("csamtools.__advance_snpcalls");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1599
+ *     cdef stepper
+ * 
+ *     def __cinit__( self, Samfile samfile, **kwargs ):             # <<<<<<<<<<<<<<
+ *         self.samfile = samfile
+ *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
+ */
+
+static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1599);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
+  }
+  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 = 1599; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1600
+ * 
+ *     def __cinit__( self, Samfile samfile, **kwargs ):
+ *         self.samfile = samfile             # <<<<<<<<<<<<<<
+ *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
+ *         self.fastafile = kwargs.get( "fastafile", None )
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile));
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile = __pyx_v_samfile;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1601
+ *     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 )
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __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 = 1601; __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 = 1601; __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 = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->mask = __pyx_t_3;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1602
+ *         self.samfile = samfile
+ *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
+ *         self.fastafile = kwargs.get( "fastafile", None )             # <<<<<<<<<<<<<<
+ *         self.stepper = kwargs.get( "stepper", None )
+ *         self.iterdata.seq = NULL
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __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 = 1602; __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_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1603
+ *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
+ *         self.fastafile = kwargs.get( "fastafile", None )
+ *         self.stepper = kwargs.get( "stepper", None )             # <<<<<<<<<<<<<<
+ *         self.iterdata.seq = NULL
+ *         self.tid = 0
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __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 = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
+  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1604
+ *         self.fastafile = kwargs.get( "fastafile", None )
+ *         self.stepper = kwargs.get( "stepper", None )
+ *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
+ *         self.tid = 0
+ *         self.pos = 0
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1605
+ *         self.stepper = kwargs.get( "stepper", None )
+ *         self.iterdata.seq = NULL
+ *         self.tid = 0             # <<<<<<<<<<<<<<
+ *         self.pos = 0
+ *         self.n_plp = 0
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->tid = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1606
+ *         self.iterdata.seq = NULL
+ *         self.tid = 0
+ *         self.pos = 0             # <<<<<<<<<<<<<<
+ *         self.n_plp = 0
+ *         self.plp = NULL
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pos = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1607
+ *         self.tid = 0
+ *         self.pos = 0
+ *         self.n_plp = 0             # <<<<<<<<<<<<<<
+ *         self.plp = NULL
+ *         self.pileup_iter = <bam_plp_t>NULL
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->n_plp = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1608
+ *         self.pos = 0
+ *         self.n_plp = 0
+ *         self.plp = NULL             # <<<<<<<<<<<<<<
+ *         self.pileup_iter = <bam_plp_t>NULL
+ * 
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->plp = NULL;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1609
+ *         self.n_plp = 0
+ *         self.plp = NULL
+ *         self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
+ * 
+ *     def __iter__(self):
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL);
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1611
+ *         self.pileup_iter = <bam_plp_t>NULL
+ * 
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__iter__");
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1611);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1612
+ * 
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int cnext(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1614
+ *         return self
+ * 
+ *     cdef int cnext(self):             # <<<<<<<<<<<<<<
+ *         '''perform next iteration.
+ * 
+ */
+
+static  int __pyx_f_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("cnext");
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1614);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1620
+ *         It has been re-implemented to permit for filtering.
+ *         '''
+ *         self.plp = bam_plp_auto( self.pileup_iter,             # <<<<<<<<<<<<<<
+ *                                  &self.tid,
+ *                                  &self.pos,
+ */
+  __pyx_v_self->plp = bam_plp_auto(__pyx_v_self->pileup_iter, (&__pyx_v_self->tid), (&__pyx_v_self->pos), (&__pyx_v_self->n_plp));
+
+  __pyx_r = 0;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1625
+ *                                  &self.n_plp )
+ * 
+ *     cdef char * getSequence( self ):             # <<<<<<<<<<<<<<
+ *         '''return current reference sequence underlying the iterator.
+ *         '''
+ */
+
+static  char *__pyx_f_9csamtools_14IteratorColumn_getSequence(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
+  char *__pyx_r;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("getSequence");
+  __Pyx_TraceCall("getSequence", __pyx_f[0], 1625);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1628
+ *         '''return current reference sequence underlying the iterator.
+ *         '''
+ *         return self.iterdata.seq             # <<<<<<<<<<<<<<
+ * 
+ *     property seq_len:
+ */
+  __pyx_r = __pyx_v_self->iterdata.seq;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1632
+ *     property seq_len:
+ *         '''current sequence length.'''
+ *         def __get__(self): return self.iterdata.seq_len             # <<<<<<<<<<<<<<
+ * 
+ *     def addReference( self, Fastafile fastafile ):
+ */
+
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1632);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __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("csamtools.IteratorColumn.seq_len.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1510
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1634
+ *         def __get__(self): return self.iterdata.seq_len
+ * 
+ *     def addReference( self, Fastafile fastafile ):             # <<<<<<<<<<<<<<
+ *        '''
+ *        add reference sequences in *fastafile* to iterator.'''
+ */
+
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile); /*proto*/
+static char __pyx_doc_9csamtools_14IteratorColumn_addReference[] = "IteratorColumn.addReference(self, Fastafile fastafile)\n\n       add reference sequences in *fastafile* to iterator.";
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("addReference");
+  __Pyx_TraceCall("addReference", __pyx_f[0], 1634);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1637
+ *        '''
+ *        add reference sequences in *fastafile* to iterator.'''
+ *        self.fastafile = fastafile             # <<<<<<<<<<<<<<
+ *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
+ *        self.iterdata.tid = -1
+ */
+  __Pyx_INCREF(__pyx_v_fastafile);
+  __Pyx_GIVEREF(__pyx_v_fastafile);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_fastafile);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1638
+ *        add reference sequences in *fastafile* to iterator.'''
+ *        self.fastafile = fastafile
+ *        if self.iterdata.seq != NULL: free(self.iterdata.seq)             # <<<<<<<<<<<<<<
+ *        self.iterdata.tid = -1
+ *        self.iterdata.fastafile = self.fastafile.fastafile
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
+  if (__pyx_t_1) {
+    free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1639
+ *        self.fastafile = fastafile
+ *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
+ *        self.iterdata.tid = -1             # <<<<<<<<<<<<<<
+ *        self.iterdata.fastafile = self.fastafile.fastafile
+ * 
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.tid = -1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1640
+ *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
+ *        self.iterdata.tid = -1
+ *        self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
+ * 
+ *     def hasReference( self ):
+ */
+  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.fastafile = ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile->fastafile;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IteratorColumn.addReference");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1642
+ *        self.iterdata.fastafile = self.fastafile.fastafile
+ * 
+ *     def hasReference( self ):             # <<<<<<<<<<<<<<
+ *         '''
+ *         return true if iterator is associated with a reference'''
+ */
+
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_14IteratorColumn_hasReference[] = "IteratorColumn.hasReference(self)\n\n        return true if iterator is associated with a reference";
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("hasReference");
+  __Pyx_TraceCall("hasReference", __pyx_f[0], 1642);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1645
+ *         '''
+ *         return true if iterator is associated with a reference'''
+ *         return self.fastafile             # <<<<<<<<<<<<<<
+ * 
+ *     cdef setMask( self, mask ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
+  __pyx_r = ((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1647
+ *         return self.fastafile
+ * 
+ *     cdef setMask( self, mask ):             # <<<<<<<<<<<<<<
+ *         '''set masking flag in iterator.
+ * 
+ */
+
+static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setMask(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, PyObject *__pyx_v_mask) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("setMask");
+  __Pyx_TraceCall("setMask", __pyx_f[0], 1647);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1652
+ *         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 = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->mask = __pyx_t_1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1653
+ *         '''
+ *         self.mask = mask
+ *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
+ * 
+ *     cdef setupIteratorData( self,
+ */
+  bam_plp_set_mask(__pyx_v_self->pileup_iter, __pyx_v_self->mask);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IteratorColumn.setMask");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -14360,29 +15956,29 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setupIteratorData");
-  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1510);
+  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1655);
   if (__pyx_optional_args) {
     if (__pyx_optional_args->__pyx_n > 0) {
       __pyx_v_reopen = __pyx_optional_args->reopen;
     }
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1517
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1662
  *         '''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 = 1517; __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 = 1662; __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 = 1517; __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 = 1662; __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 = 1517; __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 = 1662; __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 = 1517; __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 = 1662; __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 = 1517; __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 = 1662; __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));
@@ -14399,7 +15995,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_GIVEREF(__pyx_t_4);
@@ -14408,7 +16004,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1518
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1663
  * 
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile             # <<<<<<<<<<<<<<
@@ -14417,7 +16013,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.samfile = __pyx_v_self->samfile->samfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1519
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1664
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -14426,7 +16022,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1520
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1665
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -14435,7 +16031,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.seq = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1521
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1666
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL
  *         self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -14444,20 +16040,20 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.tid = -1;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1523
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1668
  *         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); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_self->fastafile), Py_None, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1524
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1669
  * 
  *         if self.fastafile != None:
  *             self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
@@ -14469,7 +16065,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1526
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1671
  *             self.iterdata.fastafile = self.fastafile.fastafile
  *         else:
  *             self.iterdata.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -14480,21 +16076,21 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1528
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1673
  *             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); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, Py_None, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (!__pyx_t_6) {
-    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_t_8 = __pyx_t_7;
   } else {
@@ -14502,7 +16098,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   if (__pyx_t_8) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1529
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1674
  * 
  *         if self.stepper == None or self.stepper == "all":
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -14513,20 +16109,20 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
     goto __pyx_L4;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1530
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1675
  *         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); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__samtools), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __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 = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_8) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1531
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1676
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -14538,30 +16134,30 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1533
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1678
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
  *         else:
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)             # <<<<<<<<<<<<<<
  * 
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_57), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __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 = 1533; __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 = 1678; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L4:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1535
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1680
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)
  * 
  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
@@ -14587,7 +16183,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1537
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1682
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef reset( self, tid, start, end ):             # <<<<<<<<<<<<<<
@@ -14603,16 +16199,16 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("reset");
-  __Pyx_TraceCall("reset", __pyx_f[0], 1537);
+  __Pyx_TraceCall("reset", __pyx_f[0], 1682);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1543
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1688
  *         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 = 1543; __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 = 1688; __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));
@@ -14626,10 +16222,10 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   __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 = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __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 = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __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 = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __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;
@@ -14639,7 +16235,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1544
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1689
  *         '''
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -14648,23 +16244,23 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
  */
   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1547
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1692
  * 
  *         # 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 = 1547; __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 = 1692; __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); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_tid, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1547; __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 = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1548
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1693
  *         # invalidate sequence if different tid
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )             # <<<<<<<<<<<<<<
@@ -14678,7 +16274,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
     }
     __pyx_L4:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1549
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1694
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -14687,7 +16283,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
  */
     __pyx_v_self->iterdata.seq = NULL;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1550
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1695
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL
  *             self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -14699,7 +16295,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1553
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1698
  * 
  *         # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata )
  *         bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -14723,7 +16319,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1555
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1700
  *         bam_plp_reset(self.pileup_iter)
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -14736,9 +16332,9 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1555);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1700);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1558
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1703
  *         # reset in order to avoid memory leak messages for iterators that have
  *         # not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:             # <<<<<<<<<<<<<<
@@ -14748,7 +16344,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter != ((bam_plp_t)NULL));
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1559
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1704
  *         # not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -14757,7 +16353,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
  */
     bam_plp_reset(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1560
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1705
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -14766,7 +16362,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
  */
     bam_plp_destroy(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1561
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1706
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)
  *             self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
@@ -14778,7 +16374,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1563
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1708
  *             self.pileup_iter = <bam_plp_t>NULL
  * 
  *         if self.iterdata.seq != NULL:             # <<<<<<<<<<<<<<
@@ -14788,7 +16384,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1564
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1709
  * 
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)             # <<<<<<<<<<<<<<
@@ -14797,7 +16393,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
  */
     free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1565
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1710
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -14813,7 +16409,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_s
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1570
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1715
  *     '''iterates over a region only.
  *     '''
  *     def __cinit__(self, Samfile samfile,             # <<<<<<<<<<<<<<
@@ -14834,7 +16430,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1570);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1715);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -14870,32 +16466,32 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_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 = 1571; __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 = 1716; __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 = 1572; __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 = 1717; __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 = 1573; __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 = 1718; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
-      __pyx_v_end = __pyx_k_55;
+      __pyx_v_end = __pyx_k_58;
     }
   } else {
     __pyx_v_tid = ((int)0);
     __pyx_v_start = ((int)0);
-    __pyx_v_end = __pyx_k_55;
+    __pyx_v_end = __pyx_k_58;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  4: __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  3: __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  2: __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  4: __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  3: __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -14903,16 +16499,16 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1577
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1722
  * 
  *         # initialize iterator
  *         self.setupIteratorData( tid, start, end, 1 )             # <<<<<<<<<<<<<<
@@ -14921,7 +16517,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
  */
   __pyx_t_2.__pyx_n = 1;
   __pyx_t_2.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_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 = 1577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_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 = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
@@ -14938,7 +16534,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1579
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1724
  *         self.setupIteratorData( tid, start, end, 1 )
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -14956,9 +16552,9 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1579);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1724);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1583
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1728
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -14968,7 +16564,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
   while (1) {
     if (!1) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1584
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1729
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -14977,7 +16573,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1585
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1730
  *         while 1:
  *             self.cnext()
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -14987,29 +16583,29 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1586
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1731
  *             self.cnext()
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             if self.plp == NULL:
  */
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1586; __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 = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_56));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_3, 0, 0);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1588
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1733
  *                 raise ValueError("error during iteration" )
  * 
  *             if self.plp == NULL:             # <<<<<<<<<<<<<<
@@ -15019,7 +16615,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp == NULL);
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1589
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1734
  * 
  *             if self.plp == NULL:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -15027,12 +16623,12 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
  *             return makePileupProxy( <bam_pileup1_t*>self.plp,
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1591
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1736
  *                 raise StopIteration
  * 
  *             return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
@@ -15041,14 +16637,14 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
  */
     __Pyx_XDECREF(__pyx_r);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1594
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1739
  *                                      self.tid,
  *                                      self.pos,
  *                                      self.n_plp )             # <<<<<<<<<<<<<<
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):
  */
-    __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -15069,7 +16665,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1600
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1745
  *     """
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -15089,7 +16685,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1600);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1745);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -15107,7 +16703,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -15117,35 +16713,35 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   }
   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 = 1600; __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 = 1745; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1605
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1750
  * 
  *         # 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 = 1605; __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 = 1750; __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 = 1605; __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 = 1750; __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);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1608
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1753
  * 
  *         # initialize iterator
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )             # <<<<<<<<<<<<<<
@@ -15154,7 +16750,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
  */
   __pyx_t_4.__pyx_n = 1;
   __pyx_t_4.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
@@ -15171,7 +16767,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1610
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1755
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -15191,9 +16787,9 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
   struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1610);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1755);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1614
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1759
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -15203,7 +16799,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
   while (1) {
     if (!1) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1615
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1760
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -15212,7 +16808,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1617
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1762
  *             self.cnext()
  * 
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -15222,29 +16818,29 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1618
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1763
  * 
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             # return result, if within same reference
  */
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1618; __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 = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_56));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_3, 0, 0);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1621
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1766
  * 
  *             # return result, if within same reference
  *             if self.plp != NULL:             # <<<<<<<<<<<<<<
@@ -15254,7 +16850,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp != NULL);
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1622
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1767
  *             # return result, if within same reference
  *             if self.plp != NULL:
  *                 return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
@@ -15263,14 +16859,14 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1625
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1770
  *                                          self.tid,
  *                                          self.pos,
  *                                          self.n_plp )             # <<<<<<<<<<<<<<
  * 
  *             # otherwise, proceed to next reference or stop
  */
-      __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __pyx_r = __pyx_t_3;
       __pyx_t_3 = 0;
@@ -15279,7 +16875,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1628
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1773
  * 
  *             # otherwise, proceed to next reference or stop
  *             self.tid += 1             # <<<<<<<<<<<<<<
@@ -15288,26 +16884,26 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
  */
     ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid += 1;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1629
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1774
  *             # 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_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.samfile), __pyx_n_s__nreferences); 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 *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __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 = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1630
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1775
  *             self.tid += 1
  *             if self.tid < self.samfile.nreferences:
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )             # <<<<<<<<<<<<<<
@@ -15316,14 +16912,14 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
  */
       __pyx_t_5.__pyx_n = 1;
       __pyx_t_5.reopen = 0;
-      __pyx_t_4 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_5); 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_4); __pyx_t_4 = 0;
       goto __pyx_L9;
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1632
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1777
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -15331,7 +16927,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
  * ##-------------------------------------------------------------------
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L9:;
   }
@@ -15351,7 +16947,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1637
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1782
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_start(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -15371,9 +16967,9 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_start");
-  __Pyx_TraceCall("query_start", __pyx_f[0], 1637);
+  __Pyx_TraceCall("query_start", __pyx_f[0], 1782);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1640
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1785
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t start_offset = 0             # <<<<<<<<<<<<<<
@@ -15382,7 +16978,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
   __pyx_v_start_offset = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1642
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1787
  *     cdef uint32_t start_offset = 0
  * 
  *     if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -15391,7 +16987,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1643
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1788
  * 
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -15400,7 +16996,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1644
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1789
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -15410,7 +17006,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
     __pyx_t_1 = __pyx_v_src->core.n_cigar;
     for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1645
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1790
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -15419,7 +17015,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1646
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1791
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
@@ -15429,7 +17025,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
       switch (__pyx_v_op) {
         case 5:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1647
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1792
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -15445,16 +17041,16 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
         }
         if (__pyx_t_4) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1648
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1793
  *             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_57);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1649
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1794
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -15468,7 +17064,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
         __pyx_L6:;
         break;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1650
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1795
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -15477,7 +17073,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
         case 4:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1651
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1796
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
@@ -15488,7 +17084,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
         break;
         default:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1653
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1798
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -15504,7 +17100,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1655
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1800
  *                 break
  * 
  *     return start_offset             # <<<<<<<<<<<<<<
@@ -15521,7 +17117,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1660
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1805
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_end(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -15540,9 +17136,9 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_end");
-  __Pyx_TraceCall("query_end", __pyx_f[0], 1660);
+  __Pyx_TraceCall("query_end", __pyx_f[0], 1805);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1663
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1808
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -15551,7 +17147,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
   __pyx_v_end_offset = __pyx_v_src->core.l_qseq;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1665
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1810
  *     cdef uint32_t end_offset = src.core.l_qseq
  * 
  *     if src.core.n_cigar>1:             # <<<<<<<<<<<<<<
@@ -15561,7 +17157,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   __pyx_t_1 = (__pyx_v_src->core.n_cigar > 1);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1666
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1811
  * 
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -15570,7 +17166,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1667
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1812
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:             # <<<<<<<<<<<<<<
@@ -15579,7 +17175,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
     for (__pyx_v_k = __pyx_v_src->core.n_cigar-1; __pyx_v_k >= 1; __pyx_v_k--) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1668
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1813
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -15588,7 +17184,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1669
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1814
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
@@ -15598,7 +17194,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
       switch (__pyx_v_op) {
         case 5:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1670
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1815
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -15614,16 +17210,16 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
         }
         if (__pyx_t_3) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1671
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1816
  *             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_57);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1672
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1817
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -15637,7 +17233,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
         __pyx_L6:;
         break;
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1673
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1818
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -15646,7 +17242,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
         case 4:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1674
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1819
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
@@ -15657,7 +17253,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
         break;
         default:
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1676
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1821
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -15673,7 +17269,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1678
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1823
  *                 break
  * 
  *     if end_offset==0:             # <<<<<<<<<<<<<<
@@ -15683,7 +17279,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   __pyx_t_3 = (__pyx_v_end_offset == 0);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1679
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1824
  * 
  *     if end_offset==0:
  *         end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -15695,7 +17291,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1681
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1826
  *         end_offset = src.core.l_qseq
  * 
  *     return end_offset             # <<<<<<<<<<<<<<
@@ -15712,7 +17308,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1684
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1829
  * 
  * 
  * cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -15731,10 +17327,10 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   uint32_t __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_seq_range");
-  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1684);
+  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1829);
   __pyx_v_seq = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1689
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1834
  *     cdef char * s
  * 
  *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -15744,7 +17340,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   __pyx_t_1 = (!__pyx_v_src->core.l_qseq);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1690
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1835
  * 
  *     if not src.core.l_qseq:
  *         return None             # <<<<<<<<<<<<<<
@@ -15759,20 +17355,20 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1692
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1837
  *         return None
  * 
  *     seq = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
  *     s   = PyString_AS_STRING(seq)
  *     p   = bam1_seq(src)
  */
-  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_v_seq);
   __pyx_v_seq = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1693
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1838
  * 
  *     seq = PyString_FromStringAndSize(NULL, end-start)
  *     s   = PyString_AS_STRING(seq)             # <<<<<<<<<<<<<<
@@ -15781,7 +17377,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
  */
   __pyx_v_s = PyString_AS_STRING(__pyx_v_seq);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1694
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1839
  *     seq = PyString_FromStringAndSize(NULL, end-start)
  *     s   = PyString_AS_STRING(seq)
  *     p   = bam1_seq(src)             # <<<<<<<<<<<<<<
@@ -15790,7 +17386,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1696
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1841
  *     p   = bam1_seq(src)
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -15800,7 +17396,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   __pyx_t_3 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1699
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1844
  *         # 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]             # <<<<<<<<<<<<<<
@@ -15810,7 +17406,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
     (__pyx_v_s[(__pyx_v_k - __pyx_v_start)]) = (__pyx_v_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)]);
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1701
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1846
  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]
  * 
  *     return seq             # <<<<<<<<<<<<<<
@@ -15836,7 +17432,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1704
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1849
  * 
  * 
  * cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -15855,10 +17451,10 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   uint32_t __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_qual_range");
-  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1704);
+  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1849);
   __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1709
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1854
  *     cdef char * q
  * 
  *     p = bam1_qual(src)             # <<<<<<<<<<<<<<
@@ -15867,7 +17463,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1710
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1855
  * 
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:             # <<<<<<<<<<<<<<
@@ -15877,7 +17473,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   __pyx_t_1 = ((__pyx_v_p[0]) == 0xff);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1711
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1856
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:
  *         return None             # <<<<<<<<<<<<<<
@@ -15892,20 +17488,20 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   }
   __pyx_L3:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1713
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1858
  *         return None
  * 
  *     qual = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
  *     q    = PyString_AS_STRING(qual)
  * 
  */
-  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1714
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1859
  * 
  *     qual = PyString_FromStringAndSize(NULL, end-start)
  *     q    = PyString_AS_STRING(qual)             # <<<<<<<<<<<<<<
@@ -15914,7 +17510,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
  */
   __pyx_v_q = PyString_AS_STRING(__pyx_v_qual);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1716
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1861
  *     q    = PyString_AS_STRING(qual)
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -15924,7 +17520,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   __pyx_t_3 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1718
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1863
  *     for k from start <= k < end:
  *         ## equivalent to t[i] + 33 (see bam.c)
  *         q[k-start] = p[k] + 33             # <<<<<<<<<<<<<<
@@ -15934,7 +17530,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
     (__pyx_v_q[(__pyx_v_k - __pyx_v_start)]) = ((__pyx_v_p[__pyx_v_k]) + 33);
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1720
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1865
  *         q[k-start] = p[k] + 33
  * 
  *     return qual             # <<<<<<<<<<<<<<
@@ -15960,7 +17556,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1746
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1890
  * 
  *     # Now only called when instances are created from Python
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -15973,12 +17569,12 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 1746);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 1890);
   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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1748
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1892
  *     def __init__(self):
  *         # see bam_init1
  *         self._delegate = <bam1_t*>calloc( 1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
@@ -15987,7 +17583,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1752
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1896
  *         # 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             # <<<<<<<<<<<<<<
@@ -15996,7 +17592,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data = 40;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1753
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1897
  *         # so allocate 40 bytes for a new read
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )             # <<<<<<<<<<<<<<
@@ -16005,7 +17601,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->data = ((uint8_t *)calloc(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data, 1));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1754
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1898
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )
  *         self._delegate.data_len = 0             # <<<<<<<<<<<<<<
@@ -16020,7 +17616,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1756
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1900
  *         self._delegate.data_len = 0
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -16032,9 +17628,9 @@ static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self
 static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1756);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1900);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1757
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1901
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self._delegate)             # <<<<<<<<<<<<<<
@@ -16047,16 +17643,16 @@ static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1759
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1903
  *         bam_destroy1(self._delegate)
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
- *         """todo"""
- *         return "\t".join(map(str, (self.qname,
+ *         """return string representation of alignment.
+ * 
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead___str__[] = "todo";
+static char __pyx_doc_9csamtools_11AlignedRead___str__[] = "return string representation of alignment.\n\n        The representation is an approximate :term:`sam` format.\n\n        An aligned read might not be associated with a :term:`Samfile`.\n        As a result :term:`tid` is shown instead of the reference name.\n\n        Similarly, the tags field is returned in its parsed state.\n        ";
 struct wrapperbase __pyx_wrapperbase_9csamtools_11AlignedRead___str__;
 static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
@@ -16071,122 +17667,161 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_9 = NULL;
   PyObject *__pyx_t_10 = NULL;
   PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 1759);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 1903);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1761
- *     def __str__(self):
- *         """todo"""
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1915
+ *         # sam-parsing is done in sam.c/bam_format1_core which
+ *         # requires a valid header.
  *         return "\t".join(map(str, (self.qname,             # <<<<<<<<<<<<<<
+ *                                    self.flag,
  *                                    self.rname,
- *                                    self.pos,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1762
- *         """todo"""
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1916
+ *         # requires a valid header.
  *         return "\t".join(map(str, (self.qname,
- *                                    self.rname,             # <<<<<<<<<<<<<<
+ *                                    self.flag,             # <<<<<<<<<<<<<<
+ *                                    self.rname,
  *                                    self.pos,
- *                                    self.cigar,
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1763
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1917
  *         return "\t".join(map(str, (self.qname,
- *                                    self.rname,
- *                                    self.pos,             # <<<<<<<<<<<<<<
- *                                    self.cigar,
- *                                    self.qual,
+ *                                    self.flag,
+ *                                    self.rname,             # <<<<<<<<<<<<<<
+ *                                    self.pos,
+ *                                    self.mapq,
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1764
- *                                    self.rname,
- *                                    self.pos,
- *                                    self.cigar,             # <<<<<<<<<<<<<<
- *                                    self.qual,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1918
  *                                    self.flag,
+ *                                    self.rname,
+ *                                    self.pos,             # <<<<<<<<<<<<<<
+ *                                    self.mapq,
+ *                                    self.cigar,
  */
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__cigar); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1765
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1919
+ *                                    self.rname,
  *                                    self.pos,
+ *                                    self.mapq,             # <<<<<<<<<<<<<<
  *                                    self.cigar,
- *                                    self.qual,             # <<<<<<<<<<<<<<
- *                                    self.flag,
- *                                    self.seq,
+ *                                    self.mrnm,
  */
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qual); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapq); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1766
- *                                    self.cigar,
- *                                    self.qual,
- *                                    self.flag,             # <<<<<<<<<<<<<<
- *                                    self.seq,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1920
+ *                                    self.pos,
  *                                    self.mapq,
+ *                                    self.cigar,             # <<<<<<<<<<<<<<
+ *                                    self.mrnm,
+ *                                    self.mpos,
  */
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__cigar); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1767
- *                                    self.qual,
- *                                    self.flag,
- *                                    self.seq,             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1921
  *                                    self.mapq,
- *                                    self.tags)))
+ *                                    self.cigar,
+ *                                    self.mrnm,             # <<<<<<<<<<<<<<
+ *                                    self.mpos,
+ *                                    self.rlen,
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seq); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mrnm); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1768
- *                                    self.flag,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1922
+ *                                    self.cigar,
+ *                                    self.mrnm,
+ *                                    self.mpos,             # <<<<<<<<<<<<<<
+ *                                    self.rlen,
  *                                    self.seq,
- *                                    self.mapq,             # <<<<<<<<<<<<<<
- *                                    self.tags)))
- * 
  */
-  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapq); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mpos); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1769
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1923
+ *                                    self.mrnm,
+ *                                    self.mpos,
+ *                                    self.rlen,             # <<<<<<<<<<<<<<
  *                                    self.seq,
- *                                    self.mapq,
- *                                    self.tags)))             # <<<<<<<<<<<<<<
- * 
- * 
+ *                                    self.qual,
  */
-  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tags); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rlen); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
-  __pyx_t_11 = PyTuple_New(9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1924
+ *                                    self.mpos,
+ *                                    self.rlen,
+ *                                    self.seq,             # <<<<<<<<<<<<<<
+ *                                    self.qual,
+ *                                    self.tags )))
+ */
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seq); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_11);
-  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1925
+ *                                    self.rlen,
+ *                                    self.seq,
+ *                                    self.qual,             # <<<<<<<<<<<<<<
+ *                                    self.tags )))
+ * 
+ */
+  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qual); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1926
+ *                                    self.seq,
+ *                                    self.qual,
+ *                                    self.tags )))             # <<<<<<<<<<<<<<
+ * 
+ *     def compare(self, AlignedRead other):
+ */
+  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tags); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
-  PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
-  PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
   __Pyx_GIVEREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
-  PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
   __Pyx_GIVEREF(__pyx_t_6);
-  PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
   __Pyx_GIVEREF(__pyx_t_7);
-  PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
   __Pyx_GIVEREF(__pyx_t_8);
-  PyTuple_SET_ITEM(__pyx_t_11, 7, __pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
   __Pyx_GIVEREF(__pyx_t_9);
-  PyTuple_SET_ITEM(__pyx_t_11, 8, __pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
   __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
+  __Pyx_GIVEREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
+  __Pyx_GIVEREF(__pyx_t_13);
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
@@ -16196,28 +17831,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_sel
   __pyx_t_8 = 0;
   __pyx_t_9 = 0;
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_11 = 0;
+  __pyx_t_12 = 0;
+  __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
-  PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
-  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
-  __Pyx_GIVEREF(__pyx_t_11);
-  __pyx_t_11 = 0;
-  __pyx_t_11 = PyObject_Call(__pyx_builtin_map, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_11);
-  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_10);
-  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
-  __Pyx_GIVEREF(__pyx_t_11);
-  __pyx_t_11 = 0;
-  __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-  __pyx_r = __pyx_t_11;
-  __pyx_t_11 = 0;
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_r = __pyx_t_14;
+  __pyx_t_14 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -16234,6 +17872,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_sel
   __Pyx_XDECREF(__pyx_t_9);
   __Pyx_XDECREF(__pyx_t_10);
   __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
   __Pyx_AddTraceback("csamtools.AlignedRead.__str__");
   __pyx_r = NULL;
   __pyx_L0:;
@@ -16243,8 +17884,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1772
- * 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1928
+ *                                    self.tags )))
  * 
  *     def compare(self, AlignedRead other):             # <<<<<<<<<<<<<<
  *         '''return -1,0,1, if contents in this are binary <,=,> to *other*'''
@@ -16252,7 +17893,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_sel
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_compare[] = "return -1,0,1, if contents in this are binary <,=,> to *other*";
+static char __pyx_doc_9csamtools_11AlignedRead_compare[] = "AlignedRead.compare(self, AlignedRead other)\nreturn -1,0,1, if contents in this are binary <,=,> to *other*";
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
   int __pyx_v_retval;
   bam1_t *__pyx_v_t;
@@ -16265,10 +17906,10 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("compare");
-  __Pyx_TraceCall("compare", __pyx_f[0], 1772);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("compare", __pyx_f[0], 1928);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1778
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1934
  *         cdef bam1_t *t, *o
  * 
  *         t = self._delegate             # <<<<<<<<<<<<<<
@@ -16277,7 +17918,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  */
   __pyx_v_t = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1779
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1935
  * 
  *         t = self._delegate
  *         o = other._delegate             # <<<<<<<<<<<<<<
@@ -16286,7 +17927,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  */
   __pyx_v_o = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_other)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1791
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1947
  * 
  *         # Fast-path test for object identity
  *         if t==o:             # <<<<<<<<<<<<<<
@@ -16296,7 +17937,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   __pyx_t_1 = (__pyx_v_t == __pyx_v_o);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1792
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1948
  *         # Fast-path test for object identity
  *         if t==o:
  *             return 0             # <<<<<<<<<<<<<<
@@ -16311,7 +17952,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1794
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1950
  *             return 0
  * 
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))             # <<<<<<<<<<<<<<
@@ -16320,7 +17961,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  */
   __pyx_v_retval = memcmp((&__pyx_v_t->core), (&__pyx_v_o->core), (sizeof(bam1_core_t)));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1796
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1952
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))
  * 
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -16329,7 +17970,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  */
   if (__pyx_v_retval) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -16338,18 +17979,18 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1797
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1953
  * 
  *         if retval: return retval
  *         retval = cmp(t.data_len, o.data_len)             # <<<<<<<<<<<<<<
  *         if retval: return retval
  *         return memcmp(t.data, o.data, t.data_len)
  */
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_t->data_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_t->data_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_o->data_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_o->data_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __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 = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -16357,14 +17998,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_retval = __pyx_t_5;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1798
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1954
  *         if retval: return retval
  *         retval = cmp(t.data_len, o.data_len)
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -16373,7 +18014,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  */
   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 = 1798; __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 = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -16382,7 +18023,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1799
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1955
  *         retval = cmp(t.data_len, o.data_len)
  *         if retval: return retval
  *         return memcmp(t.data, o.data, t.data_len)             # <<<<<<<<<<<<<<
@@ -16390,7 +18031,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
  *     # 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 = 1799; __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 = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -16411,7 +18052,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1802
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1958
  * 
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):             # <<<<<<<<<<<<<<
@@ -16424,9 +18065,9 @@ static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self) {
   long __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__hash__");
-  __Pyx_TraceCall("__hash__", __pyx_f[0], 1802);
+  __Pyx_TraceCall("__hash__", __pyx_f[0], 1958);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1803
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1959
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):
  *         return _Py_HashPointer(<void *>self)             # <<<<<<<<<<<<<<
@@ -16444,7 +18085,7 @@ static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1807
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1963
  *     property qname:
  *         """the query name (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -16460,9 +18101,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1807);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1963);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1809
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1965
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -16471,7 +18112,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1810
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1966
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None             # <<<<<<<<<<<<<<
@@ -16488,7 +18129,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1811
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1967
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None
  *             return <char *>bam1_qname( src )             # <<<<<<<<<<<<<<
@@ -16496,7 +18137,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
  *         def __set__(self, qname ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(bam1_qname(__pyx_v_src)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(bam1_qname(__pyx_v_src)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -16515,7 +18156,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1813
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1969
  *             return <char *>bam1_qname( src )
  * 
  *         def __set__(self, qname ):             # <<<<<<<<<<<<<<
@@ -16537,21 +18178,21 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
   char *__pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 1813);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 1969);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1814
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1970
  * 
  *         def __set__(self, qname ):
  *             if qname == None or len(qname) == 0: return             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef int l
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); 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_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __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 = 1970; __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 = 1814; __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 = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -16564,7 +18205,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1819
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1975
  *             cdef char * p
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -16573,7 +18214,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1820
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1976
  * 
  *             src = self._delegate
  *             p = bam1_qname( src )             # <<<<<<<<<<<<<<
@@ -16582,17 +18223,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1823
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1979
  * 
  *             # 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 = 1823; __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 = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = (__pyx_t_3 + 1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1827
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1983
  *                               src.core.l_qname,
  *                               l,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -16601,7 +18242,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->core.l_qname, __pyx_v_l, ((uint8_t *)__pyx_v_p));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1829
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1985
  *                               <uint8_t*>p )
  * 
  *             src.core.l_qname = l             # <<<<<<<<<<<<<<
@@ -16610,7 +18251,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
  */
   __pyx_v_src->core.l_qname = __pyx_v_l;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1833
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1989
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_qname(src)             # <<<<<<<<<<<<<<
@@ -16619,14 +18260,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1835
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1991
  *             p = bam1_qname(src)
  * 
  *             strncpy( p, qname, l )             # <<<<<<<<<<<<<<
  * 
  *     property cigar:
  */
-  __pyx_t_6 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_p, __pyx_t_6, __pyx_v_l);
 
   __pyx_r = 0;
@@ -16641,7 +18282,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1840
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1996
  *         """the :term:`cigar` alignment (None if not present).
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -16664,12 +18305,12 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   PyObject *__pyx_t_4 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1840);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1996);
   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_cigar = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1846
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2002
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -16678,7 +18319,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1847
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2003
  * 
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return None             # <<<<<<<<<<<<<<
@@ -16695,20 +18336,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1849
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2005
  *             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_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1849; __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 = 2005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_DECREF(__pyx_v_cigar);
   __pyx_v_cigar = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1850
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2006
  * 
  *             cigar = []
  *             cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -16717,7 +18358,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1851
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2007
  *             cigar = []
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -16727,40 +18368,40 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   __pyx_t_3 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1852
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2008
  *             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_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_op);
     __pyx_v_op = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1853
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2009
  *             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_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1854
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2010
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))             # <<<<<<<<<<<<<<
  *             return cigar
  * 
  */
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __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 = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_op);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_op);
@@ -16768,13 +18409,13 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
     __Pyx_INCREF(__pyx_v_l);
     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_l);
     __Pyx_GIVEREF(__pyx_v_l);
-    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_cigar, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_cigar, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __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;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1855
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2011
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))
  *             return cigar             # <<<<<<<<<<<<<<
@@ -16803,7 +18444,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1857
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2013
  *             return cigar
  * 
  *         def __set__(self, values ):             # <<<<<<<<<<<<<<
@@ -16831,23 +18472,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
   uint32_t __pyx_t_10;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 1857);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2013);
   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1858
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2014
  * 
  *         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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_values, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __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 = 1858; __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 = 2014; __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 = 1858; __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 = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -16860,7 +18501,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1864
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2020
  *             cdef int k
  * 
  *             k = 0             # <<<<<<<<<<<<<<
@@ -16869,7 +18510,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
  */
   __pyx_v_k = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1866
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2022
  *             k = 0
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -16878,7 +18519,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1869
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2025
  * 
  *             # get location of cigar string
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -16887,16 +18528,16 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1874
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2030
  *             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 = 1874; __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 = 2030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1875
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2031
  *                               src.core.n_cigar * 4,
  *                               len(values) * 4,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -16905,17 +18546,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
  */
   pysam_bam_update(__pyx_v_src, (__pyx_v_src->core.n_cigar * 4), (__pyx_t_3 * 4), ((uint8_t *)__pyx_v_p));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1878
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2034
  * 
  *             # 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 = 1878; __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 = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_src->core.n_cigar = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1882
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2038
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -16924,7 +18565,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1885
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2041
  * 
  *             # insert cigar operations
  *             for op, l in values:             # <<<<<<<<<<<<<<
@@ -16934,7 +18575,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
   if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
     __pyx_t_3 = 0; __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1);
   } 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 = 1885; __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 = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
   }
   for (;;) {
@@ -16947,7 +18588,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
     } else {
       __pyx_t_6 = PyIter_Next(__pyx_t_1);
       if (!__pyx_t_6) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_6);
@@ -16964,14 +18605,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
       __pyx_v_l = __pyx_t_8;
       __pyx_t_8 = 0;
     } else {
-      __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       __Pyx_DECREF(__pyx_v_op);
       __pyx_v_op = __pyx_t_7;
@@ -16981,23 +18622,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
       __pyx_t_8 = 0;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1886
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2042
  *             # insert cigar operations
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op             # <<<<<<<<<<<<<<
  *                 k += 1
  * 
  */
-    __pyx_t_6 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_8 = PyNumber_Or(__pyx_t_6, __pyx_v_op); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyNumber_Or(__pyx_t_6, __pyx_v_op); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_10 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     (__pyx_v_p[__pyx_v_k]) = __pyx_t_10;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1887
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2043
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op
  *                 k += 1             # <<<<<<<<<<<<<<
@@ -17008,7 +18649,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1890
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2046
  * 
  *             ## setting the cigar string also updates the "bin" attribute
  *             src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, p))             # <<<<<<<<<<<<<<
@@ -17035,7 +18676,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1894
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2050
  *     property seq:
  *         """read sequence bases, including :term:`soft clipped` bases (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17051,9 +18692,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1894);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2050);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1897
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2053
  *             cdef bam1_t * src
  *             cdef char * s
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17062,7 +18703,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1899
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2055
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -17079,7 +18720,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1901
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2057
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_seq_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -17087,7 +18728,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
  *         def __set__(self,seq):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -17106,7 +18747,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1903
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2059
  *             return get_seq_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,seq):             # <<<<<<<<<<<<<<
@@ -17133,21 +18774,21 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
   char *__pyx_t_7;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 1903);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2059);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1907
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2063
  *             # if no quality information is present, the first byte says 0xff.
  * 
  *             if seq == None or len(seq) == 0: return             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef uint8_t * p
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __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 = 1907; __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 = 2063; __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 = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -17160,7 +18801,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1913
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2069
  *             cdef int l, k, nbytes_new, nbytes_old
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17169,17 +18810,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1915
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2071
  *             src = self._delegate
  * 
  *             l = len(seq)             # <<<<<<<<<<<<<<
  * 
  *             # 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 = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1919
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2075
  *             # 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             # <<<<<<<<<<<<<<
@@ -17188,7 +18829,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_nbytes_new = (__Pyx_div_long((__pyx_v_l + 1), 2) + __pyx_v_l);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1920
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2076
  *             # 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             # <<<<<<<<<<<<<<
@@ -17197,7 +18838,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_nbytes_old = (__Pyx_div_long((__pyx_v_src->core.l_qseq + 1), 2) + __pyx_v_src->core.l_qseq);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1922
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2078
  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
@@ -17206,7 +18847,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1923
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2079
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )
  *             src.core.l_qseq = l             # <<<<<<<<<<<<<<
@@ -17215,7 +18856,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_src->core.l_qseq = __pyx_v_l;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1928
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2084
  *                               nbytes_old,
  *                               nbytes_new,
  *                               p)             # <<<<<<<<<<<<<<
@@ -17224,7 +18865,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_nbytes_old, __pyx_v_nbytes_new, __pyx_v_p);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1931
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2087
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
@@ -17233,7 +18874,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1932
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2088
  *             # as it might have moved
  *             p = bam1_seq( src )
  *             for k from 0 <= k < nbytes_new: p[k] = 0             # <<<<<<<<<<<<<<
@@ -17245,17 +18886,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
     (__pyx_v_p[__pyx_v_k]) = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1934
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2090
  *             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_7 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_s = __pyx_t_7;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1935
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2091
  *             # convert to C string
  *             s = seq
  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
@@ -17265,7 +18906,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
   __pyx_t_6 = __pyx_v_l;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1936
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2092
  *             s = seq
  *             for k from 0 <= k < l:
  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)             # <<<<<<<<<<<<<<
@@ -17275,7 +18916,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
     (__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) |= (pysam_translate_sequence((__pyx_v_s[__pyx_v_k])) << (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2))));
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1939
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2095
  * 
  *             # erase qualities
  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
@@ -17284,7 +18925,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1940
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2096
  *             # erase qualities
  *             p = bam1_qual( src )
  *             p[0] = 0xff             # <<<<<<<<<<<<<<
@@ -17305,7 +18946,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1945
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2101
  *     property qual:
  *         """read sequence base qualities, including :term:`soft clipped` bases (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17321,9 +18962,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1945);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2101);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1950
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2106
  *             cdef char * q
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17332,7 +18973,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1952
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2108
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -17349,7 +18990,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1954
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2110
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_qual_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -17357,7 +18998,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
  *         def __set__(self,qual):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -17376,7 +19017,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1956
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2112
  *             return get_qual_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,qual):             # <<<<<<<<<<<<<<
@@ -17403,9 +19044,9 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   int __pyx_t_9;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 1956);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2112);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1963
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2119
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17414,7 +19055,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1964
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2120
  * 
  *             src = self._delegate
  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
@@ -17423,19 +19064,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1965
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2121
  *             src = self._delegate
  *             p = bam1_qual( src )
  *             if qual == None or len(qual) == 0:             # <<<<<<<<<<<<<<
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __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 = 1965; __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 = 2121; __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_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -17443,7 +19084,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   }
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1967
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2123
  *             if qual == None or len(qual) == 0:
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff             # <<<<<<<<<<<<<<
@@ -17452,7 +19093,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
  */
     (__pyx_v_p[0]) = 0xff;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1968
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2124
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  *                 return             # <<<<<<<<<<<<<<
@@ -17465,27 +19106,27 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1971
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2127
  *             cdef int l
  *             # convert to C string
  *             q = qual             # <<<<<<<<<<<<<<
  *             l = len(qual)
  *             if src.core.l_qseq != l:
  */
-  __pyx_t_6 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_q = __pyx_t_6;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1972
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2128
  *             # 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_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1973
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2129
  *             q = qual
  *             l = len(qual)
  *             if src.core.l_qseq != l:             # <<<<<<<<<<<<<<
@@ -17495,18 +19136,18 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   __pyx_t_5 = (__pyx_v_src->core.l_qseq != __pyx_v_l);
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1974
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2130
  *             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_1 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_7 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __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 = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
@@ -17514,25 +19155,25 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
     __Pyx_GIVEREF(__pyx_t_7);
     __pyx_t_1 = 0;
     __pyx_t_7 = 0;
-    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_58), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__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 = 1974; __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 = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
     __pyx_t_7 = 0;
-    __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __Pyx_Raise(__pyx_t_7, 0, 0);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1975
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2131
  *             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             # <<<<<<<<<<<<<<
@@ -17542,11 +19183,11 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_src->core.l_qseq == __pyx_v_l))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1976
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2132
  *                 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:             # <<<<<<<<<<<<<<
@@ -17556,7 +19197,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   __pyx_t_9 = __pyx_v_l;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1977
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2133
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:
  *                 p[k] = <uint8_t>q[k] - 33             # <<<<<<<<<<<<<<
@@ -17580,7 +19221,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1989
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2145
  *         were not considered for alignment may have been retained."""
  * 
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17599,9 +19240,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1989);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2145);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1994
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2150
  *             cdef char * s
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17610,7 +19251,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1996
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2152
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -17627,27 +19268,27 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1998
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2154
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1999
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2155
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_seq_range(src, start, end)
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2001
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2157
  *             end   = query_end(src)
  * 
  *             return get_seq_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -17655,7 +19296,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
  *     property qqual:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -17674,7 +19315,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2005
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2161
  *     property qqual:
  *         """aligned query sequence quality values (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17693,9 +19334,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2005);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2161);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2010
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2166
  *             cdef char * q
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17704,7 +19345,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2012
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2168
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -17721,27 +19362,27 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2014
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2170
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2015
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2171
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_qual_range(src, start, end)
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2017
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2173
  *             end   = query_end(src)
  * 
  *             return get_qual_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -17749,7 +19390,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
  *     property qstart:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -17768,7 +19409,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2021
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2177
  *     property qstart:
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17783,9 +19424,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2021);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2177);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2022
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2178
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):
  *             return query_start(self._delegate)             # <<<<<<<<<<<<<<
@@ -17793,8 +19434,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
  *     property qend:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_start(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __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 = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_start(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __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 = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -17813,7 +19454,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2026
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2182
  *     property qend:
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17828,9 +19469,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2026);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2182);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2027
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2183
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):
  *             return query_end(self._delegate)             # <<<<<<<<<<<<<<
@@ -17838,8 +19479,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
  *     property qlen:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_end(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; __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 = 2027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_end(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __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 = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -17858,7 +19499,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2031
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2187
  *     property qlen:
  *         """Length of the aligned query sequence"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17875,9 +19516,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2031);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2187);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2033
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2189
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17886,7 +19527,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2034
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2190
  *             cdef bam1_t * src
  *             src = self._delegate
  *             return query_end(src)-query_start(src)             # <<<<<<<<<<<<<<
@@ -17894,9 +19535,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
  *     property tags:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyInt_to_py_int32_t((__pyx_t_1 - __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_to_py_int32_t((__pyx_t_1 - __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -17915,7 +19556,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2048
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2204
  * 
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -17942,11 +19583,11 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2048);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2204);
   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2055
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2211
  *             cdef char auxtype
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -17955,7 +19596,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2056
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2212
  * 
  *             src = self._delegate
  *             if src.l_aux == 0: return None             # <<<<<<<<<<<<<<
@@ -17972,7 +19613,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2058
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2214
  *             if src.l_aux == 0: return None
  * 
  *             s = bam1_aux( src )             # <<<<<<<<<<<<<<
@@ -17981,20 +19622,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
   __pyx_v_s = bam1_aux(__pyx_v_src);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2059
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2215
  * 
  *             s = bam1_aux( src )
  *             result = []             # <<<<<<<<<<<<<<
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2059; __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 = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
   __pyx_v_result = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2060
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2216
  *             s = bam1_aux( src )
  *             result = []
  *             auxtag[2] = 0             # <<<<<<<<<<<<<<
@@ -18003,7 +19644,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
   (__pyx_v_auxtag[2]) = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2061
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2217
  *             result = []
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):             # <<<<<<<<<<<<<<
@@ -18014,7 +19655,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_s < (__pyx_v_src->data + __pyx_v_src->data_len));
     if (!__pyx_t_1) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2063
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2219
  *             while s < (src.data + src.data_len):
  *                 # get tag
  *                 auxtag[0] = s[0]             # <<<<<<<<<<<<<<
@@ -18023,7 +19664,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     (__pyx_v_auxtag[0]) = (__pyx_v_s[0]);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2064
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2220
  *                 # get tag
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]             # <<<<<<<<<<<<<<
@@ -18032,7 +19673,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     (__pyx_v_auxtag[1]) = (__pyx_v_s[1]);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2065
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2221
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]
  *                 s += 2             # <<<<<<<<<<<<<<
@@ -18041,7 +19682,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     __pyx_v_s += 2;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2066
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2222
  *                 auxtag[1] = s[1]
  *                 s += 2
  *                 auxtype = s[0]             # <<<<<<<<<<<<<<
@@ -18050,7 +19691,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     __pyx_v_auxtype = (__pyx_v_s[0]);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2068
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2224
  *                 auxtype = s[0]
  * 
  *                 if auxtype in ('c', 'C'):             # <<<<<<<<<<<<<<
@@ -18068,20 +19709,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_5;
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2069
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2225
  * 
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  */
-      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2070
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2226
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 1             # <<<<<<<<<<<<<<
@@ -18092,7 +19733,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2071
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2227
  *                     value = <int>bam_aux2i(s)
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):             # <<<<<<<<<<<<<<
@@ -18110,20 +19751,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_4;
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2072
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2228
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  */
-      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2073
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2229
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 2             # <<<<<<<<<<<<<<
@@ -18134,7 +19775,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2074
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2230
  *                     value = <int>bam_aux2i(s)
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):             # <<<<<<<<<<<<<<
@@ -18152,20 +19793,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_5;
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2075
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2231
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  *                     value = <float>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'f':
  */
-      __pyx_t_2 = PyFloat_FromDouble(((float)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(((float)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2076
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2232
  *                 elif auxtype in ('i', 'I'):
  *                     value = <float>bam_aux2i(s)
  *                     s += 4             # <<<<<<<<<<<<<<
@@ -18176,7 +19817,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2077
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2233
  *                     value = <float>bam_aux2i(s)
  *                     s += 4
  *                 elif auxtype == 'f':             # <<<<<<<<<<<<<<
@@ -18186,20 +19827,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'f');
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2078
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2234
  *                     s += 4
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'd':
  */
-      __pyx_t_2 = PyFloat_FromDouble(bam_aux2f(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(bam_aux2f(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2079
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2235
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)
  *                     s += 4             # <<<<<<<<<<<<<<
@@ -18210,7 +19851,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2080
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2236
  *                     value = <float>bam_aux2f(s)
  *                     s += 4
  *                 elif auxtype == 'd':             # <<<<<<<<<<<<<<
@@ -18220,20 +19861,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'd');
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2081
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2237
  *                     s += 4
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)             # <<<<<<<<<<<<<<
  *                     s += 8
  *                 elif auxtype == 'A':
  */
-      __pyx_t_2 = PyFloat_FromDouble(bam_aux2d(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(bam_aux2d(__pyx_v_s)); 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_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2082
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2238
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)
  *                     s += 8             # <<<<<<<<<<<<<<
@@ -18244,7 +19885,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2083
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2239
  *                     value = <double>bam_aux2d(s)
  *                     s += 8
  *                 elif auxtype == 'A':             # <<<<<<<<<<<<<<
@@ -18254,23 +19895,23 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'A');
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2084
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2240
  *                     s += 8
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  */
-      __pyx_t_2 = PyInt_FromLong(bam_aux2A(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(bam_aux2A(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_59), __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = ((PyObject *)__pyx_t_6);
       __pyx_t_6 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2085
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2241
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1             # <<<<<<<<<<<<<<
@@ -18281,7 +19922,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
       goto __pyx_L8;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2086
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2242
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):             # <<<<<<<<<<<<<<
@@ -18299,33 +19940,33 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_4;
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2087
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2243
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  *                     value = <char*>bam_aux2Z(s)             # <<<<<<<<<<<<<<
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1
  */
-      __pyx_t_6 = PyBytes_FromString(bam_aux2Z(__pyx_v_s)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyBytes_FromString(bam_aux2Z(__pyx_v_s)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = ((PyObject *)__pyx_t_6);
       __pyx_t_6 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2089
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2245
  *                     value = <char*>bam_aux2Z(s)
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1             # <<<<<<<<<<<<<<
  *                  #
  *                 s += 1
  */
-      __pyx_t_7 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_s += (__pyx_t_7 + 1);
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2091
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2247
  *                     s += len(value) + 1
  *                  #
  *                 s += 1             # <<<<<<<<<<<<<<
@@ -18334,7 +19975,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     __pyx_v_s += 1;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2093
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2249
  *                 s += 1
  * 
  *                 result.append( (auxtag, value) )             # <<<<<<<<<<<<<<
@@ -18342,11 +19983,11 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  *             return result
  */
     if (unlikely(__pyx_v_result == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_6 = PyBytes_FromString(__pyx_v_auxtag); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyBytes_FromString(__pyx_v_auxtag); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __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 = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_6));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
@@ -18354,11 +19995,11 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
     __Pyx_GIVEREF(__pyx_v_value);
     __pyx_t_6 = 0;
-    __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2095
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2251
  *                 result.append( (auxtag, value) )
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -18386,7 +20027,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2097
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2253
  *             return result
  * 
  *         def __set__(self, tags):             # <<<<<<<<<<<<<<
@@ -18422,7 +20063,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
   char *__pyx_t_11;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2097);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2253);
   __pyx_v_buffer = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_pytag = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
@@ -18430,7 +20071,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
   __pyx_v_fmt = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_pytype = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2106
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2262
  *             cdef int max_size, size, offset
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18439,7 +20080,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2107
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2263
  * 
  *             src = self._delegate
  *             max_size = 4000             # <<<<<<<<<<<<<<
@@ -18448,7 +20089,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_max_size = 4000;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2108
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2264
  *             src = self._delegate
  *             max_size = 4000
  *             offset = 0             # <<<<<<<<<<<<<<
@@ -18457,39 +20098,39 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_offset = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2110
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2266
  *             offset = 0
  * 
  *             if tags != None:             # <<<<<<<<<<<<<<
  * 
  *                 # map samtools code to python.struct code and byte size
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __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 = 2110; __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 = 2266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2113
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2269
  * 
  *                 # map samtools code to python.struct code and byte size
  *                 buffer = ctypes.create_string_buffer(max_size)             # <<<<<<<<<<<<<<
  * 
  *                 for pytag, value in tags:
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_60); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_63); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyInt_FromLong(__pyx_v_max_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_max_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __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 = 2113; __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 = 2269; __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_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __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;
@@ -18497,7 +20138,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
     __pyx_v_buffer = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2115
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2271
  *                 buffer = ctypes.create_string_buffer(max_size)
  * 
  *                 for pytag, value in tags:             # <<<<<<<<<<<<<<
@@ -18507,7 +20148,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
     if (PyList_CheckExact(__pyx_v_tags) || PyTuple_CheckExact(__pyx_v_tags)) {
       __pyx_t_5 = 0; __pyx_t_1 = __pyx_v_tags; __Pyx_INCREF(__pyx_t_1);
     } else {
-      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
     }
     for (;;) {
@@ -18520,7 +20161,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       } else {
         __pyx_t_4 = PyIter_Next(__pyx_t_1);
         if (!__pyx_t_4) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_4);
@@ -18537,14 +20178,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
         __pyx_v_value = __pyx_t_6;
         __pyx_t_6 = 0;
       } else {
-        __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(__pyx_v_pytag);
         __pyx_v_pytag = __pyx_t_3;
@@ -18554,7 +20195,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
         __pyx_t_6 = 0;
       }
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2116
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2272
  * 
  *                 for pytag, value in tags:
  *                     t = type(value)             # <<<<<<<<<<<<<<
@@ -18565,33 +20206,33 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       __Pyx_DECREF(((PyObject *)__pyx_v_t));
       __pyx_v_t = ((PyObject *)((PyObject *)Py_TYPE(__pyx_v_value)));
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2117
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2273
  *                 for pytag, value in tags:
  *                     t = type(value)
  *                     if t == types.FloatType:             # <<<<<<<<<<<<<<
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:
  */
-      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       if (__pyx_t_2) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2118
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2274
  *                     t = type(value)
  *                     if t == types.FloatType:
  *                         fmt, pytype = "<cccf", 'f'             # <<<<<<<<<<<<<<
  *                     elif t == types.IntType:
  *                         if value < 0:
  */
-        __pyx_t_4 = ((PyObject *)__pyx_kp_s_61);
+        __pyx_t_4 = ((PyObject *)__pyx_kp_s_64);
         __Pyx_INCREF(__pyx_t_4);
         __pyx_t_6 = ((PyObject *)__pyx_n_s__f);
         __Pyx_INCREF(__pyx_t_6);
@@ -18604,51 +20245,51 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
         goto __pyx_L8;
       }
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2119
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2275
  *                     if t == types.FloatType:
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:             # <<<<<<<<<<<<<<
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  */
-      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__IntType); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__IntType); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_4, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_4, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       if (__pyx_t_2) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2120
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2276
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:
  *                         if value < 0:             # <<<<<<<<<<<<<<
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  */
-        __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         if (__pyx_t_2) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2121
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2277
  *                     elif t == types.IntType:
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'             # <<<<<<<<<<<<<<
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_62);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_65);
             __Pyx_INCREF(__pyx_t_6);
             __pyx_t_4 = ((PyObject *)__pyx_n_s__c);
             __Pyx_INCREF(__pyx_t_4);
@@ -18661,19 +20302,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
             goto __pyx_L10;
           }
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2122
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2278
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'             # <<<<<<<<<<<<<<
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_63);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_66);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__s);
             __Pyx_INCREF(__pyx_t_6);
@@ -18686,45 +20327,45 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
             goto __pyx_L10;
           }
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2123
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2279
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  *                         else:
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_64), __pyx_v_value); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_67), __pyx_v_value); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-            __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __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 = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_4);
             PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
             __pyx_t_6 = 0;
-            __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_6);
             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
             __Pyx_Raise(__pyx_t_6, 0, 0);
             __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L10;
           }
           /*else*/ {
 
-            /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2124
+            /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2280
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<ccci", 'i'[0]             # <<<<<<<<<<<<<<
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  */
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_65);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_68);
             __Pyx_INCREF(__pyx_t_6);
-            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_n_s__i), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_n_s__i), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_4);
             __Pyx_DECREF(__pyx_v_fmt);
             __pyx_v_fmt = __pyx_t_6;
@@ -18738,19 +20379,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
         }
         /*else*/ {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2126
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2282
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'             # <<<<<<<<<<<<<<
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_66);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_69);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__C);
             __Pyx_INCREF(__pyx_t_6);
@@ -18763,19 +20404,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
             goto __pyx_L11;
           }
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2127
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2283
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'             # <<<<<<<<<<<<<<
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<cccI", 'I'
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_67);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_70);
             __Pyx_INCREF(__pyx_t_6);
             __pyx_t_4 = ((PyObject *)__pyx_n_s__S);
             __Pyx_INCREF(__pyx_t_4);
@@ -18788,43 +20429,43 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
             goto __pyx_L11;
           }
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2128
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2284
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "<cccI", 'I'
  *                     else:
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_64), __pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_67), __pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-            __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __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 = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_6);
             PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
             __pyx_t_4 = 0;
-            __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_4);
             __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
             __Pyx_Raise(__pyx_t_4, 0, 0);
             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L11;
           }
           /*else*/ {
 
-            /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2129
+            /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2285
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<cccI", 'I'             # <<<<<<<<<<<<<<
  *                     else:
  *                         # Note: hex strings (H) are not supported yet
  */
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_68);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_71);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__I);
             __Pyx_INCREF(__pyx_t_6);
@@ -18842,25 +20483,25 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       }
       /*else*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2132
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2288
  *                     else:
  *                         # Note: hex strings (H) are not supported yet
  *                         if len(value) == 1:             # <<<<<<<<<<<<<<
  *                             fmt, pytype = "<cccc", 'A'
  *                         else:
  */
-        __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __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 = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_2 = (__pyx_t_8 == 1);
         if (__pyx_t_2) {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2133
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2289
  *                         # Note: hex strings (H) are not supported yet
  *                         if len(value) == 1:
  *                             fmt, pytype = "<cccc", 'A'             # <<<<<<<<<<<<<<
  *                         else:
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
  */
-          __pyx_t_6 = ((PyObject *)__pyx_kp_s_69);
+          __pyx_t_6 = ((PyObject *)__pyx_kp_s_72);
           __Pyx_INCREF(__pyx_t_6);
           __pyx_t_4 = ((PyObject *)__pyx_n_s__A);
           __Pyx_INCREF(__pyx_t_4);
@@ -18874,17 +20515,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
         }
         /*else*/ {
 
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2135
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2291
  *                             fmt, pytype = "<cccc", 'A'
  *                         else:
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'             # <<<<<<<<<<<<<<
  * 
  *                     size = struct.calcsize(fmt)
  */
-          __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_4 = PyInt_FromSsize_t((__pyx_t_8 + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __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 = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyInt_FromSsize_t((__pyx_t_8 + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_70), __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_73), __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           __pyx_t_4 = ((PyObject *)__pyx_n_s__Z);
@@ -18900,32 +20541,32 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       }
       __pyx_L8:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2137
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2293
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
  * 
  *                     size = struct.calcsize(fmt)             # <<<<<<<<<<<<<<
  *                     if offset + size > max_size:
  *                         raise NotImplementedError("tags field too large")
  */
-      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __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 = 2137; __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 = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_INCREF(__pyx_v_fmt);
       PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fmt);
       __Pyx_GIVEREF(__pyx_v_fmt);
-      __pyx_t_3 = PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_v_size = __pyx_t_9;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2138
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2294
  * 
  *                     size = struct.calcsize(fmt)
  *                     if offset + size > max_size:             # <<<<<<<<<<<<<<
@@ -18935,79 +20576,79 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       __pyx_t_2 = ((__pyx_v_offset + __pyx_v_size) > __pyx_v_max_size);
       if (__pyx_t_2) {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2139
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2295
  *                     size = struct.calcsize(fmt)
  *                     if offset + size > max_size:
  *                         raise NotImplementedError("tags field too large")             # <<<<<<<<<<<<<<
  * 
  *                     struct.pack_into( fmt,
  */
-        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __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 = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_71));
-        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_71));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_71));
-        __pyx_t_4 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
+        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_74));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
+        __pyx_t_4 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_4);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
         __Pyx_Raise(__pyx_t_4, 0, 0);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L13;
       }
       __pyx_L13:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2141
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2297
  *                         raise NotImplementedError("tags field too large")
  * 
  *                     struct.pack_into( fmt,             # <<<<<<<<<<<<<<
  *                                       buffer,
  *                                       offset,
  */
-      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2143
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2299
  *                     struct.pack_into( fmt,
  *                                       buffer,
  *                                       offset,             # <<<<<<<<<<<<<<
  *                                       pytag[0],
  *                                       pytag[1],
  */
-      __pyx_t_4 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2144
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2300
  *                                       buffer,
  *                                       offset,
  *                                       pytag[0],             # <<<<<<<<<<<<<<
  *                                       pytag[1],
  *                                       pytype,
  */
-      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_pytag, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_pytag, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2145
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2301
  *                                       offset,
  *                                       pytag[0],
  *                                       pytag[1],             # <<<<<<<<<<<<<<
  *                                       pytype,
  *                                       value )
  */
-      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_pytag, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_pytag, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2147
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2303
  *                                       pytag[1],
  *                                       pytype,
  *                                       value )             # <<<<<<<<<<<<<<
  *                     offset += size
  * 
  */
-      __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_10);
       __Pyx_INCREF(__pyx_v_fmt);
       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_fmt);
@@ -19030,13 +20671,13 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
       __pyx_t_4 = 0;
       __pyx_t_6 = 0;
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2148
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2304
  *                                       pytype,
  *                                       value )
  *                     offset += size             # <<<<<<<<<<<<<<
@@ -19050,7 +20691,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2156
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2312
  *                               src.l_aux,
  *                               offset,
  *                               bam1_aux( src ) )             # <<<<<<<<<<<<<<
@@ -19059,7 +20700,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->l_aux, __pyx_v_offset, bam1_aux(__pyx_v_src));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2158
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2314
  *                               bam1_aux( src ) )
  * 
  *             src.l_aux = offset             # <<<<<<<<<<<<<<
@@ -19068,7 +20709,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src->l_aux = __pyx_v_offset;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2161
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2317
  * 
  *             # copy data only if there is any
  *             if offset != 0:             # <<<<<<<<<<<<<<
@@ -19078,7 +20719,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
   __pyx_t_2 = (__pyx_v_offset != 0);
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2164
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2320
  * 
  *                 # get location of new data
  *                 s = bam1_aux( src )             # <<<<<<<<<<<<<<
@@ -19087,20 +20728,20 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
  */
     __pyx_v_s = bam1_aux(__pyx_v_src);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2167
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2323
  * 
  *                 # check if there is direct path from buffer.raw to tmp
  *                 temp = buffer.raw             # <<<<<<<<<<<<<<
  *                 memcpy( s, temp, offset )
  * 
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_11 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_temp = __pyx_t_11;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2168
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2324
  *                 # check if there is direct path from buffer.raw to tmp
  *                 temp = buffer.raw
  *                 memcpy( s, temp, offset )             # <<<<<<<<<<<<<<
@@ -19135,7 +20776,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2172
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2328
  *     property flag:
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag             # <<<<<<<<<<<<<<
@@ -19149,9 +20790,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2172);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2328);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19170,7 +20811,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2173
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2329
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag
  *         def __set__(self, flag): self._delegate.core.flag = flag             # <<<<<<<<<<<<<<
@@ -19184,8 +20825,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_sel
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2173);
-  __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 = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2329);
+  __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 = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19199,7 +20840,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2191
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2347
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -19213,9 +20854,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2191);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2347);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19234,7 +20875,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2192
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2348
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -19248,8 +20889,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_se
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2192);
-  __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 = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2348);
+  __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 = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19263,7 +20904,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2205
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2361
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -19277,9 +20918,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2205);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2361);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19298,7 +20939,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2206
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2362
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -19312,8 +20953,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2206);
-  __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 = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2362);
+  __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 = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19327,7 +20968,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2210
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2366
  *     property pos:
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos             # <<<<<<<<<<<<<<
@@ -19341,9 +20982,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2210);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2366);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19362,7 +21003,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2211
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2367
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos
  *         def __set__(self, pos):             # <<<<<<<<<<<<<<
@@ -19377,9 +21018,9 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2211);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2367);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2214
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2370
  *             ## setting the cigar string also updates the "bin" attribute
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19388,7 +21029,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2215
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2371
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -19397,7 +21038,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2216
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2372
  *             src = self._delegate
  *             if src.core.n_cigar:
  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )             # <<<<<<<<<<<<<<
@@ -19409,7 +21050,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2218
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2374
  *                 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)             # <<<<<<<<<<<<<<
@@ -19420,14 +21061,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2219
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2375
  *             else:
  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)
  *             self._delegate.core.pos = pos             # <<<<<<<<<<<<<<
  *     property bin:
  *         """properties bin"""
  */
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19441,7 +21082,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2222
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2378
  *     property bin:
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin             # <<<<<<<<<<<<<<
@@ -19455,9 +21096,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2222);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2378);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19476,7 +21117,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2223
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2379
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin
  *         def __set__(self, bin): self._delegate.core.bin = bin             # <<<<<<<<<<<<<<
@@ -19490,8 +21131,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2223);
-  __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 = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2379);
+  __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 = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19505,7 +21146,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2226
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2382
  *     property rlen:
  *         '''length of the read (read only). Returns 0 if not given.'''
  *         def __get__(self): return self._delegate.core.l_qseq             # <<<<<<<<<<<<<<
@@ -19519,9 +21160,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2226);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2382);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19540,7 +21181,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2230
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2386
  *         '''aligned end position of the read (read only).  Returns
  *         None if not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19559,9 +21200,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2230);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2386);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2232
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2388
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19570,19 +21211,19 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2233
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2389
  *             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_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2389; __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 = 2233; __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 = 2389; __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 = 2233; __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 = 2389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (!__pyx_t_3) {
     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
@@ -19592,7 +21233,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   }
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2234
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2390
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -19607,7 +21248,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2235
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2391
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core, bam1_cigar(src))             # <<<<<<<<<<<<<<
@@ -19615,7 +21256,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
  *         '''aligned length of the read (read only).  Returns None if
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -19635,7 +21276,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2239
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2395
  *         '''aligned length of the read (read only).  Returns None if
  *         not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19654,9 +21295,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2239);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2395);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2241
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2397
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19665,19 +21306,19 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2242
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2398
  *             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_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __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 = 2242; __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 = 2398; __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 = 2242; __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 = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (!__pyx_t_3) {
     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
@@ -19687,7 +21328,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   }
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2243
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2399
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -19702,7 +21343,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2244
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2400
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core,             # <<<<<<<<<<<<<<
@@ -19711,14 +21352,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2246
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2402
  *             return bam_calend(&src.core,
  *                                bam1_cigar(src)) - \
  *                                self._delegate.core.pos             # <<<<<<<<<<<<<<
  * 
  *     property mapq:
  */
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -19738,7 +21379,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2250
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2406
  *     property mapq:
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual             # <<<<<<<<<<<<<<
@@ -19752,9 +21393,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2250);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2406);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19773,7 +21414,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2251
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2407
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual
  *         def __set__(self, qual): self._delegate.core.qual = qual             # <<<<<<<<<<<<<<
@@ -19787,8 +21428,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_sel
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2251);
-  __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 = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2407);
+  __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 = 2407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19802,7 +21443,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2254
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2410
  *     property mrnm:
  *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
@@ -19816,9 +21457,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2254);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2410);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19837,7 +21478,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2255
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2411
  *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid
  *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
@@ -19851,8 +21492,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_sel
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2255);
-  __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 = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2411);
+  __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 = 2411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19866,7 +21507,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2258
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2414
  *     property mpos:
  *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
@@ -19880,9 +21521,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2258);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2414);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19901,7 +21542,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2259
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2415
  *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
@@ -19915,8 +21556,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_sel
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2259);
-  __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 = 2259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2415);
+  __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 = 2415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19930,7 +21571,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2262
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2418
  *     property isize:
  *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
@@ -19944,9 +21585,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2262);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2418);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19965,7 +21606,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2263
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2419
  *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize
  *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
@@ -19979,8 +21620,8 @@ static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_se
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2263);
-  __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 = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2419);
+  __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 = 2419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize = __pyx_t_1;
 
   __pyx_r = 0;
@@ -19994,7 +21635,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2266
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2422
  *     property is_paired:
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0             # <<<<<<<<<<<<<<
@@ -20008,9 +21649,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2266);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2422);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong(((((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(((((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -20029,7 +21670,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2267
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2423
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -20043,23 +21684,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2267);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2423);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2268
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2424
  *         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 = 2268; __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 = 2424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2269
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2425
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPAIRED
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED             # <<<<<<<<<<<<<<
@@ -20081,7 +21722,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2272
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2428
  *     property is_proper_pair:
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0             # <<<<<<<<<<<<<<
@@ -20096,14 +21737,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyOb
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2272);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2428);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __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 = 2272; __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 = 2428; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20124,7 +21765,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2273
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2429
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -20138,23 +21779,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2273);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2429);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2274
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2430
  *         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 = 2274; __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 = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 2;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2275
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2431
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
@@ -20176,7 +21817,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2278
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2434
  *     property is_unmapped:
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -20191,14 +21832,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObjec
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2278);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2434);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __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 = 2278; __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 = 2434; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20219,7 +21860,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObjec
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2279
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2435
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -20233,23 +21874,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__p
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2279);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2435);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2280
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2436
  *         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 = 2280; __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 = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 4;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2281
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2437
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP             # <<<<<<<<<<<<<<
@@ -20271,7 +21912,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2284
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2440
  *     property mate_is_unmapped:
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -20286,14 +21927,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(Py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2284);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2440);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __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 = 2284; __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 = 2440; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20314,7 +21955,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2285
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2441
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -20328,23 +21969,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2285);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2441);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2286
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2442
  *         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 = 2286; __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 = 2442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 8;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2287
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2443
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP             # <<<<<<<<<<<<<<
@@ -20366,7 +22007,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2290
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2446
  *     property is_reverse:
  *         """true if read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0             # <<<<<<<<<<<<<<
@@ -20374,21 +22015,306 @@ static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject
  *             if val: self._delegate.core.flag |= BAM_FREVERSE
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2446);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __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 = 2446; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __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_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2447
+ *         """true if read is mapped to reverse strand"""
+ *         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
+ */
+
+static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+  int __pyx_r;
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__set__");
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2447);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2448
+ *         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 = 2448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 16;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2449
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FREVERSE
+ *             else: self._delegate.core.flag &= ~BAM_FREVERSE             # <<<<<<<<<<<<<<
+ *     property mate_is_reverse:
+ *         """true is read is mapped to reverse strand"""
+ */
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~16);
+  }
+  __pyx_L5:;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2452
+ *     property mate_is_reverse:
+ *         """true is read is mapped to reverse strand"""
+ *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0             # <<<<<<<<<<<<<<
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FMREVERSE
+ */
+
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2452);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2452; __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 = 2452; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __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_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2453
+ *         """true is read is mapped to reverse strand"""
+ *         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
+ */
+
+static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+  int __pyx_r;
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__set__");
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2453);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2454
+ *         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 = 2454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 32;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2455
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FMREVERSE
+ *             else: self._delegate.core.flag &= ~BAM_FMREVERSE             # <<<<<<<<<<<<<<
+ *     property is_read1:
+ *         """true if this is read1"""
+ */
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~32);
+  }
+  __pyx_L5:;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2458
+ *     property is_read1:
+ *         """true if this is read1"""
+ *         def __get__(self): return (self.flag & BAM_FREAD1) != 0             # <<<<<<<<<<<<<<
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FREAD1
+ */
+
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2458);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __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 = 2458; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __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_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2459
+ *         """true if this is read1"""
+ *         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
+ */
+
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+  int __pyx_r;
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__set__");
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2459);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2460
+ *         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 = 2460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 64;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2461
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FREAD1
+ *             else: self._delegate.core.flag &= ~BAM_FREAD1             # <<<<<<<<<<<<<<
+ *     property is_read2:
+ *         """true if this is read2"""
+ */
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~64);
+  }
+  __pyx_L5:;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2464
+ *     property is_read2:
+ *         """true if this is read2"""
+ *         def __get__(self): return (self.flag & BAM_FREAD2) != 0             # <<<<<<<<<<<<<<
+ *         def __set__(self,val):
+ *             if val: self._delegate.core.flag |= BAM_FREAD2
+ */
+
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2290);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2464);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __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 = 2290; __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 = 2464; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20400,7 +22326,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__get__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -20409,51 +22335,51 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2291
- *         """true if read is mapped to reverse strand"""
- *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2465
+ *         """true if this is read2"""
+ *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
- *             if val: self._delegate.core.flag |= BAM_FREVERSE
- *             else: self._delegate.core.flag &= ~BAM_FREVERSE
+ *             if val: self._delegate.core.flag |= BAM_FREAD2
+ *             else: self._delegate.core.flag &= ~BAM_FREAD2
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2291);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2465);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2292
- *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2466
+ *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREVERSE             # <<<<<<<<<<<<<<
- *             else: self._delegate.core.flag &= ~BAM_FREVERSE
- *     property mate_is_reverse:
+ *             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 = 2292; __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 = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 16;
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 128;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2293
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2467
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREVERSE
- *             else: self._delegate.core.flag &= ~BAM_FREVERSE             # <<<<<<<<<<<<<<
- *     property mate_is_reverse:
- *         """true is read is mapped to reverse strand"""
+ *             if val: self._delegate.core.flag |= BAM_FREAD2
+ *             else: self._delegate.core.flag &= ~BAM_FREAD2             # <<<<<<<<<<<<<<
+ *     property is_secondary:
+ *         """true if not primary alignment"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~16);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~128);
   }
   __pyx_L5:;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -20461,29 +22387,29 @@ static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2296
- *     property mate_is_reverse:
- *         """true is read is mapped to reverse strand"""
- *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2470
+ *     property is_secondary:
+ *         """true if not primary alignment"""
+ *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0             # <<<<<<<<<<<<<<
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FMREVERSE
+ *             if val: self._delegate.core.flag |= BAM_FSECONDARY
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2296);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2470);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __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 = 2296; __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 = 2470; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20495,7 +22421,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyO
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__get__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -20504,51 +22430,51 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyO
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2297
- *         """true is read is mapped to reverse strand"""
- *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2471
+ *         """true if not primary alignment"""
+ *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
- *             if val: self._delegate.core.flag |= BAM_FMREVERSE
- *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
+ *             if val: self._delegate.core.flag |= BAM_FSECONDARY
+ *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2297);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2471);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2298
- *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2472
+ *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FMREVERSE             # <<<<<<<<<<<<<<
- *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
- *     property is_read1:
+ *             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 = 2298; __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 = 2472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 32;
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 256;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2299
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2473
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FMREVERSE
- *             else: self._delegate.core.flag &= ~BAM_FMREVERSE             # <<<<<<<<<<<<<<
- *     property is_read1:
- *         """true if this is read1"""
+ *             if val: self._delegate.core.flag |= BAM_FSECONDARY
+ *             else: self._delegate.core.flag &= ~BAM_FSECONDARY             # <<<<<<<<<<<<<<
+ *     property is_qcfail:
+ *         """true if QC failure"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~32);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~256);
   }
   __pyx_L5:;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -20556,29 +22482,29 @@ static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2302
- *     property is_read1:
- *         """true if this is read1"""
- *         def __get__(self): return (self.flag & BAM_FREAD1) != 0             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2476
+ *     property is_qcfail:
+ *         """true if QC failure"""
+ *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0             # <<<<<<<<<<<<<<
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD1
+ *             if val: self._delegate.core.flag |= BAM_FQCFAIL
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2302);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2476);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __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 = 2302; __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 = 2476; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20590,7 +22516,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *_
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__get__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_qcfail.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -20599,51 +22525,51 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2303
- *         """true if this is read1"""
- *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2477
+ *         """true if QC failure"""
+ *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
- *             if val: self._delegate.core.flag |= BAM_FREAD1
- *             else: self._delegate.core.flag &= ~BAM_FREAD1
+ *             if val: self._delegate.core.flag |= BAM_FQCFAIL
+ *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2303);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2477);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2304
- *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2478
+ *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD1             # <<<<<<<<<<<<<<
- *             else: self._delegate.core.flag &= ~BAM_FREAD1
- *     property is_read2:
+ *             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 = 2304; __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 = 2478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 64;
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 512;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2305
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2479
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD1
- *             else: self._delegate.core.flag &= ~BAM_FREAD1             # <<<<<<<<<<<<<<
- *     property is_read2:
- *         """true if this is read2"""
+ *             if val: self._delegate.core.flag |= BAM_FQCFAIL
+ *             else: self._delegate.core.flag &= ~BAM_FQCFAIL             # <<<<<<<<<<<<<<
+ *     property is_duplicate:
+ *         """true if optical or PCR duplicate"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~64);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~512);
   }
   __pyx_L5:;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_qcfail.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -20651,29 +22577,29 @@ static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2308
- *     property is_read2:
- *         """true if this is read2"""
- *         def __get__(self): return (self.flag & BAM_FREAD2) != 0             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2482
+ *     property is_duplicate:
+ *         """true if optical or PCR duplicate"""
+ *         def __get__(self): return (self.flag & BAM_FDUP) != 0             # <<<<<<<<<<<<<<
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD2
+ *             if val: self._delegate.core.flag |= BAM_FDUP
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2308);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2482);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __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 = 2308; __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 = 2482; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -20685,7 +22611,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *_
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__get__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_duplicate.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -20694,51 +22620,51 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2309
- *         """true if this is read2"""
- *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2483
+ *         """true if optical or PCR duplicate"""
+ *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
- *             if val: self._delegate.core.flag |= BAM_FREAD2
- *             else: self._delegate.core.flag &= ~BAM_FREAD2
+ *             if val: self._delegate.core.flag |= BAM_FDUP
+ *             else: self._delegate.core.flag &= ~BAM_FDUP
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2309);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2483);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2310
- *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2484
+ *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD2             # <<<<<<<<<<<<<<
- *             else: self._delegate.core.flag &= ~BAM_FREAD2
- *     property is_secondary:
+ *             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 = 2310; __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 = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 128;
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1024;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2311
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2485
  *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FREAD2
- *             else: self._delegate.core.flag &= ~BAM_FREAD2             # <<<<<<<<<<<<<<
- *     property is_secondary:
- *         """true if not primary alignment"""
+ *             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."""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~128);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1024);
   }
   __pyx_L5:;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.is_duplicate.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -20746,293 +22672,530 @@ static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2314
- *     property is_secondary:
- *         """true if not primary alignment"""
- *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0             # <<<<<<<<<<<<<<
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FSECONDARY
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2488
+ *     property positions:
+ *         """a list of reference positions that this read aligns to."""
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             cdef uint32_t k, i, pos
+ *             cdef int op
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *__pyx_v_self) {
+  uint32_t __pyx_v_k;
+  uint32_t __pyx_v_i;
+  uint32_t __pyx_v_pos;
+  int __pyx_v_op;
+  uint32_t *__pyx_v_cigar_p;
+  bam1_t *__pyx_v_src;
+  PyObject *__pyx_v_result;
+  PyObject *__pyx_v_l;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_2;
+  uint32_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  uint32_t __pyx_t_5;
+  int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2314);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __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 = 2314; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_r = __pyx_t_1;
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2488);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2494
+ *             cdef bam1_t * src
+ * 
+ *             result = []             # <<<<<<<<<<<<<<
+ *             src = self._delegate
+ *             if src.core.n_cigar == 0: return []
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_result));
+  __pyx_v_result = __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_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2495
+ * 
+ *             result = []
+ *             src = self._delegate             # <<<<<<<<<<<<<<
+ *             if src.core.n_cigar == 0: return []
+ * 
+ */
+  __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2496
+ *             result = []
+ *             src = self._delegate
+ *             if src.core.n_cigar == 0: return []             # <<<<<<<<<<<<<<
+ * 
+ *             pos = src.core.pos
+ */
+  __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __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(((PyObject *)__pyx_t_1));
+    __pyx_r = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2498
+ *             if src.core.n_cigar == 0: return []
+ * 
+ *             pos = src.core.pos             # <<<<<<<<<<<<<<
+ * 
+ *             cigar_p = bam1_cigar(src)
+ */
+  __pyx_v_pos = __pyx_v_src->core.pos;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2500
+ *             pos = src.core.pos
+ * 
+ *             cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
+ *             for k from 0 <= k < src.core.n_cigar:
+ *                 op = cigar_p[k] & BAM_CIGAR_MASK
+ */
+  __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2315
- *         """true if not primary alignment"""
- *         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
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2501
+ * 
+ *             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
  */
+  __pyx_t_3 = __pyx_v_src->core.n_cigar;
+  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
-  int __pyx_r;
-  int __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2315);
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2502
+ *             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
+ *                 if op == BAM_CMATCH:
+ */
+    __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2316
- *         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:
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2503
+ *             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_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 256;
-    goto __pyx_L5;
-  }
-  /*else*/ {
+    __pyx_t_1 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_l);
+    __pyx_v_l = __pyx_t_1;
+    __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2317
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FSECONDARY
- *             else: self._delegate.core.flag &= ~BAM_FSECONDARY             # <<<<<<<<<<<<<<
- *     property is_qcfail:
- *         """true if QC failure"""
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2504
+ *                 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:
+ *                         result.append( i )
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~256);
-  }
-  __pyx_L5:;
+    __pyx_t_2 = (__pyx_v_op == 0);
+    if (__pyx_t_2) {
 
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2505
+ *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
+ *                 if op == BAM_CMATCH:
+ *                     for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
+ *                         result.append( i )
+ * 
+ */
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_l); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2320
- *     property is_qcfail:
- *         """true if QC failure"""
- *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0             # <<<<<<<<<<<<<<
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FQCFAIL
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2506
+ *                 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:
+ */
+        if (unlikely(__pyx_v_result == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      }
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2508
+ *                         result.append( i )
+ * 
+ *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
+ *                     pos += l
+ * 
  */
+    switch (__pyx_v_op) {
+      case 0:
+      case 2:
+      case 3:
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2320);
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2509
+ * 
+ *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
+ *                     pos += l             # <<<<<<<<<<<<<<
+ * 
+ *             return result
+ */
+      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_l); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_pos += __pyx_t_5;
+      break;
+    }
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2511
+ *                     pos += l
+ * 
+ *             return result             # <<<<<<<<<<<<<<
+ *     def overlap( self, uint32_t start, uint32_t end ):
+ *         """return number of bases on reference overlapping *start* and *end*
+ */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __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 = 2320; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
+  __Pyx_INCREF(((PyObject *)__pyx_v_result));
+  __pyx_r = ((PyObject *)__pyx_v_result);
   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("csamtools.AlignedRead.is_qcfail.__get__");
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("csamtools.AlignedRead.positions.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_result);
+  __Pyx_DECREF(__pyx_v_l);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2321
- *         """true if QC failure"""
- *         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
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2512
+ * 
+ *             return result
+ *     def overlap( self, uint32_t start, uint32_t end ):             # <<<<<<<<<<<<<<
+ *         """return number of bases on reference overlapping *start* and *end*
+ *         """
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
-  int __pyx_r;
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead_overlap[] = "AlignedRead.overlap(self, uint32_t start, uint32_t end)\nreturn number of bases on reference overlapping *start* and *end*\n        ";
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  uint32_t __pyx_v_start;
+  uint32_t __pyx_v_end;
+  uint32_t __pyx_v_k;
+  uint32_t __pyx_v_pos;
+  uint32_t __pyx_v_overlap;
+  int __pyx_v_op;
+  int __pyx_v_o;
+  uint32_t *__pyx_v_cigar_p;
+  bam1_t *__pyx_v_src;
+  PyObject *__pyx_v_l;
+  PyObject *__pyx_r = NULL;
   int __pyx_t_1;
+  uint32_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  uint32_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  uint32_t __pyx_t_8;
+  uint32_t __pyx_t_9;
+  int __pyx_t_10;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__end,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2321);
+  __Pyx_RefNannySetupContext("overlap");
+  __Pyx_TraceCall("overlap", __pyx_f[0], 2512);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "overlap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __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 = 2512; __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 = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __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 = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.AlignedRead.overlap");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2322
- *         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:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2520
+ *         cdef bam1_t * src
+ * 
+ *         overlap = 0             # <<<<<<<<<<<<<<
+ * 
+ *         src = self._delegate
+ */
+  __pyx_v_overlap = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2522
+ *         overlap = 0
+ * 
+ *         src = self._delegate             # <<<<<<<<<<<<<<
+ *         if src.core.n_cigar == 0: return 0
+ *         pos = src.core.pos
+ */
+  __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2523
+ * 
+ *         src = self._delegate
+ *         if src.core.n_cigar == 0: return 0             # <<<<<<<<<<<<<<
+ *         pos = src.core.pos
+ *         o = 0
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = (__pyx_v_src->core.n_cigar == 0);
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 512;
-    goto __pyx_L5;
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_int_0);
+    __pyx_r = __pyx_int_0;
+    goto __pyx_L0;
+    goto __pyx_L6;
   }
-  /*else*/ {
+  __pyx_L6:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2323
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FQCFAIL
- *             else: self._delegate.core.flag &= ~BAM_FQCFAIL             # <<<<<<<<<<<<<<
- *     property is_duplicate:
- *         """ true if optical or PCR duplicate"""
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2524
+ *         src = self._delegate
+ *         if src.core.n_cigar == 0: return 0
+ *         pos = src.core.pos             # <<<<<<<<<<<<<<
+ *         o = 0
+ * 
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~512);
-  }
-  __pyx_L5:;
+  __pyx_v_pos = __pyx_v_src->core.pos;
 
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_qcfail.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2525
+ *         if src.core.n_cigar == 0: return 0
+ *         pos = src.core.pos
+ *         o = 0             # <<<<<<<<<<<<<<
+ * 
+ *         cigar_p = bam1_cigar(src)
+ */
+  __pyx_v_o = 0;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2326
- *     property is_duplicate:
- *         """ true if optical or PCR duplicate"""
- *         def __get__(self): return (self.flag & BAM_FDUP) != 0             # <<<<<<<<<<<<<<
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FDUP
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2527
+ *         o = 0
+ * 
+ *         cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
+ *         for k from 0 <= k < src.core.n_cigar:
+ *             op = cigar_p[k] & BAM_CIGAR_MASK
+ */
+  __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2528
+ * 
+ *         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
  */
+  __pyx_t_2 = __pyx_v_src->core.n_cigar;
+  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2326);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __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 = 2326; __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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
-  goto __pyx_L0;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2529
+ *         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
+ * 
+ */
+    __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2530
+ *         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 = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_v_l);
+    __pyx_v_l = __pyx_t_3;
+    __pyx_t_3 = 0;
 
-  __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("csamtools.AlignedRead.is_duplicate.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2532
+ *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
+ * 
+ *             if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
+ *                 o = min( pos + l, end) - max( pos, start )
+ *                 if o > 0: overlap += o
+ */
+    __pyx_t_1 = (__pyx_v_op == 0);
+    if (__pyx_t_1) {
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2327
- *         """ true if optical or PCR duplicate"""
- *         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
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2533
+ * 
+ *             if op == BAM_CMATCH:
+ *                 o = min( pos + l, end) - max( pos, start )             # <<<<<<<<<<<<<<
+ *                 if o > 0: overlap += o
+ * 
  */
+      __pyx_t_4 = __pyx_v_end;
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_1) {
+        __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_3 = __pyx_t_7;
+        __pyx_t_7 = 0;
+      } else {
+        __Pyx_INCREF(__pyx_t_5);
+        __pyx_t_3 = __pyx_t_5;
+      }
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_4 = __pyx_v_start;
+      __pyx_t_8 = __pyx_v_pos;
+      if ((__pyx_t_4 > __pyx_t_8)) {
+        __pyx_t_9 = __pyx_t_4;
+      } else {
+        __pyx_t_9 = __pyx_t_8;
+      }
+      __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_v_o = __pyx_t_10;
 
-static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
-  int __pyx_r;
-  int __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2327);
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2534
+ *             if op == BAM_CMATCH:
+ *                 o = min( pos + l, end) - max( pos, start )
+ *                 if o > 0: overlap += o             # <<<<<<<<<<<<<<
+ * 
+ *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
+ */
+      __pyx_t_1 = (__pyx_v_o > 0);
+      if (__pyx_t_1) {
+        __pyx_v_overlap += __pyx_v_o;
+        goto __pyx_L10;
+      }
+      __pyx_L10:;
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2328
- *         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
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2536
+ *                 if o > 0: overlap += o
+ * 
+ *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
+ *                 pos += l
  * 
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1024;
-    goto __pyx_L5;
+    switch (__pyx_v_op) {
+      case 0:
+      case 2:
+      case 3:
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2537
+ * 
+ *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
+ *                 pos += l             # <<<<<<<<<<<<<<
+ * 
+ *         return overlap
+ */
+      __pyx_t_9 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_l); if (unlikely((__pyx_t_9 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_pos += __pyx_t_9;
+      break;
+    }
   }
-  /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2329
- *         def __set__(self,val):
- *             if val: self._delegate.core.flag |= BAM_FDUP
- *             else: self._delegate.core.flag &= ~BAM_FDUP             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2539
+ *                 pos += l
+ * 
+ *         return overlap             # <<<<<<<<<<<<<<
  * 
  *     def opt(self, tag):
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1024);
-  }
-  __pyx_L5:;
+  __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 = 2539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_r = __pyx_t_7;
+  __pyx_t_7 = 0;
+  goto __pyx_L0;
 
-  __pyx_r = 0;
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.is_duplicate.__set__");
-  __pyx_r = -1;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("csamtools.AlignedRead.overlap");
+  __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
+  __Pyx_DECREF(__pyx_v_l);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2331
- *             else: self._delegate.core.flag &= ~BAM_FDUP
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2541
+ *         return overlap
  * 
  *     def opt(self, tag):             # <<<<<<<<<<<<<<
  *         """retrieves optional data given a two-letter *tag*"""
@@ -21040,7 +23203,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_opt[] = "retrieves optional data given a two-letter *tag*";
+static char __pyx_doc_9csamtools_11AlignedRead_opt[] = "AlignedRead.opt(self, tag)\nretrieves optional data given a two-letter *tag*";
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
   uint8_t *__pyx_v_v;
   PyObject *__pyx_v_type;
@@ -21055,20 +23218,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("opt");
-  __Pyx_TraceCall("opt", __pyx_f[0], 2331);
+  __Pyx_TraceCall("opt", __pyx_f[0], 2541);
   __pyx_v_type = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2335
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2545
  *         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc
  *         cdef uint8_t * v
  *         v = bam_aux_get(self._delegate, tag)             # <<<<<<<<<<<<<<
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])
  */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_tag); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_tag); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_v = bam_aux_get(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate, __pyx_t_1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2336
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2546
  *         cdef uint8_t * v
  *         v = bam_aux_get(self._delegate, tag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )             # <<<<<<<<<<<<<<
@@ -21077,69 +23240,69 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  */
   __pyx_t_2 = (__pyx_v_v == NULL);
   if (__pyx_t_2) {
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_72), __pyx_v_tag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_75), __pyx_v_tag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __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 = 2546; __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_KeyError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2337
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2547
  *         v = bam_aux_get(self._delegate, tag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])             # <<<<<<<<<<<<<<
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)
  */
-  __pyx_t_3 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __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 = 2337; __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 = 2547; __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_builtin_chr, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_v_type);
   __pyx_v_type = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2338
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2548
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':             # <<<<<<<<<<<<<<
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__c), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__c), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __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 = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__C), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__C), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __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 = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     if (!__pyx_t_5) {
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__s), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__s), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (!__pyx_t_6) {
-        __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__S), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__S), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
         __pyx_t_8 = __pyx_t_7;
       } else {
@@ -21155,7 +23318,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   }
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2339
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2549
  *         type = chr(v[0])
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -21163,7 +23326,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *             return <int32_t>bam_aux2i(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21171,21 +23334,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
     goto __pyx_L6;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2340
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2550
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':             # <<<<<<<<<<<<<<
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__i), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__i), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_5) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__I), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__I), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_6 = __pyx_t_2;
   } else {
@@ -21193,7 +23356,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   }
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2341
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2551
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':
  *             return <int32_t>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -21201,7 +23364,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *             return <float>bam_aux2f(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(bam_aux2i(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(bam_aux2i(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21209,21 +23372,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
     goto __pyx_L6;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2342
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2552
  *         elif type == 'i' or type == 'I':
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':             # <<<<<<<<<<<<<<
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__f), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__f), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_6) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__F), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__F), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __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 = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_2 = __pyx_t_5;
   } else {
@@ -21231,7 +23394,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   }
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2343
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2553
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':
  *             return <float>bam_aux2f(v)             # <<<<<<<<<<<<<<
@@ -21239,7 +23402,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *             return <double>bam_aux2d(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyFloat_FromDouble(bam_aux2f(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyFloat_FromDouble(bam_aux2f(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21247,21 +23410,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
     goto __pyx_L6;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2344
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2554
  *         elif type == 'f' or type == 'F':
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':             # <<<<<<<<<<<<<<
  *             return <double>bam_aux2d(v)
  *         elif type == 'A':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__d), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__d), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __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 = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__D), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__D), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = __pyx_t_6;
   } else {
@@ -21269,7 +23432,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   }
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2345
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2555
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':
  *             return <double>bam_aux2d(v)             # <<<<<<<<<<<<<<
@@ -21277,7 +23440,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *             # there might a more efficient way
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyFloat_FromDouble(bam_aux2d(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyFloat_FromDouble(bam_aux2d(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21285,20 +23448,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
     goto __pyx_L6;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2346
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2556
  *         elif type == 'd' or type == 'D':
  *             return <double>bam_aux2d(v)
  *         elif type == 'A':             # <<<<<<<<<<<<<<
  *             # there might a more efficient way
  *             # to convert a char into a string
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__A), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__A), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __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 = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2349
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2559
  *             # there might a more efficient way
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)             # <<<<<<<<<<<<<<
@@ -21306,9 +23469,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *             return <char*>bam_aux2Z(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(bam_aux2A(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(bam_aux2A(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_59), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_r = ((PyObject *)__pyx_t_4);
@@ -21317,20 +23480,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
     goto __pyx_L6;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2350
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2560
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)
  *         elif type == 'Z':             # <<<<<<<<<<<<<<
  *             return <char*>bam_aux2Z(v)
  * 
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__Z), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__Z), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; __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 = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2351
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2561
  *             return '%c' % <char>bam_aux2A(v)
  *         elif type == 'Z':
  *             return <char*>bam_aux2Z(v)             # <<<<<<<<<<<<<<
@@ -21338,7 +23501,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  *     def fancy_str (self):
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_4 = PyBytes_FromString(bam_aux2Z(__pyx_v_v)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyBytes_FromString(bam_aux2Z(__pyx_v_v)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __pyx_r = ((PyObject *)__pyx_t_4);
     __pyx_t_4 = 0;
@@ -21362,7 +23525,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2353
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2563
  *             return <char*>bam_aux2Z(v)
  * 
  *     def fancy_str (self):             # <<<<<<<<<<<<<<
@@ -21371,7 +23534,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, P
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_fancy_str[] = "returns list of fieldnames/values in pretty format for debugging\n        ";
+static char __pyx_doc_9csamtools_11AlignedRead_fancy_str[] = "AlignedRead.fancy_str(self)\nreturns list of fieldnames/values in pretty format for debugging\n        ";
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_v_ret_string;
   PyObject *__pyx_v_field_names;
@@ -21390,64 +23553,64 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
   int __pyx_t_10;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fancy_str");
-  __Pyx_TraceCall("fancy_str", __pyx_f[0], 2353);
+  __Pyx_TraceCall("fancy_str", __pyx_f[0], 2563);
   __pyx_v_ret_string = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_field_names = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_fields_names_in_order = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2356
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2566
  *         """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 = 2356; __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 = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_ret_string));
   __pyx_v_ret_string = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2357
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2567
  *         """
  *         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 = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __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_73)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_74)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_75)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_76)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_77)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_78)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_79)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_80)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_81)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_82)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_83)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_84)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_85)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_86)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_87)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_88)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_89)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_90)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__tid), ((PyObject *)__pyx_kp_s_76)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_77)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_78)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_79)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_80)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_81)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_82)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_83)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_84)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_85)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_86)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_87)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_88)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_89)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_90)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_91)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_92)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_93)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_v_field_names));
   __pyx_v_field_names = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2377
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2587
  *            "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 = 2377; __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 = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__tid));
   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tid));
@@ -21507,7 +23670,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
   __pyx_v_fields_names_in_order = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2381
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2591
  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
  * 
  *         for f in fields_names_in_order:             # <<<<<<<<<<<<<<
@@ -21517,7 +23680,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
   if (likely(((PyObject *)__pyx_v_fields_names_in_order) != Py_None)) {
     __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields_names_in_order); __Pyx_INCREF(__pyx_t_1);
   } else {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   for (;;) {
     if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
@@ -21526,21 +23689,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
     __pyx_v_f = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2382
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2592
  * 
  *         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(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_v_f))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_v_f))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __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) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2383
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2593
  *         for f in fields_names_in_order:
  *             if not f in self.__dict__:
  *                 continue             # <<<<<<<<<<<<<<
@@ -21552,7 +23715,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
     }
     __pyx_L7:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2384
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2594
  *             if not f in self.__dict__:
  *                 continue
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
@@ -21560,27 +23723,27 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
  *         for f in self.__dict__:
  */
     if (unlikely(__pyx_v_ret_string == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __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 = 2384; __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 = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_92), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_95), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_93)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_96)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __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(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __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 = 2384; __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 = 2594; __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, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_DECREF(__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 = 2384; __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 = 2594; __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);
@@ -21591,28 +23754,28 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
     __pyx_t_3 = 0;
     __pyx_t_7 = 0;
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_91), __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_94), __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-    __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __pyx_L5_continue:;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2386
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2596
  *             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(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __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 = 0; __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9);
   } 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 = 2386; __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 = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -21626,7 +23789,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
     } else {
       __pyx_t_1 = PyIter_Next(__pyx_t_9);
       if (!__pyx_t_1) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_1);
@@ -21635,7 +23798,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
     __pyx_v_f = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2387
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2597
  * 
  *         for f in self.__dict__:
  *             if not f in field_names:             # <<<<<<<<<<<<<<
@@ -21643,14 +23806,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
  *         return ret_string
  */
     if (unlikely(((PyObject *)__pyx_v_field_names) == Py_None)) {
-      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     } else {
-      __pyx_t_5 = ((PyDict_Contains(((PyObject *)__pyx_v_field_names), __pyx_v_f))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = ((PyDict_Contains(((PyObject *)__pyx_v_field_names), __pyx_v_f))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_t_4 = (!__pyx_t_5);
     if (__pyx_t_4) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2388
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2598
  *         for f in self.__dict__:
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
@@ -21658,20 +23821,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
  * 
  */
       if (unlikely(__pyx_v_ret_string == Py_None)) {
-        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
       }
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __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 = 2388; __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 = 2598; __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, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_DECREF(__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 = 2388; __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 = 2598; __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);
@@ -21682,10 +23845,10 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
       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_91), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_94), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
       goto __pyx_L10;
     }
@@ -21693,7 +23856,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
   }
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2389
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2599
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  *         return ret_string             # <<<<<<<<<<<<<<
@@ -21727,7 +23890,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2413
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2623
  *     cdef int n_pu
  * 
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -21742,29 +23905,29 @@ static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, Py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2413);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2623);
   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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2414
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2624
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __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 = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_94));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_94));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_94));
-  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_Raise(__pyx_t_2, 0, 0);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -21779,7 +23942,7 @@ static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2416
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2626
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -21797,9 +23960,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2416);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2626);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2417
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -21808,30 +23971,30 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2418
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2628
  *     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_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2417
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
  * 
  *     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(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __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 = 2417; __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 = 2627; __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 = 2417; __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 = 2627; __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);
@@ -21842,7 +24005,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
   __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 = 2417; __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 = 2627; __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)));
@@ -21850,34 +24013,34 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __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 = 2417; __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 = 2627; __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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2419
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2629
  *         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_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __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 = 2419; __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 = 2629; __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 = 2419; __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 = 2629; __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)));
@@ -21885,19 +24048,19 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
   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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2419; __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 = 2629; __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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_DECREF(__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 = 2418; __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 = 2628; __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;
@@ -21922,7 +24085,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2423
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2633
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self): return self.tid             # <<<<<<<<<<<<<<
@@ -21936,9 +24099,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2423);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2633);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21957,7 +24120,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2427
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2637
  *     property n:
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu             # <<<<<<<<<<<<<<
@@ -21971,9 +24134,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2427);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2637);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21992,7 +24155,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2428
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2638
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu
  *         def __set__(self, n): self.n_pu = n             # <<<<<<<<<<<<<<
@@ -22006,8 +24169,8 @@ static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self,
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2428);
-  __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 = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2638);
+  __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 = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu = __pyx_t_1;
 
   __pyx_r = 0;
@@ -22021,7 +24184,7 @@ static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2431
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2641
  * 
  *     property pos:
  *         def __get__(self): return self.pos             # <<<<<<<<<<<<<<
@@ -22035,9 +24198,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2431);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2641);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22056,7 +24219,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2435
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2645
  *     property pileups:
  *         '''list of reads (:class:`pysam.PileupRead`) aligned to this column'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22074,23 +24237,23 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2435);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2645);
   __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2437
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2647
  *         def __get__(self):
  *             cdef int x
  *             pileups = []             # <<<<<<<<<<<<<<
  *             # warning: there could be problems if self.n and self.buf are
  *             # out of sync.
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __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 = 2647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_pileups));
   __pyx_v_pileups = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2440
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2650
  *             # warning: there could be problems if self.n and self.buf are
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:             # <<<<<<<<<<<<<<
@@ -22100,7 +24263,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   __pyx_t_2 = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2441
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2651
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[x])) )             # <<<<<<<<<<<<<<
@@ -22108,15 +24271,15 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
  * 
  */
     if (unlikely(__pyx_v_pileups == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_1 = __pyx_f_9csamtools_makePileupRead((&(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->plp[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __pyx_f_9csamtools_makePileupRead((&(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->plp[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2442
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2652
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[x])) )
  *             return pileups             # <<<<<<<<<<<<<<
@@ -22142,7 +24305,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2457
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2667
  *          uint32_t _is_tail
  * 
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -22157,29 +24320,29 @@ static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyO
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2457);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2667);
   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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2458
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2668
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __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 = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_94));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_94));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_94));
-  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_Raise(__pyx_t_2, 0, 0);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -22194,7 +24357,7 @@ static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyO
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2460
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2670
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -22216,9 +24379,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self
   PyObject *__pyx_t_9 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2460);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2670);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2461
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2671
  * 
  *     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 ) ) )             # <<<<<<<<<<<<<<
@@ -22226,23 +24389,23 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self
  *     property alignment:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __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 = 2461; __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 = 2671; __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);
@@ -22265,7 +24428,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self
   __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 = 2461; __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 = 2671; __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)));
@@ -22273,15 +24436,15 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self
   PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
   __Pyx_GIVEREF(__pyx_t_9);
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __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 = 2461; __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 = 2671; __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, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
@@ -22310,7 +24473,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2465
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2675
  *     property alignment:
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22323,9 +24486,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *_
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2465);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2675);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2466
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2676
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):
  *             return self._alignment             # <<<<<<<<<<<<<<
@@ -22345,7 +24508,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2469
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2679
  *     property qpos:
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22359,9 +24522,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2469);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2679);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2470
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2680
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):
  *             return self._qpos             # <<<<<<<<<<<<<<
@@ -22369,7 +24532,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
  *         """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(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22388,7 +24551,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2473
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2683
  *     property indel:
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22402,9 +24565,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2473);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2683);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2474
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2684
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):
  *             return self._indel             # <<<<<<<<<<<<<<
@@ -22412,7 +24575,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
  *         """1 iff the base on the padded read is a deletion"""
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22431,7 +24594,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2477
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2687
  *     property is_del:
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22445,9 +24608,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2477);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2687);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2478
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2688
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):
  *             return self._is_del             # <<<<<<<<<<<<<<
@@ -22455,7 +24618,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22474,7 +24637,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2480
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2690
  *             return self._is_del
  *     property is_head:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22488,9 +24651,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2480);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2690);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2481
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2691
  *     property is_head:
  *         def __get__(self):
  *             return self._is_head             # <<<<<<<<<<<<<<
@@ -22498,7 +24661,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22517,7 +24680,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2483
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2693
  *             return self._is_head
  *     property is_tail:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22531,9 +24694,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2483);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2693);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2484
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2694
  *     property is_tail:
  *         def __get__(self):
  *             return self._is_tail             # <<<<<<<<<<<<<<
@@ -22541,7 +24704,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22560,7 +24723,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2486
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2696
  *             return self._is_tail
  *     property level:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22574,9 +24737,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2486);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2696);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2487
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2697
  *     property level:
  *         def __get__(self):
  *             return self._level             # <<<<<<<<<<<<<<
@@ -22584,7 +24747,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
  * class Outs:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -22603,7 +24766,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2491
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
  * class Outs:
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
@@ -22612,7 +24775,8 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
  */
 
 static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_4Outs___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_4Outs___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_4Outs___init__[] = "Outs.__init__(self, id=1)";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_4Outs___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs___init__)};
 static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
   PyObject *__pyx_v_id = 0;
@@ -22621,7 +24785,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__id,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2491);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2701);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -22645,7 +24809,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_id = values[1];
@@ -22660,33 +24824,33 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   }
   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 = 2491; __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 = 2701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.__init__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2492
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2702
  *     '''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 = 2492; __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 = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__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 = 2492; __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 = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2493
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2703
  *     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 = 2493; __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 = 2703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -22701,7 +24865,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2495
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
@@ -22710,7 +24874,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
  */
 
 static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_setdevice[] = "open an existing file, like \"/dev/null\"";
+static char __pyx_doc_9csamtools_4Outs_setdevice[] = "Outs.setdevice(self, filename)\nopen an existing file, like \"/dev/null\"";
 static PyMethodDef __pyx_mdef_9csamtools_4Outs_setdevice = {__Pyx_NAMESTR("setdevice"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setdevice, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setdevice)};
 static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
@@ -22723,7 +24887,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setdevice");
-  __Pyx_TraceCall("setdevice", __pyx_f[0], 2495);
+  __Pyx_TraceCall("setdevice", __pyx_f[0], 2705);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -22743,11 +24907,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_filename = values[1];
@@ -22759,7 +24923,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
   }
   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 = 2495; __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 = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setdevice");
   __Pyx_RefNannyFinishContext();
@@ -22767,24 +24931,24 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2497
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2707
  *     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 = 2497; __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 = 2707; __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 = 2497; __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 = 2707; __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 = 2497; __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 = 2707; __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 = 2497; __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 = 2707; __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 = 2497; __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 = 2707; __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);
@@ -22792,7 +24956,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, 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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -22800,21 +24964,21 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
   __pyx_v_fd = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2498
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2708
  *         '''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 = 2498; __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 = 2708; __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 = 2498; __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 = 2708; __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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __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;
@@ -22836,7 +25000,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2500
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
@@ -22845,7 +25009,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObj
  */
 
 static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_setfile[] = "open a new file.";
+static char __pyx_doc_9csamtools_4Outs_setfile[] = "Outs.setfile(self, filename)\nopen a new file.";
 static PyMethodDef __pyx_mdef_9csamtools_4Outs_setfile = {__Pyx_NAMESTR("setfile"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setfile, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setfile)};
 static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
@@ -22859,7 +25023,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfile");
-  __Pyx_TraceCall("setfile", __pyx_f[0], 2500);
+  __Pyx_TraceCall("setfile", __pyx_f[0], 2710);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -22879,11 +25043,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_filename = values[1];
@@ -22895,7 +25059,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
   }
   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 = 2500; __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 = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setfile");
   __Pyx_RefNannyFinishContext();
@@ -22903,33 +25067,33 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2502
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2712
  *     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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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 = 2502; __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 = 2712; __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);
@@ -22940,7 +25104,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, 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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __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_4); __pyx_t_4 = 0;
@@ -22948,21 +25112,21 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
   __pyx_v_fd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2503
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2713
  *         '''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 = 2503; __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 = 2713; __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 = 2503; __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 = 2713; __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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __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_4); __pyx_t_4 = 0;
@@ -22985,7 +25149,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2505
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
  *         self.setfd(fd)
  * 
  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
@@ -22994,7 +25158,8 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObjec
  */
 
 static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyMethodDef __pyx_mdef_9csamtools_4Outs_setfd = {__Pyx_NAMESTR("setfd"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setfd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static char __pyx_doc_9csamtools_4Outs_setfd[] = "Outs.setfd(self, fd)";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs_setfd = {__Pyx_NAMESTR("setfd"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setfd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setfd)};
 static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
   PyObject *__pyx_v_fd = 0;
@@ -23006,7 +25171,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fd,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfd");
-  __Pyx_TraceCall("setfd", __pyx_f[0], 2505);
+  __Pyx_TraceCall("setfd", __pyx_f[0], 2715);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -23026,11 +25191,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fd);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_fd = values[1];
@@ -23042,7 +25207,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
   }
   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 = 2505; __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 = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setfd");
   __Pyx_RefNannyFinishContext();
@@ -23050,26 +25215,26 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_ofd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2506
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2716
  * 
  *     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 = 2506; __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 = 2716; __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 = 2506; __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 = 2716; __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 = 2506; __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 = 2716; __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 = 2506; __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 = 2716; __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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __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_3); __pyx_t_3 = 0;
@@ -23077,90 +25242,110 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
   __pyx_v_ofd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2507
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2717
  *     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.
- *         os.dup2(fd, self.id)        #  Open unit 1 on new 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 = 2507; __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 = 2717; __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 = 2507; __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 = 2717; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2508
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2718
  *         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.
- *         os.close(fd)                #  Close other unit (look out, caller.)
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2508; __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 = 2718; __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 = 2508; __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 = 2718; __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 = 2508; __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 = 2718; __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 = 2508; __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 = 2718; __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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2509
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2719
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
- *         os.dup2(fd, self.id)        #  Open unit 1 on new 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__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __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 = 2719; __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 = 2719; __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 = 2719; __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 = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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 = 2719; __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__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2720
+ *         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 = 2720; __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 = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __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 = 2720; __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 = 2720; __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);
   __Pyx_GIVEREF(__pyx_v_fd);
-  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
-  __Pyx_GIVEREF(__pyx_t_1);
-  __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __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_2); __pyx_t_2 = 0;
+  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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2510
- *         sys.stdout.flush()          #  Buffered data goes to old stream.
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2721
+ *         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_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __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 = 2721; __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 = 2721; __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 = 2510; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(__pyx_v_fd);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fd);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __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;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -23178,7 +25363,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2512
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
@@ -23187,7 +25372,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject
  */
 
 static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_restore[] = "restore previous output stream";
+static char __pyx_doc_9csamtools_4Outs_restore[] = "Outs.restore(self)\nrestore previous output stream";
 static PyMethodDef __pyx_mdef_9csamtools_4Outs_restore = {__Pyx_NAMESTR("restore"), (PyCFunction)__pyx_pf_9csamtools_4Outs_restore, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_restore)};
 static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
@@ -23198,82 +25383,82 @@ static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObjec
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("restore");
-  __Pyx_TraceCall("restore", __pyx_f[0], 2512);
+  __Pyx_TraceCall("restore", __pyx_f[0], 2723);
   __pyx_self = __pyx_self;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2514
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2725
  *     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 = 2514; __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 = 2725; __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 = 2514; __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 = 2725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2517
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2728
  *             # 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 = 2517; __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 = 2728; __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 = 2517; __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 = 2728; __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 = 2517; __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 = 2728; __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 = 2517; __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 = 2728; __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;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2518
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2729
  *             # 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 = 2518; __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 = 2729; __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 = 2518; __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 = 2729; __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 = 2518; __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 = 2729; __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 = 2518; __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 = 2729; __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;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2519
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2730
  *             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 = 2519; __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 = 2730; __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 = 2519; __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 = 2730; __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 = 2519; __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 = 2730; __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 = 2519; __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 = 2730; __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 = 2519; __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 = 2730; __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 = 2519; __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 = 2730; __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);
@@ -23281,50 +25466,50 @@ static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObjec
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_4 = 0;
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __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_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2520
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2731
  *             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 = 2520; __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 = 2731; __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 = 2520; __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 = 2731; __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 = 2520; __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 = 2731; __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 = 2520; __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 = 2731; __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 = 2520; __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 = 2731; __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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2521
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2732
  *             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 = 2521; __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 = 2732; __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 = 2521; __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 = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     goto __pyx_L5;
   }
@@ -23346,7 +25531,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObjec
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2523
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2734
  *             del self.streams[-1]
  * 
  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
@@ -23355,7 +25540,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObjec
  */
 
 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools__samtools_dispatch[] = "call ``method`` in samtools providing arguments in args.\n    \n    .. note:: \n       This method redirects stdout and stderr to capture it \n       from samtools. If for some reason stdout/stderr disappears\n       the reason might be in this method.\n\n    .. note::\n       The current implementation might only work on linux.\n       \n    .. note:: \n       This method captures stdout and stderr using temporary files, \n       which are then read into memory in their entirety. This method\n       is slow and might cause large memory overhead. \n\n    See http://bytes.com/topic/c/answers/487231-how-capture-stdout-temporarily\n    on the topic of redirecting stderr/stdout.\n    ";
+static char __pyx_doc_9csamtools__samtools_dispatch[] = "_samtools_dispatch(method, args=(), catch_stdout=True, catch_stderr=False)\ncall ``method`` in samtools providing arguments in args.\n    \n    .. note:: \n       This method redirects stdout and stderr to capture it \n       from samtools. If for some reason stdout/stderr disappears\n       the reason might be in this method.\n\n    .. note::\n       The current implementation might only work on linux.\n       \n    .. note:: \n       This method captures stdout and stderr using temporary files, \n       which are then read into memory in their entirety. This method\n       is slow and might cause large memory overhead. \n\n    See http://bytes.com/topic/c/answers/487231-how-capture-stdout-temporarily\n    on the topic of redirecting stderr/stdout.\n    ";
 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_method = 0;
   PyObject *__pyx_v_args = 0;
@@ -23386,13 +25571,13 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__method,&__pyx_n_s__args,&__pyx_n_s__catch_stdout,&__pyx_n_s__catch_stderr,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_samtools_dispatch");
-  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 2523);
+  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 2734);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2524
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2735
  * 
  * def _samtools_dispatch( method,
  *                         args = (),             # <<<<<<<<<<<<<<
@@ -23400,8 +25585,8 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  *                         catch_stderr = False,
  */
     values[1] = ((PyObject *)__pyx_empty_tuple);
-    values[2] = __pyx_k_95;
-    values[3] = __pyx_k_96;
+    values[2] = __pyx_k_98;
+    values[3] = __pyx_k_99;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
@@ -23432,7 +25617,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2523; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_method = values[0];
     __pyx_v_args = values[1];
@@ -23440,8 +25625,8 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __pyx_v_catch_stderr = values[3];
   } else {
     __pyx_v_args = ((PyObject *)__pyx_empty_tuple);
-    __pyx_v_catch_stdout = __pyx_k_95;
-    __pyx_v_catch_stderr = __pyx_k_96;
+    __pyx_v_catch_stdout = __pyx_k_98;
+    __pyx_v_catch_stderr = __pyx_k_99;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  4: __pyx_v_catch_stderr = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: __pyx_v_catch_stdout = PyTuple_GET_ITEM(__pyx_args, 2);
@@ -23453,7 +25638,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2523; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools._samtools_dispatch");
   __Pyx_RefNannyFinishContext();
@@ -23469,73 +25654,73 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   __pyx_v_out_stdout = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_out_stderr = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2551
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2762
  * 
  *     # 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); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__index), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __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 = 2551; __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 = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2552
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2763
  *     # 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 = 2552; __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 = 2763; __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 = 2552; __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 = 2763; __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 = 2552; __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 = 2763; __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 = 2552; __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 = 2763; __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 = 2552; __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 = 2763; __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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __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_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 = 2552; __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 = 2763; __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) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2553
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2764
  *     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 = 2553; __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 = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_97), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_100), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __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 = 2553; __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 = 2764; __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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_Raise(__pyx_t_4, 0, 0);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
@@ -23543,29 +25728,29 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2556
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2767
  * 
  *     # redirect stderr and stdout to file
  *     if catch_stderr:             # <<<<<<<<<<<<<<
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2557
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2768
  *     # redirect stderr and stdout to file
  *     if catch_stderr:
  *         stderr_h, stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         stderr_save = Outs( sys.stderr.fileno() )
  *         stderr_save.setfd( 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 = 2557; __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 = 2768; __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 = 2557; __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 = 2768; __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 = 2557; __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 = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
@@ -23580,14 +25765,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_v_stderr_f = __pyx_t_1;
       __pyx_t_1 = 0;
     } else {
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2557; __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 = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_v_stderr_h);
       __pyx_v_stderr_h = __pyx_t_3;
@@ -23597,32 +25782,32 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_t_1 = 0;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2558
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2769
  *     if catch_stderr:
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
  *         stderr_save.setfd( stderr_h )
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2558; __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 = 2769; __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 = 2558; __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 = 2769; __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__fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __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 = 2558; __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 = 2769; __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 = 2558; __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 = 2769; __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_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __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;
@@ -23630,21 +25815,21 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __pyx_v_stderr_save = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2559
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2770
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )
  *         stderr_save.setfd( stderr_h )             # <<<<<<<<<<<<<<
  * 
  *     if catch_stdout:
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __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 = 2559; __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 = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_stderr_h);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_h);
     __Pyx_GIVEREF(__pyx_v_stderr_h);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -23653,29 +25838,29 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2561
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2772
  *         stderr_save.setfd( stderr_h )
  * 
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2561; __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 = 2772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2562
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2773
  * 
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         stdout_save = Outs( sys.stdout.fileno() )
  *         stdout_save.setfd( stdout_h )
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __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 = 2773; __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 = 2562; __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 = 2773; __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 = 2562; __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 = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
@@ -23690,14 +25875,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_v_stdout_f = __pyx_t_3;
       __pyx_t_3 = 0;
     } else {
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __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 = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_v_stdout_h);
       __pyx_v_stdout_h = __pyx_t_1;
@@ -23707,32 +25892,32 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_t_3 = 0;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2563
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2774
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )             # <<<<<<<<<<<<<<
  *         stdout_save.setfd( stdout_h )
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2563; __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 = 2774; __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 = 2563; __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 = 2774; __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__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2563; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2774; __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 = 2563; __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 = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2563; __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 = 2774; __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_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -23740,79 +25925,79 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __pyx_v_stdout_save = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2564
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2775
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )
  *         stdout_save.setfd( stdout_h )             # <<<<<<<<<<<<<<
  * 
  *         # patch for `samtools view`
  */
-    __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 = 2564; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 2775; __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 = 2564; __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 = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2569
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2780
  *         # 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_4 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2569; __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 = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_5) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2570
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2781
  *         # 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 = ((PySequence_Contains(__pyx_v_args, ((PyObject *)__pyx_kp_s_98)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = ((PySequence_Contains(__pyx_v_args, ((PyObject *)__pyx_kp_s_101)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_5) {
-        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2570; __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 = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_4);
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_99));
-        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_99));
-        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_99));
-        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_102));
+        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_102));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_102));
+        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
         __Pyx_Raise(__pyx_t_3, 0, 0);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L11;
       }
       __pyx_L11:;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2571
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2782
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
  *             args = ( "-o", stdout_f ) + args             # <<<<<<<<<<<<<<
  * 
  * 
  */
-      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2571; __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 = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_98));
-      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_98));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_98));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_101));
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_101));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_101));
       __Pyx_INCREF(__pyx_v_stdout_f);
       PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_stdout_f);
       __Pyx_GIVEREF(__pyx_v_stdout_f);
-      __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_args); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_args); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_DECREF(__pyx_v_args);
@@ -23825,17 +26010,17 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2578
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2789
  *     cdef int i, n, retval
  * 
  *     n = len(args)             # <<<<<<<<<<<<<<
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  */
-  __pyx_t_7 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_n = __pyx_t_7;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2580
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2791
  *     n = len(args)
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )             # <<<<<<<<<<<<<<
@@ -23844,7 +26029,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   __pyx_v_cargs = ((char **)calloc((__pyx_v_n + 2), (sizeof(char *))));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2581
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2792
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"             # <<<<<<<<<<<<<<
@@ -23853,17 +26038,17 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   (__pyx_v_cargs[0]) = __pyx_k__samtools;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2582
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2793
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"
  *     cargs[1] = method             # <<<<<<<<<<<<<<
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
  *     retval = pysam_dispatch(n+2, cargs)
  */
-  __pyx_t_8 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   (__pyx_v_cargs[1]) = __pyx_t_8;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2583
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2794
  *     cargs[0] = "samtools"
  *     cargs[1] = method
  *     for i from 0 <= i < n: cargs[i+2] = args[i]             # <<<<<<<<<<<<<<
@@ -23872,14 +26057,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   __pyx_t_9 = __pyx_v_n;
   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
-    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_8 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     (__pyx_v_cargs[(__pyx_v_i + 2)]) = __pyx_t_8;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2584
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2795
  *     cargs[1] = method
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
  *     retval = pysam_dispatch(n+2, cargs)             # <<<<<<<<<<<<<<
@@ -23888,7 +26073,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   __pyx_v_retval = pysam_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2585
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2796
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
  *     retval = pysam_dispatch(n+2, cargs)
  *     free( cargs )             # <<<<<<<<<<<<<<
@@ -23897,38 +26082,38 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   free(__pyx_v_cargs);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2589
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2800
  *     # restore stdout/stderr. This will also flush, so
  *     # needs to be before reading back the file contents
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2589; __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 = 2800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2590
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2801
  *     # needs to be before reading back the file contents
  *     if catch_stdout:
  *         stdout_save.restore()             # <<<<<<<<<<<<<<
  *         out_stdout = open( stdout_f, "r").readlines()
  *         os.remove( stdout_f )
  */
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __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_3); __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2591
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2802
  *     if catch_stdout:
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()             # <<<<<<<<<<<<<<
  *         os.remove( stdout_f )
  *     else:
  */
-    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __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 = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_stdout_f);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_f);
@@ -23936,37 +26121,37 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __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_4 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __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 = 2591; __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 = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_out_stdout);
     __pyx_v_out_stdout = __pyx_t_4;
     __pyx_t_4 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2592
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2803
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()
  *         os.remove( stdout_f )             # <<<<<<<<<<<<<<
  *     else:
  *         out_stdout = []
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__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 = 2592; __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 = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_INCREF(__pyx_v_stdout_f);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stdout_f);
     __Pyx_GIVEREF(__pyx_v_stdout_f);
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __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;
@@ -23975,14 +26160,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2594
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2805
  *         os.remove( stdout_f )
  *     else:
  *         out_stdout = []             # <<<<<<<<<<<<<<
  * 
  *     if catch_stderr:
  */
-    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __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 = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_v_out_stdout);
     __pyx_v_out_stdout = ((PyObject *)__pyx_t_1);
@@ -23990,38 +26175,38 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L14:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2596
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2807
  *         out_stdout = []
  * 
  *     if catch_stderr:             # <<<<<<<<<<<<<<
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2597
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2808
  * 
  *     if catch_stderr:
  *         stderr_save.restore()             # <<<<<<<<<<<<<<
  *         out_stderr = open( stderr_f, "r").readlines()
  *         os.remove( stderr_f )
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __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 = 2597; __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 = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2598
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2809
  *     if catch_stderr:
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()             # <<<<<<<<<<<<<<
  *         os.remove( stderr_f )
  *     else:
  */
-    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __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 = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_INCREF(__pyx_v_stderr_f);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stderr_f);
@@ -24029,37 +26214,37 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
     PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_open, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_open, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __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_GetAttr(__pyx_t_1, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __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 = 2598; __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 = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_v_out_stderr);
     __pyx_v_out_stderr = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2599
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2810
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()
  *         os.remove( stderr_f )             # <<<<<<<<<<<<<<
  *     else:
  *         out_stderr = []
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2599; __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 = 2810; __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 = 2599; __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 = 2810; __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 = 2599; __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 = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __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;
@@ -24068,14 +26253,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2601
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2812
  *         os.remove( stderr_f )
  *     else:
  *         out_stderr = []             # <<<<<<<<<<<<<<
  * 
  *     return retval, out_stderr, out_stdout
  */
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __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 = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_DECREF(__pyx_v_out_stderr);
     __pyx_v_out_stderr = ((PyObject *)__pyx_t_3);
@@ -24083,7 +26268,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L15:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2603
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2814
  *         out_stderr = []
  * 
  *     return retval, out_stderr, out_stdout             # <<<<<<<<<<<<<<
@@ -24091,9 +26276,9 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  * 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 = 2603; __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 = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __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 = 2814; __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);
@@ -24133,7 +26318,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2618
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2829
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24147,9 +26332,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2618);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2829);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2619
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2830
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):
  *             return self._tid             # <<<<<<<<<<<<<<
@@ -24157,7 +26342,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
  *     property pos:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24176,7 +26361,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2623
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2834
  *     property pos:
  *        '''nucleotide position of SNP.'''
  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
@@ -24190,9 +26375,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2623);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2834);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24211,7 +26396,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2627
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2838
  *     property reference_base:
  *        '''reference base at pos. ``N`` if no reference sequence supplied.'''
  *        def __get__(self): return PyString_FromStringAndSize( &self._reference_base, 1 )             # <<<<<<<<<<<<<<
@@ -24225,9 +26410,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2627);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2838);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24246,7 +26431,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2631
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2842
  *     property genotype:
  *        '''the genotype called.'''
  *        def __get__(self): return PyString_FromStringAndSize( &self._genotype, 1 )             # <<<<<<<<<<<<<<
@@ -24260,9 +26445,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2631);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2842);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24281,7 +26466,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2635
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2846
  *     property consensus_quality:
  *        '''the genotype quality (Phred-scaled).'''
  *        def __get__(self): return self._consensus_quality             # <<<<<<<<<<<<<<
@@ -24295,9 +26480,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObje
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2635);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2846);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24316,7 +26501,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObje
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2639
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2850
  *     property snp_quality:
  *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
  *        def __get__(self): return self._snp_quality             # <<<<<<<<<<<<<<
@@ -24330,9 +26515,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2639);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2850);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24351,7 +26536,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2643
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2854
  *     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             # <<<<<<<<<<<<<<
@@ -24365,9 +26550,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2643);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2854);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24386,7 +26571,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2647
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2858
  *     property coverage:
  *        '''coverage or read depth - the number of reads involved in the call.'''
  *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
@@ -24400,9 +26585,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2647);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2858);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24421,7 +26606,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2649
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2860
  *        def __get__(self): return self._coverage
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -24444,9 +26629,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_t_10 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2649);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2860);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2651
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2862
  *     def __str__(self):
  * 
  *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
@@ -24454,89 +26639,89 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
  *                     self.pos,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2652
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2863
  * 
  *         return "\t".join( map(str, (
  *                     self.tid,             # <<<<<<<<<<<<<<
  *                     self.pos,
  *                     self.reference_base,
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __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 = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2653
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2864
  *         return "\t".join( map(str, (
  *                     self.tid,
  *                     self.pos,             # <<<<<<<<<<<<<<
  *                     self.reference_base,
  *                     self.genotype,
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __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 = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2654
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2865
  *                     self.tid,
  *                     self.pos,
  *                     self.reference_base,             # <<<<<<<<<<<<<<
  *                     self.genotype,
  *                     self.consensus_quality,
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2655
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2866
  *                     self.pos,
  *                     self.reference_base,
  *                     self.genotype,             # <<<<<<<<<<<<<<
  *                     self.consensus_quality,
  *                     self.snp_quality,
  */
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2656
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2867
  *                     self.reference_base,
  *                     self.genotype,
  *                     self.consensus_quality,             # <<<<<<<<<<<<<<
  *                     self.snp_quality,
  *                     self.mapping_quality,
  */
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2657
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2868
  *                     self.genotype,
  *                     self.consensus_quality,
  *                     self.snp_quality,             # <<<<<<<<<<<<<<
  *                     self.mapping_quality,
  *                     self.coverage ) ) )
  */
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2658
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2869
  *                     self.consensus_quality,
  *                     self.snp_quality,
  *                     self.mapping_quality,             # <<<<<<<<<<<<<<
  *                     self.coverage ) ) )
  * 
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2659
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2870
  *                     self.snp_quality,
  *                     self.mapping_quality,
  *                     self.coverage ) ) )             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2870; __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 = 2652; __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 = 2863; __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);
@@ -24562,7 +26747,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   __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 = 2651; __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 = 2862; __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)));
@@ -24570,15 +26755,15 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
   __Pyx_GIVEREF(__pyx_t_10);
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __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 = 2651; __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 = 2862; __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, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
@@ -24608,7 +26793,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2680
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2891
  *     cdef IteratorColumn iter
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -24629,7 +26814,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2680);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2891);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -24647,7 +26832,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -24657,16 +26842,16 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   }
   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 = 2680; __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 = 2891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.SNPCallerBase.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2684
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2895
  *                   **kwargs ):
  * 
  *         self.iter = iterator_column             # <<<<<<<<<<<<<<
@@ -24679,7 +26864,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter));
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2685
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2896
  * 
  *         self.iter = iterator_column
  *         self.c =  bam_maqcns_init()             # <<<<<<<<<<<<<<
@@ -24688,7 +26873,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  */
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c = bam_maqcns_init();
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2691
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2902
  * 
  *         # new default mode for samtools >0.1.10
  *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )             # <<<<<<<<<<<<<<
@@ -24696,18 +26881,18 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = PyInt_FromLong(BAM_ERRMOD_MAQ2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(BAM_ERRMOD_MAQ2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __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__errmod), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__errmod), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __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 = 2691; __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 = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2693
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2904
  *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )
  * 
  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )             # <<<<<<<<<<<<<<
@@ -24715,15 +26900,15 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__min_baseQ), __pyx_int_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__min_baseQ), __pyx_int_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __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 = 2693; __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 = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->min_baseQ = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2695
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2906
  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
  *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )             # <<<<<<<<<<<<<<
@@ -24731,15 +26916,15 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  *         self.c.theta = kwargs.get( "theta", 0.83 )
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2906; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__n_haplotypes), __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__n_haplotypes), __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2906; __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 = 2695; __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 = 2906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->n_hap = __pyx_t_3;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2696
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2907
  *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
  *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )             # <<<<<<<<<<<<<<
@@ -24747,18 +26932,18 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  * 
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__het_rate), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__het_rate), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __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_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->het_rate = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2697
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2908
  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
  *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )
  *         self.c.theta = kwargs.get( "theta", 0.83 )             # <<<<<<<<<<<<<<
@@ -24766,18 +26951,18 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
  *         if self.c.errmod != BAM_ERRMOD_MAQ2:
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = PyFloat_FromDouble(0.83); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyFloat_FromDouble(0.83); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __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__theta), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__theta), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2699
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2910
  *         self.c.theta = kwargs.get( "theta", 0.83 )
  * 
  *         if self.c.errmod != BAM_ERRMOD_MAQ2:             # <<<<<<<<<<<<<<
@@ -24787,7 +26972,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   __pyx_t_5 = (((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod != BAM_ERRMOD_MAQ2);
   if (__pyx_t_5) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2700
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2911
  * 
  *         if self.c.errmod != BAM_ERRMOD_MAQ2:
  *             self.c.theta += 0.02             # <<<<<<<<<<<<<<
@@ -24799,7 +26984,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2703
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2914
  * 
  *         # call prepare AFTER setting parameters
  *         bam_maqcns_prepare( self.c )             # <<<<<<<<<<<<<<
@@ -24822,7 +27007,7 @@ static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2705
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2916
  *         bam_maqcns_prepare( self.c )
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -24834,9 +27019,9 @@ static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_se
 static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2705);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2916);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2706
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2917
  * 
  *     def __dealloc__(self):
  *         bam_maqcns_destroy( self.c )             # <<<<<<<<<<<<<<
@@ -24849,7 +27034,7 @@ static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_se
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2708
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2919
  *         bam_maqcns_destroy( self.c )
  * 
  *     cdef __dump( self, glf1_t * g, uint32_t cns, int rb ):             # <<<<<<<<<<<<<<
@@ -24875,9 +27060,9 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
   PyObject *__pyx_t_13 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dump");
-  __Pyx_TraceCall("__dump", __pyx_f[0], 2708);
+  __Pyx_TraceCall("__dump", __pyx_f[0], 2919);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2711
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2922
  *         '''debugging output.'''
  * 
  *         pysam_dump_glf( g, self.c );             # <<<<<<<<<<<<<<
@@ -24886,16 +27071,16 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
  */
   pysam_dump_glf(__pyx_v_g, __pyx_v_self->c);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2712
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2923
  * 
  *         pysam_dump_glf( g, self.c );
  *         print ""             # <<<<<<<<<<<<<<
  *         for x in range(self.iter.n_plp):
  *             print "--> read %i %s %i" % (x,
  */
-  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2713
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2924
  *         pysam_dump_glf( g, self.c );
  *         print ""
  *         for x in range(self.iter.n_plp):             # <<<<<<<<<<<<<<
@@ -24906,36 +27091,36 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
   for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
     __pyx_v_x = __pyx_t_2;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2714
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2925
  *         print ""
  *         for x in range(self.iter.n_plp):
  *             print "--> read %i %s %i" % (x,             # <<<<<<<<<<<<<<
  *                                          bam1_qname(self.iter.plp[x].b),
  *                                          self.iter.plp[x].qpos,
  */
-    __pyx_t_3 = PyInt_FromLong(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2715
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2926
  *         for x in range(self.iter.n_plp):
  *             print "--> read %i %s %i" % (x,
  *                                          bam1_qname(self.iter.plp[x].b),             # <<<<<<<<<<<<<<
  *                                          self.iter.plp[x].qpos,
  *                                          )
  */
-    __pyx_t_4 = PyBytes_FromString(bam1_qname((__pyx_v_self->iter->plp[__pyx_v_x]).b)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyBytes_FromString(bam1_qname((__pyx_v_self->iter->plp[__pyx_v_x]).b)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2716
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2927
  *             print "--> read %i %s %i" % (x,
  *                                          bam1_qname(self.iter.plp[x].b),
  *                                          self.iter.plp[x].qpos,             # <<<<<<<<<<<<<<
  *                                          )
  * 
  */
-    __pyx_t_5 = __Pyx_PyInt_to_py_int32_t((__pyx_v_self->iter->plp[__pyx_v_x]).qpos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyInt_to_py_int32_t((__pyx_v_self->iter->plp[__pyx_v_x]).qpos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2927; __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 = 2714; __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 = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
@@ -24946,113 +27131,113 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
     __pyx_t_3 = 0;
     __pyx_t_4 = 0;
     __pyx_t_5 = 0;
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_101), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_104), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2720
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2931
  * 
  *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
  *             % (self.iter.pos,             # <<<<<<<<<<<<<<
  *                cns,
  *                self.c.q_r,
  */
-  __pyx_t_5 = PyInt_FromLong(__pyx_v_self->iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyInt_FromLong(__pyx_v_self->iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2721
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2932
  *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
  *             % (self.iter.pos,
  *                cns,             # <<<<<<<<<<<<<<
  *                self.c.q_r,
  *                self.iter.n_plp,
  */
-  __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_cns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_cns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2722
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2933
  *             % (self.iter.pos,
  *                cns,
  *                self.c.q_r,             # <<<<<<<<<<<<<<
  *                self.iter.n_plp,
  *                self.iter.n_plp,
  */
-  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->c->q_r); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->c->q_r); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2723
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2934
  *                cns,
  *                self.c.q_r,
  *                self.iter.n_plp,             # <<<<<<<<<<<<<<
  *                self.iter.n_plp,
  *                rb,
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2724
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2935
  *                self.c.q_r,
  *                self.iter.n_plp,
  *                self.iter.n_plp,             # <<<<<<<<<<<<<<
  *                rb,
  *                cns >> 8 & 0xff,
  */
-  __pyx_t_7 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2725
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2936
  *                self.iter.n_plp,
  *                self.iter.n_plp,
  *                rb,             # <<<<<<<<<<<<<<
  *                cns >> 8 & 0xff,
  *                cns >> 16 & 0xff,
  */
-  __pyx_t_8 = PyInt_FromLong(__pyx_v_rb); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyInt_FromLong(__pyx_v_rb); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2726
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2937
  *                self.iter.n_plp,
  *                rb,
  *                cns >> 8 & 0xff,             # <<<<<<<<<<<<<<
  *                cns >> 16 & 0xff,
  *                cns & 0xff,
  */
-  __pyx_t_9 = PyInt_FromLong(((__pyx_v_cns >> 8) & 0xff)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyInt_FromLong(((__pyx_v_cns >> 8) & 0xff)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2727
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2938
  *                rb,
  *                cns >> 8 & 0xff,
  *                cns >> 16 & 0xff,             # <<<<<<<<<<<<<<
  *                cns & 0xff,
  *                cns >> 28,
  */
-  __pyx_t_10 = PyInt_FromLong(((__pyx_v_cns >> 16) & 0xff)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyInt_FromLong(((__pyx_v_cns >> 16) & 0xff)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2728
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2939
  *                cns >> 8 & 0xff,
  *                cns >> 16 & 0xff,
  *                cns & 0xff,             # <<<<<<<<<<<<<<
  *                cns >> 28,
  *                )
  */
-  __pyx_t_11 = PyInt_FromLong((__pyx_v_cns & 0xff)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = PyInt_FromLong((__pyx_v_cns & 0xff)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_11);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2729
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2940
  *                cns >> 16 & 0xff,
  *                cns & 0xff,
  *                cns >> 28,             # <<<<<<<<<<<<<<
  *                )
  * 
  */
-  __pyx_t_12 = PyInt_FromLong((__pyx_v_cns >> 28)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyInt_FromLong((__pyx_v_cns >> 28)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
-  __pyx_t_13 = PyTuple_New(10); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyTuple_New(10); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
@@ -25084,37 +27269,37 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
   __pyx_t_10 = 0;
   __pyx_t_11 = 0;
   __pyx_t_12 = 0;
-  __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_102), __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_105), __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_12));
   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
-  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_12)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_12)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2732
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2943
  *                )
  * 
  *         printf("-------------------------------------\n");             # <<<<<<<<<<<<<<
  *         sys.stdout.flush()
  * 
  */
-  printf(__pyx_k_103);
+  printf(__pyx_k_106);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2733
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2944
  * 
  *         printf("-------------------------------------\n");
  *         sys.stdout.flush()             # <<<<<<<<<<<<<<
  * 
  * cdef class IteratorSNPCalls( SNPCallerBase ):
  */
-  __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
-  __pyx_t_13 = PyObject_GetAttr(__pyx_t_12, __pyx_n_s__stdout); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_GetAttr(__pyx_t_12, __pyx_n_s__stdout); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-  __pyx_t_12 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__flush); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__flush); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
-  __pyx_t_13 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
@@ -25142,7 +27327,7 @@ static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9cs
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2749
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2960
  *     """
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -25161,7 +27346,7 @@ static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_se
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2749);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2960);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -25179,7 +27364,7 @@ static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_se
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -25189,16 +27374,16 @@ static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_se
   }
   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 = 2749; __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 = 2960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2753
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2964
  *                   **kwargs ):
  * 
  *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
@@ -25206,16 +27391,16 @@ static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_se
  *     def __iter__(self):
  */
   #ifndef PYREX_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__hasReference); 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_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __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 = 2964; __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 = 2753; __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 = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (unlikely(!__pyx_t_3)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_104));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_107));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
@@ -25233,7 +27418,7 @@ static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2755
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2966
  *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -25246,9 +27431,9 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 2755);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 2966);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2756
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2967
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -25268,7 +27453,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2758
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2969
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -25294,10 +27479,10 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 2758);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 2969);
   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2763
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2974
  * 
  *         # the following code was adapted from bam_plcmd.c:pileup_func()
  *         self.iter.cnext()             # <<<<<<<<<<<<<<
@@ -25306,7 +27491,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2765
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2976
  *         self.iter.cnext()
  * 
  *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -25316,29 +27501,29 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2766
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2977
  * 
  *         if self.iter.n_plp < 0:
  *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *         if self.iter.plp == NULL:
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __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 = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_56));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2768
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2979
  *             raise ValueError("error during iteration" )
  * 
  *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
@@ -25348,7 +27533,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2769
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2980
  * 
  *         if self.iter.plp == NULL:
  *            raise StopIteration             # <<<<<<<<<<<<<<
@@ -25356,12 +27541,12 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  *         cdef char * seq = self.iter.getSequence()
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2771
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2982
  *            raise StopIteration
  * 
  *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
@@ -25370,20 +27555,20 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2772
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2983
  * 
  *         cdef char * seq = self.iter.getSequence()
  *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
  * 
  *         assert seq != NULL
  */
-  __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __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 = 2772; __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 = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_seq_len = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2774
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2985
  *         cdef int seq_len = self.iter.seq_len
  * 
  *         assert seq != NULL             # <<<<<<<<<<<<<<
@@ -25393,11 +27578,11 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_seq != NULL))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2777
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2988
  * 
  *         # reference base
  *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
@@ -25407,18 +27592,18 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2778
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2989
  *         # reference base
  *         if self.iter.pos >= seq_len:
  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
  * 
  *         cdef int rb = seq[self.iter.pos]
  */
-    __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __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 = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
@@ -25426,25 +27611,25 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_3 = 0;
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_105), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(__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 = 2778; __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 = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2780
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2991
  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
  * 
  *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
@@ -25453,7 +27638,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos]);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2787
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2998
  *                                self.iter.plp,
  *                                bam_nt16_table[rb],
  *                                self.c )             # <<<<<<<<<<<<<<
@@ -25462,7 +27647,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_g = bam_maqcns_glfgen(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp, ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp, (bam_nt16_table[__pyx_v_rb]), ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.c);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2789
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3000
  *                                self.c )
  * 
  *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
@@ -25472,7 +27657,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   __pyx_t_1 = (pysam_glf_depth(__pyx_v_g) == 0);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2790
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3001
  * 
  *         if pysam_glf_depth( g ) == 0:
  *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
@@ -25484,7 +27669,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2792
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3003
  *             cns = 0xfu << 28 | 0xf << 24
  *         else:
  *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
@@ -25495,7 +27680,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2794
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3005
  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
  * 
  *         free(g)             # <<<<<<<<<<<<<<
@@ -25504,20 +27689,20 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   free(__pyx_v_g);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2798
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3009
  *         cdef SNPCall call
  * 
  *         call = SNPCall()             # <<<<<<<<<<<<<<
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos
  */
-  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(((PyObject *)__pyx_v_call));
   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2799
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3010
  * 
  *         call = SNPCall()
  *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
@@ -25526,7 +27711,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->tid;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2800
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3011
  *         call = SNPCall()
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
@@ -25535,7 +27720,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2801
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3012
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos
  *         call._reference_base = rb             # <<<<<<<<<<<<<<
@@ -25544,7 +27729,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_reference_base = __pyx_v_rb;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2802
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3013
  *         call._pos = self.iter.pos
  *         call._reference_base = rb
  *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
@@ -25553,7 +27738,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2803
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3014
  *         call._reference_base = rb
  *         call._genotype = bam_nt16_rev_table[cns>>28]
  *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
@@ -25562,7 +27747,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2804
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3015
  *         call._genotype = bam_nt16_rev_table[cns>>28]
  *         call._consensus_quality = cns >> 8 & 0xff
  *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
@@ -25571,7 +27756,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2805
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3016
  *         call._consensus_quality = cns >> 8 & 0xff
  *         call._snp_quality = cns & 0xff
  *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
@@ -25580,7 +27765,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2806
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3017
  *         call._snp_quality = cns & 0xff
  *         call._rms_mapping_quality = cns >> 16&0xff
  *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
@@ -25589,7 +27774,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
  */
   __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2808
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3019
  *         call._coverage = self.iter.n_plp
  * 
  *         return call             # <<<<<<<<<<<<<<
@@ -25617,7 +27802,7 @@ static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2824
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3035
  * 
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -25633,7 +27818,7 @@ static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyOb
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2824);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3035);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -25651,7 +27836,7 @@ static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyOb
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -25661,14 +27846,14 @@ static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyOb
   }
   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 = 2824; __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 = 3035; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.SNPCaller.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -25682,7 +27867,7 @@ static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2830
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3041
  *         pass
  * 
  *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
@@ -25691,7 +27876,7 @@ static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyOb
  */
 
 static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_9SNPCaller_call[] = "call a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object.\n        ";
+static char __pyx_doc_9csamtools_9SNPCaller_call[] = "SNPCaller.call(self, reference, int pos)\ncall a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object.\n        ";
 static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   int __pyx_v_pos;
@@ -25712,7 +27897,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("call");
-  __Pyx_TraceCall("call", __pyx_f[0], 2830);
+  __Pyx_TraceCall("call", __pyx_f[0], 3041);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -25731,23 +27916,23 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
-    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
     goto __pyx_L5_argtuple_error;
   } else {
     __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
-    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.SNPCaller.call");
   __Pyx_RefNannyFinishContext();
@@ -25755,49 +27940,49 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2837
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3048
  *         """
  * 
  *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
  * 
  *         self.iter.reset( tid, pos, pos + 1 )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; __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 = 3048; __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);
   __Pyx_GIVEREF(__pyx_v_reference);
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __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_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 = 2837; __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 = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_tid = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2839
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3050
  *         cdef int tid = self.iter.samfile.gettid( reference )
  * 
  *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
  * 
  *         while 1:
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2841
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3052
  *         self.iter.reset( tid, pos, pos + 1 )
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -25807,7 +27992,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   while (1) {
     if (!1) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2842
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3053
  * 
  *         while 1:
  *             self.iter.cnext()             # <<<<<<<<<<<<<<
@@ -25816,7 +28001,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2844
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3055
  *             self.iter.cnext()
  * 
  *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -25826,29 +28011,29 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
     __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
     if (__pyx_t_6) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2845
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3056
  * 
  *             if self.iter.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             if self.iter.plp == NULL:
  */
-      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __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 = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_56));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2847
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3058
  *                 raise ValueError("error during iteration" )
  * 
  *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
@@ -25858,29 +28043,29 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
     __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
     if (__pyx_t_6) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2848
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3059
  * 
  *             if self.iter.plp == NULL:
  *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
  * 
  *             if self.iter.pos == pos: break
  */
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __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 = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_106));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_106));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_106));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2850
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3061
  *                 raise ValueError( "no reads in region - no call" )
  * 
  *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
@@ -25896,7 +28081,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   }
   __pyx_L7_break:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2852
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3063
  *             if self.iter.pos == pos: break
  * 
  *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
@@ -25905,20 +28090,20 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2853
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3064
  * 
  *         cdef char * seq = self.iter.getSequence()
  *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
  * 
  *         assert seq != NULL
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __pyx_v_seq_len = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2855
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3066
  *         cdef int seq_len = self.iter.seq_len
  * 
  *         assert seq != NULL             # <<<<<<<<<<<<<<
@@ -25928,11 +28113,11 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_seq != NULL))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2858
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3069
  * 
  *         # reference base
  *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
@@ -25942,18 +28127,18 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2859
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3070
  *         # reference base
  *         if self.iter.pos >= seq_len:
  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
  * 
  *         cdef int rb = seq[self.iter.pos]
  */
-    __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_1 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __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 = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
     __Pyx_GIVEREF(__pyx_t_5);
@@ -25961,25 +28146,25 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_5 = 0;
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_105), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__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 = 2859; __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 = 3070; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L11;
   }
   __pyx_L11:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2861
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3072
  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
  * 
  *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
@@ -25988,7 +28173,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos]);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2868
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3079
  *                                self.iter.plp,
  *                                bam_nt16_table[rb],
  *                                self.c )             # <<<<<<<<<<<<<<
@@ -25997,7 +28182,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_g = bam_maqcns_glfgen(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp, ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp, (bam_nt16_table[__pyx_v_rb]), ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.c);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2871
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3082
  * 
  * 
  *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
@@ -26007,7 +28192,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   __pyx_t_6 = (pysam_glf_depth(__pyx_v_g) == 0);
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2872
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3083
  * 
  *         if pysam_glf_depth( g ) == 0:
  *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
@@ -26019,7 +28204,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2874
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3085
  *             cns = 0xfu << 28 | 0xf << 24
  *         else:
  *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
@@ -26030,7 +28215,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   }
   __pyx_L12:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2876
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3087
  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
  * 
  *         free(g)             # <<<<<<<<<<<<<<
@@ -26039,20 +28224,20 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   free(__pyx_v_g);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2880
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3091
  *         cdef SNPCall call
  * 
  *         call = SNPCall()             # <<<<<<<<<<<<<<
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos
  */
-  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_v_call));
   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2881
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3092
  * 
  *         call = SNPCall()
  *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
@@ -26061,7 +28246,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->tid;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2882
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3093
  *         call = SNPCall()
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
@@ -26070,7 +28255,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2883
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3094
  *         call._tid = self.iter.tid
  *         call._pos = self.iter.pos
  *         call._reference_base = rb             # <<<<<<<<<<<<<<
@@ -26079,7 +28264,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_reference_base = __pyx_v_rb;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2884
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3095
  *         call._pos = self.iter.pos
  *         call._reference_base = rb
  *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
@@ -26088,7 +28273,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2885
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3096
  *         call._reference_base = rb
  *         call._genotype = bam_nt16_rev_table[cns>>28]
  *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
@@ -26097,7 +28282,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2886
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3097
  *         call._genotype = bam_nt16_rev_table[cns>>28]
  *         call._consensus_quality = cns >> 8 & 0xff
  *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
@@ -26106,7 +28291,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2887
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3098
  *         call._consensus_quality = cns >> 8 & 0xff
  *         call._snp_quality = cns & 0xff
  *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
@@ -26115,7 +28300,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2888
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3099
  *         call._snp_quality = cns & 0xff
  *         call._rms_mapping_quality = cns >> 16&0xff
  *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
@@ -26124,7 +28309,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2890
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3101
  *         call._coverage = self.iter.n_plp
  * 
  *         return call             # <<<<<<<<<<<<<<
@@ -26153,7 +28338,7 @@ static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyO
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2900
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3111
  *     cdef bam_maqindel_ret_t * _r
  * 
  *     def __cinit__(self):             # <<<<<<<<<<<<<<
@@ -26166,7 +28351,7 @@ static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyOb
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2900);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3111);
   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
     __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
@@ -26177,7 +28362,7 @@ static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2907
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3118
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -26191,9 +28376,9 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_s
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2907);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3118);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2908
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3119
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):
  *             return self._tid             # <<<<<<<<<<<<<<
@@ -26201,7 +28386,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_s
  *     property pos:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26220,7 +28405,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2912
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3123
  *     property pos:
  *        '''nucleotide position of SNP.'''
  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
@@ -26234,9 +28419,9 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_s
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2912);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3123);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26255,7 +28440,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2916
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3127
  *     property genotype:
  *        '''the genotype called.'''
  *        def __get__(self):             # <<<<<<<<<<<<<<
@@ -26272,10 +28457,10 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2916);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3127);
   __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2917
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3128
  *        '''the genotype called.'''
  *        def __get__(self):
  *            if self._r.gt == 0:             # <<<<<<<<<<<<<<
@@ -26285,20 +28470,20 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
   switch (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->gt) {
     case 0:
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2918
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3129
  *        def __get__(self):
  *            if self._r.gt == 0:
  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
  *                return "%s/%s" % (s,s)
  *            elif self._r.gt == 1:
  */
-    __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_v_s);
     __pyx_v_s = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2919
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3130
  *            if self._r.gt == 0:
  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
  *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
@@ -26306,7 +28491,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __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 = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_s);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
@@ -26314,7 +28499,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
     __Pyx_INCREF(__pyx_v_s);
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_s);
     __Pyx_GIVEREF(__pyx_v_s);
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_107), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_r = ((PyObject *)__pyx_t_2);
@@ -26322,7 +28507,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
     goto __pyx_L0;
     break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2920
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3131
  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
  *                return "%s/%s" % (s,s)
  *            elif self._r.gt == 1:             # <<<<<<<<<<<<<<
@@ -26331,20 +28516,20 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
  */
     case 1:
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2921
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3132
  *                return "%s/%s" % (s,s)
  *            elif self._r.gt == 1:
  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
  *                return "%s/%s" % (s,s)
  *            else:
  */
-    __pyx_t_2 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_s);
     __pyx_v_s = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2922
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3133
  *            elif self._r.gt == 1:
  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
  *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
@@ -26352,7 +28537,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
  *                return "%s/%s" % (self.first_allele, self.second_allele )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __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 = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_s);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
@@ -26360,7 +28545,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
     __Pyx_INCREF(__pyx_v_s);
     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_s);
     __Pyx_GIVEREF(__pyx_v_s);
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_107), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_r = ((PyObject *)__pyx_t_1);
@@ -26369,7 +28554,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
     break;
     default:
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2924
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3135
  *                return "%s/%s" % (s,s)
  *            else:
  *                return "%s/%s" % (self.first_allele, self.second_allele )             # <<<<<<<<<<<<<<
@@ -26377,11 +28562,11 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
  *     property consensus_quality:
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __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 = 2924; __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 = 3135; __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);
@@ -26389,7 +28574,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_1 = 0;
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_107), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_r = ((PyObject *)__pyx_t_2);
@@ -26402,35 +28587,175 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__py
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("csamtools.IndelCall.genotype.__get__");
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("csamtools.IndelCall.genotype.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3139
+ *     property consensus_quality:
+ *        '''the genotype quality (Phred-scaled).'''
+ *        def __get__(self): return self._r.q_cns             # <<<<<<<<<<<<<<
+ * 
+ *     property snp_quality:
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3139);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_cns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __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("csamtools.IndelCall.consensus_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3143
+ *     property snp_quality:
+ *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
+ *        def __get__(self): return self._r.q_ref             # <<<<<<<<<<<<<<
+ * 
+ *     property mapping_quality:
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3143);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __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("csamtools.IndelCall.snp_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3147
+ *     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             # <<<<<<<<<<<<<<
+ * 
+ *     property coverage:
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3147);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __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("csamtools.IndelCall.mapping_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3151
+ *     property coverage:
+ *        '''coverage or read depth - the number of reads involved in the call.'''
+ *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
+ * 
+ *     property first_allele:
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3151);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3151; __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("csamtools.IndelCall.coverage.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_s);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2928
- *     property consensus_quality:
- *        '''the genotype quality (Phred-scaled).'''
- *        def __get__(self): return self._r.q_cns             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3155
+ *     property first_allele:
+ *        '''sequence of first allele.'''
+ *        def __get__(self): return PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
  * 
- *     property snp_quality:
+ *     property second_allele:
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2928);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3155);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_cns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26440,7 +28765,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyOb
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.consensus_quality.__get__");
+  __Pyx_AddTraceback("csamtools.IndelCall.first_allele.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26449,23 +28774,23 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2932
- *     property snp_quality:
- *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
- *        def __get__(self): return self._r.q_ref             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3159
+ *     property second_allele:
+ *        '''sequence of second allele.'''
+ *        def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
  * 
- *     property mapping_quality:
+ *     property reads_first:
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2932);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3159);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26475,7 +28800,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.snp_quality.__get__");
+  __Pyx_AddTraceback("csamtools.IndelCall.second_allele.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26484,23 +28809,23 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2936
- *     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             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3163
+ *     property reads_first:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt1             # <<<<<<<<<<<<<<
  * 
- *     property coverage:
+ *     property reads_second:
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2936);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3163);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26510,7 +28835,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObje
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.mapping_quality.__get__");
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_first.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26519,23 +28844,23 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObje
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2940
- *     property coverage:
- *        '''coverage or read depth - the number of reads involved in the call.'''
- *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3167
+ *     property reads_second:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt2             # <<<<<<<<<<<<<<
  * 
- *     property first_allele:
+ *     property reads_diff:
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2940);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3167);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26545,7 +28870,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__py
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.coverage.__get__");
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_second.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26554,23 +28879,23 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2944
- *     property first_allele:
- *        '''sequence of first allele.'''
- *        def __get__(self): return PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3171
+ *     property reads_diff:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt_anti             # <<<<<<<<<<<<<<
  * 
- *     property second_allele:
+ *     def __str__(self):
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2944);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3171);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt_anti); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26580,7 +28905,7 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.first_allele.__get__");
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_diff.__get__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26589,33 +28914,245 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2948
- *     property second_allele:
- *        '''sequence of second allele.'''
- *        def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3173
+ *        def __get__(self): return self._r.cnt_anti
  * 
- *     property reads_first:
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ * 
+ *         return "\t".join( map(str, (
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2948);
+  __Pyx_RefNannySetupContext("__str__");
+  __Pyx_TraceCall("__str__", __pyx_f[0], 3173);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3175
+ *     def __str__(self):
+ * 
+ *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
+ *                     self.tid,
+ *                     self.pos,
+ */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3176
+ * 
+ *         return "\t".join( map(str, (
+ *                     self.tid,             # <<<<<<<<<<<<<<
+ *                     self.pos,
+ *                     self.genotype,
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3177
+ *         return "\t".join( map(str, (
+ *                     self.tid,
+ *                     self.pos,             # <<<<<<<<<<<<<<
+ *                     self.genotype,
+ *                     self.consensus_quality,
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3178
+ *                     self.tid,
+ *                     self.pos,
+ *                     self.genotype,             # <<<<<<<<<<<<<<
+ *                     self.consensus_quality,
+ *                     self.snp_quality,
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3179
+ *                     self.pos,
+ *                     self.genotype,
+ *                     self.consensus_quality,             # <<<<<<<<<<<<<<
+ *                     self.snp_quality,
+ *                     self.mapping_quality,
+ */
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3180
+ *                     self.genotype,
+ *                     self.consensus_quality,
+ *                     self.snp_quality,             # <<<<<<<<<<<<<<
+ *                     self.mapping_quality,
+ *                     self.coverage,
+ */
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3181
+ *                     self.consensus_quality,
+ *                     self.snp_quality,
+ *                     self.mapping_quality,             # <<<<<<<<<<<<<<
+ *                     self.coverage,
+ *                     self.first_allele,
+ */
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3182
+ *                     self.snp_quality,
+ *                     self.mapping_quality,
+ *                     self.coverage,             # <<<<<<<<<<<<<<
+ *                     self.first_allele,
+ *                     self.second_allele,
+ */
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3183
+ *                     self.mapping_quality,
+ *                     self.coverage,
+ *                     self.first_allele,             # <<<<<<<<<<<<<<
+ *                     self.second_allele,
+ *                     self.reads_first,
+ */
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3184
+ *                     self.coverage,
+ *                     self.first_allele,
+ *                     self.second_allele,             # <<<<<<<<<<<<<<
+ *                     self.reads_first,
+ *                     self.reads_second,
+ */
+  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3185
+ *                     self.first_allele,
+ *                     self.second_allele,
+ *                     self.reads_first,             # <<<<<<<<<<<<<<
+ *                     self.reads_second,
+ *                     self.reads_diff ) ) )
+ */
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_first); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3186
+ *                     self.second_allele,
+ *                     self.reads_first,
+ *                     self.reads_second,             # <<<<<<<<<<<<<<
+ *                     self.reads_diff ) ) )
+ * 
+ */
+  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_second); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3187
+ *                     self.reads_first,
+ *                     self.reads_second,
+ *                     self.reads_diff ) ) )             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self ):
+ */
+  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_diff); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
+  __Pyx_GIVEREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
+  __Pyx_GIVEREF(__pyx_t_13);
+  __pyx_t_2 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_6 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_8 = 0;
+  __pyx_t_9 = 0;
+  __pyx_t_10 = 0;
+  __pyx_t_11 = 0;
+  __pyx_t_12 = 0;
+  __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_r = __pyx_t_14;
+  __pyx_t_14 = 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("csamtools.IndelCall.second_allele.__get__");
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_AddTraceback("csamtools.IndelCall.__str__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -26624,407 +29161,589 @@ static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2952
- *     property reads_first:
- *        '''reads supporting first allele.'''
- *        def __get__(self): return self._r.cnt1             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3189
+ *                     self.reads_diff ) ) )
+ * 
+ *     def __dealloc__(self ):             # <<<<<<<<<<<<<<
+ *         bam_maqindel_ret_destroy(self._r)
  * 
- *     property reads_second:
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
+static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2952);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __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_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3189);
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.reads_first.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3190
+ * 
+ *     def __dealloc__(self ):
+ *         bam_maqindel_ret_destroy(self._r)             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IndelCallerBase:
+ */
+  bam_maqindel_ret_destroy(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r);
+
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
-  return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2956
- *     property reads_second:
- *        '''reads supporting first allele.'''
- *        def __get__(self): return self._r.cnt2             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3212
+ *     cdef int max_depth
  * 
- *     property reads_diff:
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
+static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  float __pyx_t_4;
+  int __pyx_t_5;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2956);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3212);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
+  }
+  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 = 3212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3217
+ * 
+ * 
+ *         self.iter = iterator_column             # <<<<<<<<<<<<<<
+ * 
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter));
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3219
+ *         self.iter = iterator_column
+ * 
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
+ * 
+ *         self.options = bam_maqindel_opt_init()
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_iterator_column), __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __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_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __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 = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (unlikely(!__pyx_t_3)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_111));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3221
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
+ * 
+ *         self.options = bam_maqindel_opt_init()             # <<<<<<<<<<<<<<
+ * 
+ *         # set the default parameterization according to
+ */
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options = bam_maqindel_opt_init();
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3226
+ *         # samtools
+ * 
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )             # <<<<<<<<<<<<<<
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = PyFloat_FromDouble(0.00015); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__r_indel), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __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_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->r_indel = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3227
+ * 
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )             # <<<<<<<<<<<<<<
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__q_indel), __pyx_int_40); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->q_indel = __pyx_t_5;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3228
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )             # <<<<<<<<<<<<<<
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ * 
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__cap_mapQ), __pyx_int_60); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ = __pyx_t_5;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3229
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_1024); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth = __pyx_t_5;
+
+  __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.reads_second.__get__");
-  __pyx_r = NULL;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
+  __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2960
- *     property reads_diff:
- *        '''reads supporting first allele.'''
- *        def __get__(self): return self._r.cnt_anti             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3231
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         free( self.options )
  * 
- *     def __str__(self):
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
+static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2960);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt_anti); 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;
-  goto __pyx_L0;
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3231);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3232
+ * 
+ *     def __dealloc__(self):
+ *         free( self.options )             # <<<<<<<<<<<<<<
+ * 
+ *     def _call( self ):
+ */
+  free(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options);
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.IndelCall.reads_diff.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
-  return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2962
- *        def __get__(self): return self._r.cnt_anti
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3234
+ *         free( self.options )
  * 
- *     def __str__(self):             # <<<<<<<<<<<<<<
+ *     def _call( self ):             # <<<<<<<<<<<<<<
  * 
- *         return "\t".join( map(str, (
+ *         cdef char * seq = self.iter.getSequence()
  */
 
-static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_15IndelCallerBase__call[] = "IndelCallerBase._call(self)";
+static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  char *__pyx_v_seq;
+  int __pyx_v_seq_len;
+  bam_maqindel_ret_t *__pyx_v_r;
+  int __pyx_v_m;
+  struct __pyx_obj_9csamtools_IndelCall *__pyx_v_call;
+  uint64_t __pyx_v_rms_aux;
+  int __pyx_v_i;
+  bam_pileup1_t *__pyx_v_p;
+  int __pyx_v_tmp;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
   PyObject *__pyx_t_4 = NULL;
   PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  PyObject *__pyx_t_7 = NULL;
-  PyObject *__pyx_t_8 = NULL;
-  PyObject *__pyx_t_9 = NULL;
-  PyObject *__pyx_t_10 = NULL;
-  PyObject *__pyx_t_11 = NULL;
-  PyObject *__pyx_t_12 = NULL;
-  PyObject *__pyx_t_13 = NULL;
-  PyObject *__pyx_t_14 = NULL;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  double __pyx_t_8;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2962);
+  __Pyx_RefNannySetupContext("_call");
+  __Pyx_TraceCall("_call", __pyx_f[0], 3234);
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2964
- *     def __str__(self):
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3236
+ *     def _call( self ):
+ * 
+ *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
+ *         cdef int seq_len = self.iter.seq_len
  * 
- *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
- *                     self.tid,
- *                     self.pos,
  */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3237
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
+ * 
+ *         assert seq != NULL
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_seq_len = __pyx_t_2;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2965
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3239
+ *         cdef int seq_len = self.iter.seq_len
  * 
- *         return "\t".join( map(str, (
- *                     self.tid,             # <<<<<<<<<<<<<<
- *                     self.pos,
- *                     self.genotype,
+ *         assert seq != NULL             # <<<<<<<<<<<<<<
+ * 
+ *         # reference base
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!(__pyx_v_seq != NULL))) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2966
- *         return "\t".join( map(str, (
- *                     self.tid,
- *                     self.pos,             # <<<<<<<<<<<<<<
- *                     self.genotype,
- *                     self.consensus_quality,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3242
+ * 
+ *         # reference base
+ *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_3 = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos >= __pyx_v_seq_len);
+  if (__pyx_t_3) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2967
- *                     self.tid,
- *                     self.pos,
- *                     self.genotype,             # <<<<<<<<<<<<<<
- *                     self.consensus_quality,
- *                     self.snp_quality,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3243
+ *         # reference base
+ *         if self.iter.pos >= seq_len:
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
+ * 
+ *         cdef bam_maqindel_ret_t * r
+ */
+    __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos); 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_4 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __pyx_t_1 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __Pyx_DECREF(__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 = 3243; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3247
+ *         cdef bam_maqindel_ret_t * r
+ * 
+ *         cdef int m = min( self.max_depth, self.iter.n_plp )             # <<<<<<<<<<<<<<
+ * 
+ *         # printf("pysam: m=%i, q_indel=%i, r_indel=%f, r_snp=%i, mm_penalty=%i, indel_err=%i, ambi_thres=%i\n",
+ */
+  __pyx_t_2 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+  __pyx_t_6 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth;
+  if ((__pyx_t_2 < __pyx_t_6)) {
+    __pyx_t_7 = __pyx_t_2;
+  } else {
+    __pyx_t_7 = __pyx_t_6;
+  }
+  __pyx_v_m = __pyx_t_7;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3259
+ *                          seq,
+ *                          0,
+ *                          NULL)             # <<<<<<<<<<<<<<
+ * 
+ *         if r == NULL: return None
+ */
+  __pyx_v_r = bam_maqindel(__pyx_v_m, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp, __pyx_v_seq, 0, NULL);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3261
+ *                          NULL)
+ * 
+ *         if r == NULL: return None             # <<<<<<<<<<<<<<
+ * 
+ *         cdef IndelCall call
+ */
+  __pyx_t_3 = (__pyx_v_r == NULL);
+  if (__pyx_t_3) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3264
+ * 
+ *         cdef IndelCall call
+ *         call = IndelCall()             # <<<<<<<<<<<<<<
+ *         call._r = r
+ *         call._tid = self.iter.tid
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IndelCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(((PyObject *)__pyx_v_call));
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)__pyx_t_4);
+  __pyx_t_4 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2968
- *                     self.pos,
- *                     self.genotype,
- *                     self.consensus_quality,             # <<<<<<<<<<<<<<
- *                     self.snp_quality,
- *                     self.mapping_quality,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3265
+ *         cdef IndelCall call
+ *         call = IndelCall()
+ *         call._r = r             # <<<<<<<<<<<<<<
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
  */
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_v_call->_r = __pyx_v_r;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2969
- *                     self.genotype,
- *                     self.consensus_quality,
- *                     self.snp_quality,             # <<<<<<<<<<<<<<
- *                     self.mapping_quality,
- *                     self.coverage,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3266
+ *         call = IndelCall()
+ *         call._r = r
+ *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
+ *         call._pos = self.iter.pos
+ *         call._coverage = self.iter.n_plp
  */
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->tid;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2970
- *                     self.consensus_quality,
- *                     self.snp_quality,
- *                     self.mapping_quality,             # <<<<<<<<<<<<<<
- *                     self.coverage,
- *                     self.first_allele,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3267
+ *         call._r = r
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
+ *         call._coverage = self.iter.n_plp
+ * 
  */
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2971
- *                     self.snp_quality,
- *                     self.mapping_quality,
- *                     self.coverage,             # <<<<<<<<<<<<<<
- *                     self.first_allele,
- *                     self.second_allele,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3268
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
+ * 
+ *         cdef uint64_t rms_aux = 0
+ */
+  __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3270
+ *         call._coverage = self.iter.n_plp
+ * 
+ *         cdef uint64_t rms_aux = 0             # <<<<<<<<<<<<<<
+ *         cdef int i = 0
+ *         cdef bam_pileup1_t * p
+ */
+  __pyx_v_rms_aux = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3271
+ * 
+ *         cdef uint64_t rms_aux = 0
+ *         cdef int i = 0             # <<<<<<<<<<<<<<
+ *         cdef bam_pileup1_t * p
+ *         cdef int tmp
+ */
+  __pyx_v_i = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3275
+ *         cdef int tmp
+ * 
+ *         for i from 0 <= i < self.iter.n_plp:             # <<<<<<<<<<<<<<
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:
+ */
+  __pyx_t_7 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3276
+ * 
+ *         for i from 0 <= i < self.iter.n_plp:
+ *             p = self.iter.plp + i             # <<<<<<<<<<<<<<
+ *             if p.b.core.qual < self.cap_mapQ:
+ *                 tmp = p.b.core.qual
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_8);
+    __pyx_v_p = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp + __pyx_v_i);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2972
- *                     self.mapping_quality,
- *                     self.coverage,
- *                     self.first_allele,             # <<<<<<<<<<<<<<
- *                     self.second_allele,
- *                     self.reads_first,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3277
+ *         for i from 0 <= i < self.iter.n_plp:
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:             # <<<<<<<<<<<<<<
+ *                 tmp = p.b.core.qual
+ *             else:
  */
-  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_3 = (__pyx_v_p->b->core.qual < ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ);
+    if (__pyx_t_3) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2973
- *                     self.coverage,
- *                     self.first_allele,
- *                     self.second_allele,             # <<<<<<<<<<<<<<
- *                     self.reads_first,
- *                     self.reads_second,
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3278
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:
+ *                 tmp = p.b.core.qual             # <<<<<<<<<<<<<<
+ *             else:
+ *                 tmp = self.cap_mapQ
  */
-  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_10);
+      __pyx_v_tmp = __pyx_v_p->b->core.qual;
+      goto __pyx_L9;
+    }
+    /*else*/ {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2974
- *                     self.first_allele,
- *                     self.second_allele,
- *                     self.reads_first,             # <<<<<<<<<<<<<<
- *                     self.reads_second,
- *                     self.reads_diff ) ) )
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3280
+ *                 tmp = p.b.core.qual
+ *             else:
+ *                 tmp = self.cap_mapQ             # <<<<<<<<<<<<<<
+ *             rms_aux += tmp * tmp
+ * 
  */
-  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_first); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_11);
+      __pyx_v_tmp = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ;
+    }
+    __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2975
- *                     self.second_allele,
- *                     self.reads_first,
- *                     self.reads_second,             # <<<<<<<<<<<<<<
- *                     self.reads_diff ) ) )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3281
+ *             else:
+ *                 tmp = self.cap_mapQ
+ *             rms_aux += tmp * tmp             # <<<<<<<<<<<<<<
  * 
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
  */
-  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_second); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_12);
+    __pyx_v_rms_aux += (__pyx_v_tmp * __pyx_v_tmp);
+  }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2976
- *                     self.reads_first,
- *                     self.reads_second,
- *                     self.reads_diff ) ) )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3283
+ *             rms_aux += tmp * tmp
  * 
- *     def __dealloc__(self ):
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)             # <<<<<<<<<<<<<<
+ * 
+ *         return call
  */
-  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_diff); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_13);
-  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_14);
-  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
-  __Pyx_GIVEREF(__pyx_t_2);
-  PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
-  __Pyx_GIVEREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
-  __Pyx_GIVEREF(__pyx_t_5);
-  PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
-  __Pyx_GIVEREF(__pyx_t_6);
-  PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
-  __Pyx_GIVEREF(__pyx_t_7);
-  PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
-  __Pyx_GIVEREF(__pyx_t_8);
-  PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
-  __Pyx_GIVEREF(__pyx_t_9);
-  PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
-  __Pyx_GIVEREF(__pyx_t_10);
-  PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
-  __Pyx_GIVEREF(__pyx_t_11);
-  PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
-  __Pyx_GIVEREF(__pyx_t_12);
-  PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
-  __Pyx_GIVEREF(__pyx_t_13);
-  __pyx_t_2 = 0;
-  __pyx_t_3 = 0;
-  __pyx_t_4 = 0;
-  __pyx_t_5 = 0;
-  __pyx_t_6 = 0;
-  __pyx_t_7 = 0;
-  __pyx_t_8 = 0;
-  __pyx_t_9 = 0;
-  __pyx_t_10 = 0;
-  __pyx_t_11 = 0;
-  __pyx_t_12 = 0;
-  __pyx_t_13 = 0;
-  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_13);
-  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
-  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
-  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
-  __Pyx_GIVEREF(__pyx_t_14);
-  __pyx_t_14 = 0;
-  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_14);
-  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
-  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_13);
-  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
-  __Pyx_GIVEREF(__pyx_t_14);
-  __pyx_t_14 = 0;
-  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_14);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
-  __pyx_r = __pyx_t_14;
-  __pyx_t_14 = 0;
+  __pyx_t_8 = ((double)__pyx_v_rms_aux);
+  if (unlikely(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp == 0)) {
+    PyErr_Format(PyExc_ZeroDivisionError, "float division");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_v_call->_rms_mapping_quality = ((uint64_t)(sqrt((__pyx_t_8 / ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp)) + .499));
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3285
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
+ * 
+ *         return call             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IndelCaller( IndelCallerBase ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_call));
+  __pyx_r = ((PyObject *)__pyx_v_call);
   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_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
   __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_XDECREF(__pyx_t_7);
-  __Pyx_XDECREF(__pyx_t_8);
-  __Pyx_XDECREF(__pyx_t_9);
-  __Pyx_XDECREF(__pyx_t_10);
-  __Pyx_XDECREF(__pyx_t_11);
-  __Pyx_XDECREF(__pyx_t_12);
-  __Pyx_XDECREF(__pyx_t_13);
-  __Pyx_XDECREF(__pyx_t_14);
-  __Pyx_AddTraceback("csamtools.IndelCall.__str__");
+  __Pyx_AddTraceback("csamtools.IndelCallerBase._call");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_call);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2978
- *                     self.reads_diff ) ) )
- * 
- *     def __dealloc__(self ):             # <<<<<<<<<<<<<<
- *         bam_maqindel_ret_destroy(self._r)
- * 
- */
-
-static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self) {
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2978);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2979
- * 
- *     def __dealloc__(self ):
- *         bam_maqindel_ret_destroy(self._r)             # <<<<<<<<<<<<<<
- * 
- * cdef class IndelCallerBase:
- */
-  bam_maqindel_ret_destroy(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r);
-
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3001
- *     cdef int max_depth
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3300
+ *     '''
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
  *                   IteratorColumn iterator_column,
  *                   **kwargs ):
  */
 
-static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
   PyObject *__pyx_v_kwargs = 0;
   int __pyx_r;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  float __pyx_t_4;
-  int __pyx_t_5;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3001);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3300);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -27042,7 +29761,7 @@ static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_sel
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -27052,585 +29771,504 @@ static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_sel
   }
   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 = 3001; __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 = 3300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
+  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3006
- * 
- * 
- *         self.iter = iterator_column             # <<<<<<<<<<<<<<
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3306
+ *         pass
  * 
- *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
+ *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
+ *         """call a snp on chromosome *reference*
+ *         and position *pos*.
  */
-  __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
-  __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
-  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter));
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3008
- *         self.iter = iterator_column
+static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_11IndelCaller_call[] = "IndelCaller.call(self, reference, int pos)\ncall a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object or None, if no indel call could be made.\n        ";
+static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_reference = 0;
+  int __pyx_v_pos;
+  int __pyx_v_tid;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("call");
+  __Pyx_TraceCall("call", __pyx_f[0], 3306);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_reference = values[0];
+    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.IndelCaller.call");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3313
+ *         """
  * 
- *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
+ *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
  * 
- *         self.options = bam_maqindel_opt_init()
+ *         self.iter.reset( tid, pos, pos + 1 )
  */
-  #ifndef PYREX_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_iterator_column), __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __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 = 3008; __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 = 3313; __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);
+  __Pyx_GIVEREF(__pyx_v_reference);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __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 = 3008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (unlikely(!__pyx_t_3)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_108));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  #endif
+  __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 = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_tid = __pyx_t_4;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3010
- *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
- * 
- *         self.options = bam_maqindel_opt_init()             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3315
+ *         cdef int tid = self.iter.samfile.gettid( reference )
  * 
- *         # set the default parameterization according to
- */
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options = bam_maqindel_opt_init();
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3015
- *         # samtools
+ *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
  * 
- *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )             # <<<<<<<<<<<<<<
- *         self.options.q_indel = kwargs.get( "q_indel", 40 )
- *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ *         while 1:
  */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-  }
-  __pyx_t_2 = PyFloat_FromDouble(0.00015); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__r_indel), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); 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_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->r_indel = __pyx_t_4;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3016
- * 
- *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
- *         self.options.q_indel = kwargs.get( "q_indel", 40 )             # <<<<<<<<<<<<<<
- *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
- *         self.max_depth = kwargs.get( "max_depth", 1024 )
- */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-  }
-  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__q_indel), __pyx_int_40); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->q_indel = __pyx_t_5;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3017
- *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
- *         self.options.q_indel = kwargs.get( "q_indel", 40 )
- *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )             # <<<<<<<<<<<<<<
- *         self.max_depth = kwargs.get( "max_depth", 1024 )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3317
+ *         self.iter.reset( tid, pos, pos + 1 )
  * 
- */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-  }
-  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__cap_mapQ), __pyx_int_60); 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_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ = __pyx_t_5;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3018
- *         self.options.q_indel = kwargs.get( "q_indel", 40 )
- *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
- *         self.max_depth = kwargs.get( "max_depth", 1024 )             # <<<<<<<<<<<<<<
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             self.iter.cnext()
  * 
- *     def __dealloc__(self):
  */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-  }
-  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_1024); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth = __pyx_t_5;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  while (1) {
+    if (!1) break;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3020
- *         self.max_depth = kwargs.get( "max_depth", 1024 )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3318
  * 
- *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         free( self.options )
+ *         while 1:
+ *             self.iter.cnext()             # <<<<<<<<<<<<<<
  * 
+ *             if self.iter.n_plp < 0:
  */
+    ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter);
 
-static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self) {
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3020);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3021
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3320
+ *             self.iter.cnext()
  * 
- *     def __dealloc__(self):
- *         free( self.options )             # <<<<<<<<<<<<<<
+ *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("error during iteration" )
  * 
- *     def _call( self ):
  */
-  free(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options);
-
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-}
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+    if (__pyx_t_6) {
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3023
- *         free( self.options )
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3321
  * 
- *     def _call( self ):             # <<<<<<<<<<<<<<
+ *             if self.iter.n_plp < 0:
+ *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
- *         cdef char * seq = self.iter.getSequence()
+ *             if self.iter.plp == NULL:
  */
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
 
-static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  char *__pyx_v_seq;
-  int __pyx_v_seq_len;
-  bam_maqindel_ret_t *__pyx_v_r;
-  int __pyx_v_m;
-  struct __pyx_obj_9csamtools_IndelCall *__pyx_v_call;
-  uint64_t __pyx_v_rms_aux;
-  int __pyx_v_i;
-  bam_pileup1_t *__pyx_v_p;
-  int __pyx_v_tmp;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
-  int __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  int __pyx_t_6;
-  int __pyx_t_7;
-  double __pyx_t_8;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("_call");
-  __Pyx_TraceCall("_call", __pyx_f[0], 3023);
-  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)Py_None); __Pyx_INCREF(Py_None);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3025
- *     def _call( self ):
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3323
+ *                 raise ValueError("error during iteration" )
  * 
- *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
- *         cdef int seq_len = self.iter.seq_len
+ *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "no reads in region - no call" )
  * 
  */
-  __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+    if (__pyx_t_6) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3026
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3324
  * 
- *         cdef char * seq = self.iter.getSequence()
- *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
+ *             if self.iter.plp == NULL:
+ *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
  * 
- *         assert seq != NULL
+ *             if self.iter.pos == pos: break
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_v_seq_len = __pyx_t_2;
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3028
- *         cdef int seq_len = self.iter.seq_len
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3326
+ *                 raise ValueError( "no reads in region - no call" )
  * 
- *         assert seq != NULL             # <<<<<<<<<<<<<<
+ *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
  * 
- *         # reference base
+ *         return self._call()
  */
-  #ifndef PYREX_WITHOUT_ASSERTIONS
-  if (unlikely(!(__pyx_v_seq != NULL))) {
-    PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
+    if (__pyx_t_6) {
+      goto __pyx_L7_break;
+      goto __pyx_L10;
+    }
+    __pyx_L10:;
   }
-  #endif
+  __pyx_L7_break:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3031
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3328
+ *             if self.iter.pos == pos: break
  * 
- *         # reference base
- *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
- *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ *         return self._call()             # <<<<<<<<<<<<<<
  * 
+ * cdef class IteratorIndelCalls( IndelCallerBase ):
  */
-  __pyx_t_3 = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos >= __pyx_v_seq_len);
-  if (__pyx_t_3) {
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3032
- *         # reference base
- *         if self.iter.pos >= seq_len:
- *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
- * 
- *         cdef bam_maqindel_ret_t * r
- */
-    __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
-    __Pyx_GIVEREF(__pyx_t_1);
-    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
-    __Pyx_GIVEREF(__pyx_t_4);
-    __pyx_t_1 = 0;
-    __pyx_t_4 = 0;
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_105), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __Pyx_DECREF(__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 = 3032; __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, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_Raise(__pyx_t_4, 0, 0);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
+  __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_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("csamtools.IndelCaller.call");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3036
- *         cdef bam_maqindel_ret_t * r
- * 
- *         cdef int m = min( self.max_depth, self.iter.n_plp )             # <<<<<<<<<<<<<<
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3344
+ *     """
  * 
- *         # printf("pysam: m=%i, q_indel=%i, r_indel=%f, r_snp=%i, mm_penalty=%i, indel_err=%i, ambi_thres=%i\n",
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
  */
-  __pyx_t_2 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
-  __pyx_t_6 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth;
-  if ((__pyx_t_2 < __pyx_t_6)) {
-    __pyx_t_7 = __pyx_t_2;
+
+static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3344);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_t_7 = __pyx_t_6;
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
   }
-  __pyx_v_m = __pyx_t_7;
+  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 = 3344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3048
- *                          seq,
- *                          0,
- *                          NULL)             # <<<<<<<<<<<<<<
- * 
- *         if r == NULL: return None
- */
-  __pyx_v_r = bam_maqindel(__pyx_v_m, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp, __pyx_v_seq, 0, NULL);
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3050
- *                          NULL)
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3350
  * 
- *         if r == NULL: return None             # <<<<<<<<<<<<<<
  * 
- *         cdef IndelCall call
- */
-  __pyx_t_3 = (__pyx_v_r == NULL);
-  if (__pyx_t_3) {
-    __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(Py_None);
-    __pyx_r = Py_None;
-    goto __pyx_L0;
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3053
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
  * 
- *         cdef IndelCall call
- *         call = IndelCall()             # <<<<<<<<<<<<<<
- *         call._r = r
- *         call._tid = self.iter.tid
- */
-  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IndelCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(((PyObject *)__pyx_v_call));
-  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)__pyx_t_4);
-  __pyx_t_4 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3054
- *         cdef IndelCall call
- *         call = IndelCall()
- *         call._r = r             # <<<<<<<<<<<<<<
- *         call._tid = self.iter.tid
- *         call._pos = self.iter.pos
  */
-  __pyx_v_call->_r = __pyx_v_r;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3055
- *         call = IndelCall()
- *         call._r = r
- *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
- *         call._pos = self.iter.pos
- *         call._coverage = self.iter.n_plp
- */
-  __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->tid;
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__iter__");
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 3350);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3056
- *         call._r = r
- *         call._tid = self.iter.tid
- *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
- *         call._coverage = self.iter.n_plp
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3351
  * 
- */
-  __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3057
- *         call._tid = self.iter.tid
- *         call._pos = self.iter.pos
- *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
  * 
- *         cdef uint64_t rms_aux = 0
+ *     def __next__(self):
  */
-  __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3059
- *         call._coverage = self.iter.n_plp
- * 
- *         cdef uint64_t rms_aux = 0             # <<<<<<<<<<<<<<
- *         cdef int i = 0
- *         cdef bam_pileup1_t * p
- */
-  __pyx_v_rms_aux = 0;
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3060
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3353
+ *         return self
  * 
- *         cdef uint64_t rms_aux = 0
- *         cdef int i = 0             # <<<<<<<<<<<<<<
- *         cdef bam_pileup1_t * p
- *         cdef int tmp
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
+ *         """
  */
-  __pyx_v_i = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3064
- *         cdef int tmp
- * 
- *         for i from 0 <= i < self.iter.n_plp:             # <<<<<<<<<<<<<<
- *             p = self.iter.plp + i
- *             if p.b.core.qual < self.cap_mapQ:
- */
-  __pyx_t_7 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
-  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18IteratorIndelCalls___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__next__");
+  __Pyx_TraceCall("__next__", __pyx_f[0], 3353);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3065
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3358
  * 
- *         for i from 0 <= i < self.iter.n_plp:
- *             p = self.iter.plp + i             # <<<<<<<<<<<<<<
- *             if p.b.core.qual < self.cap_mapQ:
- *                 tmp = p.b.core.qual
- */
-    __pyx_v_p = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp + __pyx_v_i);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3066
- *         for i from 0 <= i < self.iter.n_plp:
- *             p = self.iter.plp + i
- *             if p.b.core.qual < self.cap_mapQ:             # <<<<<<<<<<<<<<
- *                 tmp = p.b.core.qual
- *             else:
+ *         # the following code was adapted from bam_plcmd.c:pileup_func()
+ *         self.iter.cnext()             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iter.n_plp < 0:
  */
-    __pyx_t_3 = (__pyx_v_p->b->core.qual < ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ);
-    if (__pyx_t_3) {
+  ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3067
- *             p = self.iter.plp + i
- *             if p.b.core.qual < self.cap_mapQ:
- *                 tmp = p.b.core.qual             # <<<<<<<<<<<<<<
- *             else:
- *                 tmp = self.cap_mapQ
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3360
+ *         self.iter.cnext()
+ * 
+ *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError("error during iteration" )
+ * 
  */
-      __pyx_v_tmp = __pyx_v_p->b->core.qual;
-      goto __pyx_L9;
-    }
-    /*else*/ {
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+  if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3069
- *                 tmp = p.b.core.qual
- *             else:
- *                 tmp = self.cap_mapQ             # <<<<<<<<<<<<<<
- *             rms_aux += tmp * tmp
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3361
+ * 
+ *         if self.iter.n_plp < 0:
+ *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
+ *         if self.iter.plp == NULL:
  */
-      __pyx_v_tmp = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ;
-    }
-    __pyx_L9:;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3070
- *             else:
- *                 tmp = self.cap_mapQ
- *             rms_aux += tmp * tmp             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3363
+ *             raise ValueError("error during iteration" )
+ * 
+ *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *            raise StopIteration
  * 
- *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
  */
-    __pyx_v_rms_aux += (__pyx_v_tmp * __pyx_v_tmp);
-  }
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+  if (__pyx_t_1) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3072
- *             rms_aux += tmp * tmp
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3364
  * 
- *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)             # <<<<<<<<<<<<<<
+ *         if self.iter.plp == NULL:
+ *            raise StopIteration             # <<<<<<<<<<<<<<
  * 
- *         return call
+ *         return self._call()
  */
-  __pyx_t_8 = ((double)__pyx_v_rms_aux);
-  if (unlikely(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp == 0)) {
-    PyErr_Format(PyExc_ZeroDivisionError, "float division");
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
   }
-  __pyx_v_call->_rms_mapping_quality = ((uint64_t)(sqrt((__pyx_t_8 / ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp)) + .499));
+  __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3074
- *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3366
+ *            raise StopIteration
+ * 
+ *         return self._call()             # <<<<<<<<<<<<<<
  * 
- *         return call             # <<<<<<<<<<<<<<
  * 
- * cdef class IndelCaller( IndelCallerBase ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(((PyObject *)__pyx_v_call));
-  __pyx_r = ((PyObject *)__pyx_v_call);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); 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_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __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_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_AddTraceback("csamtools.IndelCallerBase._call");
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__next__");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF((PyObject *)__pyx_v_call);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3089
- *     '''
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3386
+ *     cdef int owns_samfile
  * 
- *     def __cinit__(self,             # <<<<<<<<<<<<<<
- *                   IteratorColumn iterator_column,
- *                   **kwargs ):
- */
-
-static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
-  PyObject *__pyx_v_kwargs = 0;
-  int __pyx_r;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3089);
-  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
-  __Pyx_GOTREF(__pyx_v_kwargs);
-  if (unlikely(__pyx_kwds)) {
-    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[1] = {0};
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
-      case  0: break;
-      default: goto __pyx_L5_argtuple_error;
-    }
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
-      if (likely(values[0])) kw_args--;
-      else goto __pyx_L5_argtuple_error;
-    }
-    if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    }
-    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
-  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
-    goto __pyx_L5_argtuple_error;
-  } else {
-    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
-  }
-  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 = 3089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  __pyx_L3_error:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
-  __Pyx_RefNannyFinishContext();
-  return -1;
-  __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3095
- *         pass
+ *     def __init__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
+ *         self.samfile = samfile
  * 
- *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
- *         """call a snp on chromosome *reference*
- *         and position *pos*.
  */
 
-static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_11IndelCaller_call[] = "call a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object or None, if no indel call could be made.\n        ";
-static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_reference = 0;
-  int __pyx_v_pos;
-  int __pyx_v_tid;
-  PyObject *__pyx_r = NULL;
+static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
+  int __pyx_v_reopen;
+  PyObject *__pyx_v_mode;
+  PyObject *__pyx_v_store;
+  int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  int __pyx_t_4;
-  PyObject *__pyx_t_5 = NULL;
-  int __pyx_t_6;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
+  char *__pyx_t_3;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("call");
-  __Pyx_TraceCall("call", __pyx_f[0], 3095);
+  __Pyx_RefNannySetupContext("__init__");
+  __Pyx_TraceCall("__init__", __pyx_f[0], 3386);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -27642,303 +30280,368 @@ static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self,
     }
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
       if (likely(values[0])) kw_args--;
       else goto __pyx_L5_argtuple_error;
       case  1:
-      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
-      if (likely(values[1])) kw_args--;
-      else {
-        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
+        if (value) { values[1] = value; kw_args--; }
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_samfile = ((struct __pyx_obj_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 = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_reopen = ((int)1);
     }
-    __pyx_v_reference = values[0];
-    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
-    goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
-    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_reopen = ((int)1);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __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 = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("csamtools.IndelCaller.call");
+  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
   __Pyx_RefNannyFinishContext();
-  return NULL;
+  return -1;
   __pyx_L4_argument_unpacking_done:;
+  __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3102
- *         """
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3387
  * 
- *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
+ *     def __init__(self, Samfile samfile, int reopen = True ):
+ *         self.samfile = samfile             # <<<<<<<<<<<<<<
  * 
- *         self.iter.reset( tid, pos, pos + 1 )
+ *         if samfile.isbam: mode = "rb"
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3102; __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);
-  __Pyx_GIVEREF(__pyx_v_reference);
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3102; __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_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 = 3102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_v_tid = __pyx_t_4;
+  __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3104
- *         cdef int tid = self.iter.samfile.gettid( reference )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3389
+ *         self.samfile = samfile
  * 
- *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
+ *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
+ *         else: mode = "r"
  * 
- *         while 1:
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  if (__pyx_v_samfile->isbam) {
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
+    __Pyx_DECREF(__pyx_v_mode);
+    __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
+    goto __pyx_L6;
+  }
+  /*else*/ {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3106
- *         self.iter.reset( tid, pos, pos + 1 )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3390
  * 
- *         while 1:             # <<<<<<<<<<<<<<
- *             self.iter.cnext()
+ *         if samfile.isbam: mode = "rb"
+ *         else: mode = "r"             # <<<<<<<<<<<<<<
  * 
+ *         # reopen the file - note that this makes the iterator
  */
-  while (1) {
-    if (!1) break;
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
+    __Pyx_DECREF(__pyx_v_mode);
+    __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
+  }
+  __pyx_L6:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3107
- * 
- *         while 1:
- *             self.iter.cnext()             # <<<<<<<<<<<<<<
- * 
- *             if self.iter.n_plp < 0:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3394
+ *         # reopen the file - note that this makes the iterator
+ *         # slow and causes pileup to slow down significantly.
+ *         if reopen:             # <<<<<<<<<<<<<<
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )
  */
-    ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter);
+  if (__pyx_v_reopen) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3109
- *             self.iter.cnext()
- * 
- *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
- *                 raise ValueError("error during iteration" )
- * 
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3395
+ *         # slow and causes pileup to slow down significantly.
+ *         if reopen:
+ *             store = StderrStore()             # <<<<<<<<<<<<<<
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
  */
-    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
-    if (__pyx_t_6) {
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3395; __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 = 3395; __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_store);
+    __pyx_v_store = __pyx_t_2;
+    __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3110
- * 
- *             if self.iter.n_plp < 0:
- *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
- * 
- *             if self.iter.plp == NULL:
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3396
+ *         if reopen:
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
+ *             store.release()
+ *             assert self.fp != NULL
  */
-      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_56));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __Pyx_Raise(__pyx_t_1, 0, 0);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L8;
+    __pyx_t_3 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_3, NULL);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3397
+ *             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 = 3397; __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 = 3397; __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;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3398
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
+ *             assert self.fp != NULL             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = True
+ *         else:
+ */
+    #ifndef PYREX_WITHOUT_ASSERTIONS
+    if (unlikely(!(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp != NULL))) {
+      PyErr_SetNone(PyExc_AssertionError);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
-    __pyx_L8:;
+    #endif
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3112
- *                 raise ValueError("error during iteration" )
- * 
- *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
- *                 raise ValueError( "no reads in region - no call" )
- * 
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3399
+ *             store.release()
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.fp = samfile.samfile
  */
-    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
-    if (__pyx_t_6) {
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 1;
+    goto __pyx_L7;
+  }
+  /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3113
- * 
- *             if self.iter.plp == NULL:
- *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3401
+ *             self.owns_samfile = True
+ *         else:
+ *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = False
  * 
- *             if self.iter.pos == pos: break
  */
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_106));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_106));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_106));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __Pyx_Raise(__pyx_t_5, 0, 0);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L9;
-    }
-    __pyx_L9:;
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3115
- *                 raise ValueError( "no reads in region - no call" )
- * 
- *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3402
+ *         else:
+ *             self.fp = samfile.samfile
+ *             self.owns_samfile = False             # <<<<<<<<<<<<<<
  * 
- *         return self._call()
+ *         assert samfile.isbam, "can only IndexReads on bam files"
  */
-    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
-    if (__pyx_t_6) {
-      goto __pyx_L7_break;
-      goto __pyx_L10;
-    }
-    __pyx_L10:;
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 0;
   }
-  __pyx_L7_break:;
+  __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3117
- *             if self.iter.pos == pos: break
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3404
+ *             self.owns_samfile = False
  * 
- *         return self._call()             # <<<<<<<<<<<<<<
+ *         assert samfile.isbam, "can only IndexReads on bam files"             # <<<<<<<<<<<<<<
  * 
- * cdef class IteratorIndelCalls( IndelCallerBase ):
+ *     def build( self ):
  */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
-  goto __pyx_L0;
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!__pyx_v_samfile->isbam)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_112));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __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_5);
-  __Pyx_AddTraceback("csamtools.IndelCaller.call");
-  __pyx_r = NULL;
+  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
+  __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_DECREF(__pyx_v_mode);
+  __Pyx_DECREF(__pyx_v_store);
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3133
- *     """
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3406
+ *         assert samfile.isbam, "can only IndexReads on bam files"
+ * 
+ *     def build( self ):             # <<<<<<<<<<<<<<
+ *         '''build index.'''
  * 
- *     def __cinit__(self,             # <<<<<<<<<<<<<<
- *                   IteratorColumn iterator_column,
- *                   **kwargs ):
  */
 
-static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
-  PyObject *__pyx_v_kwargs = 0;
-  int __pyx_r;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_12IndexedReads_build[] = "IndexedReads.build(self)\nbuild index.";
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  int __pyx_v_ret;
+  bam1_t *__pyx_v_b;
+  uint64_t __pyx_v_pos;
+  char *__pyx_v_qname;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3133);
-  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
-  __Pyx_GOTREF(__pyx_v_kwargs);
-  if (unlikely(__pyx_kwds)) {
-    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[1] = {0};
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
-      case  0: break;
-      default: goto __pyx_L5_argtuple_error;
-    }
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
-      if (likely(values[0])) kw_args--;
-      else goto __pyx_L5_argtuple_error;
-    }
-    if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    }
-    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
-  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
-    goto __pyx_L5_argtuple_error;
-  } else {
-    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
-  }
-  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 = 3133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  __pyx_L3_error:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
-  __Pyx_RefNannyFinishContext();
-  return -1;
-  __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannySetupContext("build");
+  __Pyx_TraceCall("build", __pyx_f[0], 3406);
 
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_kwargs);
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3409
+ *         '''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 = 3409; __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 = 3409; __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 = 3409; __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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __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_1); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
+  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
+  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index = __pyx_t_3;
+  __pyx_t_3 = 0;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3139
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3413
+ *         # this method will start indexing from the current file position
+ *         # if you decide
+ *         cdef int ret = 1             # <<<<<<<<<<<<<<
+ *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )
  * 
+ */
+  __pyx_v_ret = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3414
+ *         # if you decide
+ *         cdef int ret = 1
+ *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
  * 
- *     def __iter__(self):             # <<<<<<<<<<<<<<
- *         return self
+ *         cdef uint64_t pos
+ */
+  __pyx_v_b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3418
+ *         cdef uint64_t pos
+ * 
+ *         while ret > 0:             # <<<<<<<<<<<<<<
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)
+ */
+  while (1) {
+    __pyx_t_4 = (__pyx_v_ret > 0);
+    if (!__pyx_t_4) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3419
  * 
+ *         while ret > 0:
+ *             pos = bam_tell( self.fp.x.bam )             # <<<<<<<<<<<<<<
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:
  */
+    __pyx_v_pos = bam_tell(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp->x.bam);
 
-static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 3139);
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3420
+ *         while ret > 0:
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)             # <<<<<<<<<<<<<<
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )
+ */
+    __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp, __pyx_v_b);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3421
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:             # <<<<<<<<<<<<<<
+ *                 qname = bam1_qname( b )
+ *                 self.index[qname].append( pos )
+ */
+    __pyx_t_4 = (__pyx_v_ret > 0);
+    if (__pyx_t_4) {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3140
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3422
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )             # <<<<<<<<<<<<<<
+ *                 self.index[qname].append( pos )
  * 
- *     def __iter__(self):
- *         return self             # <<<<<<<<<<<<<<
+ */
+      __pyx_v_qname = bam1_qname(__pyx_v_b);
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3423
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )
+ *                 self.index[qname].append( pos )             # <<<<<<<<<<<<<<
  * 
- *     def __next__(self):
+ *         bam_destroy1( b )
  */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(__pyx_v_self);
-  __pyx_r = __pyx_v_self;
-  goto __pyx_L0;
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_1 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __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 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __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_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3425
+ *                 self.index[qname].append( pos )
+ * 
+ *         bam_destroy1( b )             # <<<<<<<<<<<<<<
+ * 
+ *     def find( self, qname ):
+ */
+  bam_destroy1(__pyx_v_b);
 
   __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("csamtools.IndexedReads.build");
+  __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
@@ -27946,113 +30649,101 @@ static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__p
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3142
- *         return self
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3427
+ *         bam_destroy1( b )
  * 
- *     def __next__(self):             # <<<<<<<<<<<<<<
- *         """python version of next().
- *         """
+ *     def find( self, qname ):             # <<<<<<<<<<<<<<
+ *         if qname in self.index:
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
  */
 
-static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_18IteratorIndelCalls___next__[] = "python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
-static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
+static char __pyx_doc_9csamtools_12IndexedReads_find[] = "IndexedReads.find(self, qname)";
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 3142);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3147
- * 
- *         # the following code was adapted from bam_plcmd.c:pileup_func()
- *         self.iter.cnext()             # <<<<<<<<<<<<<<
- * 
- *         if self.iter.n_plp < 0:
- */
-  ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter);
+  __Pyx_RefNannySetupContext("find");
+  __Pyx_TraceCall("find", __pyx_f[0], 3427);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3149
- *         self.iter.cnext()
- * 
- *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
- *             raise ValueError("error during iteration" )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3428
  * 
+ *     def find( self, qname ):
+ *         if qname in self.index:             # <<<<<<<<<<<<<<
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ *         else:
  */
-  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+  __pyx_t_1 = ((PySequence_Contains(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3150
- * 
- *         if self.iter.n_plp < 0:
- *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
- * 
- *         if self.iter.plp == NULL:
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3429
+ *     def find( self, qname ):
+ *         if qname in self.index:
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )             # <<<<<<<<<<<<<<
+ *         else:
+ *             raise KeyError( "read %s not found" % qname )
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_56));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __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 = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    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 = 3429; __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 = 3429; __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 = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowSelection)), __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
     goto __pyx_L5;
   }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3152
- *             raise ValueError("error during iteration" )
- * 
- *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
- *            raise StopIteration
- * 
- */
-  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3153
- * 
- *         if self.iter.plp == NULL:
- *            raise StopIteration             # <<<<<<<<<<<<<<
- * 
- *         return self._call()
- */
-    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
+  /*else*/ {
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3155
- *            raise StopIteration
- * 
- *         return self._call()             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3431
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ *         else:
+ *             raise KeyError( "read %s not found" % qname )             # <<<<<<<<<<<<<<
  * 
- * __all__ = ["Samfile",
+ *     def __dealloc__(self):
  */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
-  goto __pyx_L0;
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), __pyx_v_qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __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 = 3431; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_L5:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__next__");
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("csamtools.IndexedReads.find");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
@@ -28061,6 +30752,37 @@ static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__p
   return __pyx_r;
 }
 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3433
+ *             raise KeyError( "read %s not found" % qname )
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ */
+
+static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3433);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3434
+ * 
+ *     def __dealloc__(self):
+ *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
+ * 
+ * __all__ = ["Samfile",
+ */
+  if (((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile) {
+    samclose(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
 static PyObject *__pyx_tp_new_9csamtools_AlignedRead(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
@@ -28462,47 +31184,53 @@ static int __pyx_setprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, PyOb
   }
 }
 
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_positions(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_9positions___get__(o);
+}
+
 static PyMethodDef __pyx_methods_9csamtools_AlignedRead[] = {
   {__Pyx_NAMESTR("compare"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_compare, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_compare)},
+  {__Pyx_NAMESTR("overlap"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_overlap, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_overlap)},
   {__Pyx_NAMESTR("opt"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_opt, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_opt)},
   {__Pyx_NAMESTR("fancy_str"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_fancy_str, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_fancy_str)},
   {0, 0, 0, 0}
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_AlignedRead[] = {
-  {(char *)"qname", __pyx_getprop_9csamtools_11AlignedRead_qname, __pyx_setprop_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_109), 0},
-  {(char *)"cigar", __pyx_getprop_9csamtools_11AlignedRead_cigar, __pyx_setprop_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_110), 0},
-  {(char *)"seq", __pyx_getprop_9csamtools_11AlignedRead_seq, __pyx_setprop_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_111), 0},
-  {(char *)"qual", __pyx_getprop_9csamtools_11AlignedRead_qual, __pyx_setprop_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_112), 0},
-  {(char *)"query", __pyx_getprop_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_113), 0},
-  {(char *)"qqual", __pyx_getprop_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_114), 0},
-  {(char *)"qstart", __pyx_getprop_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_115), 0},
-  {(char *)"qend", __pyx_getprop_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_116), 0},
-  {(char *)"qlen", __pyx_getprop_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_117), 0},
-  {(char *)"tags", __pyx_getprop_9csamtools_11AlignedRead_tags, __pyx_setprop_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_118), 0},
-  {(char *)"flag", __pyx_getprop_9csamtools_11AlignedRead_flag, __pyx_setprop_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_119), 0},
-  {(char *)"rname", __pyx_getprop_9csamtools_11AlignedRead_rname, __pyx_setprop_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_120), 0},
-  {(char *)"tid", __pyx_getprop_9csamtools_11AlignedRead_tid, __pyx_setprop_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_121), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_11AlignedRead_pos, __pyx_setprop_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_122), 0},
-  {(char *)"bin", __pyx_getprop_9csamtools_11AlignedRead_bin, __pyx_setprop_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_123), 0},
-  {(char *)"rlen", __pyx_getprop_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_124), 0},
-  {(char *)"aend", __pyx_getprop_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_125), 0},
-  {(char *)"alen", __pyx_getprop_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_126), 0},
-  {(char *)"mapq", __pyx_getprop_9csamtools_11AlignedRead_mapq, __pyx_setprop_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_127), 0},
-  {(char *)"mrnm", __pyx_getprop_9csamtools_11AlignedRead_mrnm, __pyx_setprop_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_128), 0},
-  {(char *)"mpos", __pyx_getprop_9csamtools_11AlignedRead_mpos, __pyx_setprop_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_129), 0},
-  {(char *)"isize", __pyx_getprop_9csamtools_11AlignedRead_isize, __pyx_setprop_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_130), 0},
-  {(char *)"is_paired", __pyx_getprop_9csamtools_11AlignedRead_is_paired, __pyx_setprop_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_131), 0},
-  {(char *)"is_proper_pair", __pyx_getprop_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_132), 0},
-  {(char *)"is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_133), 0},
-  {(char *)"mate_is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_134), 0},
-  {(char *)"is_reverse", __pyx_getprop_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_135), 0},
-  {(char *)"mate_is_reverse", __pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_136), 0},
-  {(char *)"is_read1", __pyx_getprop_9csamtools_11AlignedRead_is_read1, __pyx_setprop_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_137), 0},
-  {(char *)"is_read2", __pyx_getprop_9csamtools_11AlignedRead_is_read2, __pyx_setprop_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_138), 0},
-  {(char *)"is_secondary", __pyx_getprop_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_139), 0},
-  {(char *)"is_qcfail", __pyx_getprop_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_140), 0},
-  {(char *)"is_duplicate", __pyx_getprop_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_141), 0},
+  {(char *)"qname", __pyx_getprop_9csamtools_11AlignedRead_qname, __pyx_setprop_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_114), 0},
+  {(char *)"cigar", __pyx_getprop_9csamtools_11AlignedRead_cigar, __pyx_setprop_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_115), 0},
+  {(char *)"seq", __pyx_getprop_9csamtools_11AlignedRead_seq, __pyx_setprop_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_116), 0},
+  {(char *)"qual", __pyx_getprop_9csamtools_11AlignedRead_qual, __pyx_setprop_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_117), 0},
+  {(char *)"query", __pyx_getprop_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_118), 0},
+  {(char *)"qqual", __pyx_getprop_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_119), 0},
+  {(char *)"qstart", __pyx_getprop_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_120), 0},
+  {(char *)"qend", __pyx_getprop_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_121), 0},
+  {(char *)"qlen", __pyx_getprop_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_122), 0},
+  {(char *)"tags", __pyx_getprop_9csamtools_11AlignedRead_tags, __pyx_setprop_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_123), 0},
+  {(char *)"flag", __pyx_getprop_9csamtools_11AlignedRead_flag, __pyx_setprop_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_124), 0},
+  {(char *)"rname", __pyx_getprop_9csamtools_11AlignedRead_rname, __pyx_setprop_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_125), 0},
+  {(char *)"tid", __pyx_getprop_9csamtools_11AlignedRead_tid, __pyx_setprop_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_126), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_11AlignedRead_pos, __pyx_setprop_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_127), 0},
+  {(char *)"bin", __pyx_getprop_9csamtools_11AlignedRead_bin, __pyx_setprop_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_128), 0},
+  {(char *)"rlen", __pyx_getprop_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_129), 0},
+  {(char *)"aend", __pyx_getprop_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_130), 0},
+  {(char *)"alen", __pyx_getprop_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_131), 0},
+  {(char *)"mapq", __pyx_getprop_9csamtools_11AlignedRead_mapq, __pyx_setprop_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_132), 0},
+  {(char *)"mrnm", __pyx_getprop_9csamtools_11AlignedRead_mrnm, __pyx_setprop_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_133), 0},
+  {(char *)"mpos", __pyx_getprop_9csamtools_11AlignedRead_mpos, __pyx_setprop_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_134), 0},
+  {(char *)"isize", __pyx_getprop_9csamtools_11AlignedRead_isize, __pyx_setprop_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_135), 0},
+  {(char *)"is_paired", __pyx_getprop_9csamtools_11AlignedRead_is_paired, __pyx_setprop_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_136), 0},
+  {(char *)"is_proper_pair", __pyx_getprop_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_137), 0},
+  {(char *)"is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_138), 0},
+  {(char *)"mate_is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_139), 0},
+  {(char *)"is_reverse", __pyx_getprop_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_140), 0},
+  {(char *)"mate_is_reverse", __pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_141), 0},
+  {(char *)"is_read1", __pyx_getprop_9csamtools_11AlignedRead_is_read1, __pyx_setprop_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_142), 0},
+  {(char *)"is_read2", __pyx_getprop_9csamtools_11AlignedRead_is_read2, __pyx_setprop_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_143), 0},
+  {(char *)"is_secondary", __pyx_getprop_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_144), 0},
+  {(char *)"is_qcfail", __pyx_getprop_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_145), 0},
+  {(char *)"is_duplicate", __pyx_getprop_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_146), 0},
+  {(char *)"positions", __pyx_getprop_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_147), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -28624,29 +31352,265 @@ PyTypeObject __pyx_type_9csamtools_AlignedRead = {
   &__pyx_tp_as_mapping_AlignedRead, /*tp_as_mapping*/
   __pyx_pf_9csamtools_11AlignedRead___hash__, /*tp_hash*/
   0, /*tp_call*/
-  __pyx_pf_9csamtools_11AlignedRead___str__, /*tp_str*/
+  __pyx_pf_9csamtools_11AlignedRead___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_AlignedRead, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("AlignedRead()\n\n    Class representing an aligned read. see SAM format specification for \n    the meaning of fields (http://samtools.sourceforge.net/).\n\n    This class stores a handle to the samtools C-structure representing\n    an aligned read. Member read access is forwarded to the C-structure\n    and converted into python objects. This implementation should be fast,\n    as only the data needed is converted.\n\n    For write access, the C-structure is updated in-place. This is\n    not the most efficient way to build BAM entries, as the variable\n    length data is concatenated and thus needs to resized if\n    a field is updated. Furthermore, the BAM entry might be\n    in an inconsistent state. The :meth:`~validate` method can\n    be used to check if an entry is consistent.\n\n    One issue to look out for is that the sequence should always\n    be set *before* the quality scores. Setting the sequence will\n    also erase any quality scores that were set previously.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_AlignedRead, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_AlignedRead, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_9csamtools_11AlignedRead___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_AlignedRead, /*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_9csamtools_Samfile __pyx_vtable_9csamtools_Samfile;
+
+static PyObject *__pyx_tp_new_9csamtools_Samfile(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_Samfile *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_Samfile *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Samfile;
+  if (__pyx_pf_9csamtools_7Samfile___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_Samfile(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_7Samfile___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_9csamtools_7Samfile_filename(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_8filename___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_nreferences(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_11nreferences___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_references(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_10references___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_lengths(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_7lengths___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_text(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_4text___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_header(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_6header___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_Samfile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__isOpen)},
+  {__Pyx_NAMESTR("_hasIndex"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__hasIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__hasIndex)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__open)},
+  {__Pyx_NAMESTR("gettid"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_gettid, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_gettid)},
+  {__Pyx_NAMESTR("getrname"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_getrname, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_getrname)},
+  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__parseRegion)},
+  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_seek)},
+  {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_tell)},
+  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_fetch)},
+  {__Pyx_NAMESTR("mate"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_mate, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_mate)},
+  {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_count, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_count)},
+  {__Pyx_NAMESTR("pileup"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_pileup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_pileup)},
+  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_close)},
+  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_write, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_write)},
+  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___enter__)},
+  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___exit__)},
+  {__Pyx_NAMESTR("_buildLine"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__buildLine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__buildLine)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___next__)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_Samfile[] = {
+  {(char *)"filename", __pyx_getprop_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
+  {(char *)"nreferences", __pyx_getprop_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
+  {(char *)"references", __pyx_getprop_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_150), 0},
+  {(char *)"lengths", __pyx_getprop_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_151), 0},
+  {(char *)"text", __pyx_getprop_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_152), 0},
+  {(char *)"header", __pyx_getprop_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_153), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Samfile = {
+  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_Samfile = {
+  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_Samfile = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
+  #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
+};
+
+PyTypeObject __pyx_type_9csamtools_Samfile = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.Samfile"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_Samfile), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_Samfile, /*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_Samfile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Samfile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Samfile, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_AlignedRead, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_Samfile, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("\n    Class representing an aligned read. see SAM format specification for meaning of fields (http://samtools.sourceforge.net/).\n\n    This class stores a handle to the samtools C-structure representing\n    an aligned read. Member read access is forwarded to the C-structure\n    and converted into python objects. This implementation should be fast,\n    as only the data needed is converted.\n\n    For write access, the C-structure is updated in-place. This is\n    not the most efficient way to build BAM entries, as the variable\n    length data is concatenated and thus needs to resized if\n    a field is updated. Furthermore, the BAM entry might be\n    in an inconsistent state. The :meth:`~validate` method can\n    be used to check if an entry is consistent.\n\n    One issue to look out for is that the sequence should always\n    be set *before* the quality scores. Setting the sequence will\n    also erase any quality scores that were set previously.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*\n              \n    A :term:`SAM`/:term:`BAM` formatted file. The file is automatically opened.\n    \n    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode (:term:`SAM`). For binary \n    (:term:`BAM`) I/O you should append ``b`` for compressed or ``u`` for uncompressed :term:`BAM` output. \n    Use ``h`` to output header information in text (:term:`TAM`)  mode.\n\n    If ``b`` is present, it must immediately follow ``r`` or ``w``. \n    Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open \n    a :term:`BAM` formatted file for reading, type::\n\n        f = pysam.Samfile('ex1.bam','rb')\n\n    If mode is not specified, we will try to auto-detect in the order 'r', 'rb', thus both the following\n    should work::\n\n        f1 = pysam.Samfile('ex1.bam' )\n        f2 = pysam.Samfile('ex1.bam' )\n\n    If an index for a BAM file exists (.bai), it will be opened automatically. Without an index random\n    access to reads via :meth:`fetch` and :meth:`pileup` is disabled.\n\n    For writing, the header of a :term:`SAM` file/:term:`BAM` file can be constituted from several\n    sources (see also the samtools format specification):\n\n        1. If *template* is given, the header is copied from a another *Samfile* \n           (*template* must be of type *Samfile*).\n\n        2. If *header* is given, the header is built from a multi-level dictionary. The first level \n           are the four types ('HD', 'SQ', ...). The second level are a list of lines, with each line \n           being a list of tag-value pairs.\n\n        3. If *text* is given, new header text is copied from raw text.\n\n        4. The names (*referencenames*) and lengths (*referencelengths*) are supplied directly as lists. \n\n    "), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_AlignedRead, /*tp_methods*/
+  __pyx_pf_9csamtools_7Samfile___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_7Samfile___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_Samfile, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_AlignedRead, /*tp_getset*/
+  __pyx_getsets_9csamtools_Samfile, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
   0, /*tp_descr_set*/
   0, /*tp_dictoffset*/
-  __pyx_pf_9csamtools_11AlignedRead___init__, /*tp_init*/
+  0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_AlignedRead, /*tp_new*/
+  __pyx_tp_new_9csamtools_Samfile, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -28701,10 +31665,10 @@ static PyMethodDef __pyx_methods_9csamtools_PileupProxy[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_PileupProxy[] = {
-  {(char *)"tid", __pyx_getprop_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_142), 0},
-  {(char *)"n", __pyx_getprop_9csamtools_11PileupProxy_n, __pyx_setprop_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_143), 0},
+  {(char *)"tid", __pyx_getprop_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"n", __pyx_getprop_9csamtools_11PileupProxy_n, __pyx_setprop_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_155), 0},
   {(char *)"pos", __pyx_getprop_9csamtools_11PileupProxy_pos, 0, 0, 0},
-  {(char *)"pileups", __pyx_getprop_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_144), 0},
+  {(char *)"pileups", __pyx_getprop_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -28831,7 +31795,7 @@ PyTypeObject __pyx_type_9csamtools_PileupProxy = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_PileupProxy, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("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\n    This class is a proxy for results returned by the samtools pileup engine.\n    If the underlying engine iterator advances, the results of this column\n    will change.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("PileupProxy()\nA 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\n    This class is a proxy for results returned by the samtools pileup engine.\n    If the underlying engine iterator advances, the results of this column\n    will change.\n    "), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -28928,10 +31892,10 @@ static PyMethodDef __pyx_methods_9csamtools_PileupRead[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_PileupRead[] = {
-  {(char *)"alignment", __pyx_getprop_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_145), 0},
-  {(char *)"qpos", __pyx_getprop_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_146), 0},
-  {(char *)"indel", __pyx_getprop_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_147), 0},
-  {(char *)"is_del", __pyx_getprop_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
+  {(char *)"alignment", __pyx_getprop_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_157), 0},
+  {(char *)"qpos", __pyx_getprop_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
+  {(char *)"indel", __pyx_getprop_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
+  {(char *)"is_del", __pyx_getprop_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
   {(char *)"is_head", __pyx_getprop_9csamtools_10PileupRead_is_head, 0, 0, 0},
   {(char *)"is_tail", __pyx_getprop_9csamtools_10PileupRead_is_tail, 0, 0, 0},
   {(char *)"level", __pyx_getprop_9csamtools_10PileupRead_level, 0, 0, 0},
@@ -29061,7 +32025,7 @@ PyTypeObject __pyx_type_9csamtools_PileupRead = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_PileupRead, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("A read aligned to a column.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("PileupRead()\nA read aligned to a column.\n    "), /*tp_doc*/
   __pyx_tp_traverse_9csamtools_PileupRead, /*tp_traverse*/
   __pyx_tp_clear_9csamtools_PileupRead, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -29119,259 +32083,23 @@ static void __pyx_tp_dealloc_9csamtools_Fastafile(PyObject *o) {
 }
 
 static PyObject *__pyx_getprop_9csamtools_9Fastafile_filename(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_9Fastafile_8filename___get__(o);
-}
-
-static PyMethodDef __pyx_methods_9csamtools_Fastafile[] = {
-  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__isOpen)},
-  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__open, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__open)},
-  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_close, METH_NOARGS, __Pyx_DOCSTR(0)},
-  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_fetch)},
-  {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_9csamtools_Fastafile[] = {
-  {(char *)"filename", __pyx_getprop_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
-  {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_Fastafile = {
-  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_Fastafile = {
-  __pyx_pf_9csamtools_9Fastafile___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_pf_9csamtools_9Fastafile___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
-};
-
-PyTypeObject __pyx_type_9csamtools_Fastafile = {
-  PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.Fastafile"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_Fastafile), /*tp_basicsize*/
-  0, /*tp_itemsize*/
-  __pyx_tp_dealloc_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_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*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_9csamtools_Fastafile, /*tp_methods*/
-  0, /*tp_members*/
-  __pyx_getsets_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_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 struct __pyx_vtabstruct_9csamtools_Samfile __pyx_vtable_9csamtools_Samfile;
-
-static PyObject *__pyx_tp_new_9csamtools_Samfile(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_Samfile *p;
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_Samfile *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Samfile;
-  if (__pyx_pf_9csamtools_7Samfile___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
-  return o;
-}
-
-static void __pyx_tp_dealloc_9csamtools_Samfile(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_7Samfile___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_9csamtools_7Samfile_filename(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_8filename___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_nreferences(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_11nreferences___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_references(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_10references___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_lengths(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_7lengths___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_text(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_4text___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_header(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_6header___get__(o);
-}
-
-static PyMethodDef __pyx_methods_9csamtools_Samfile[] = {
-  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__isOpen)},
-  {__Pyx_NAMESTR("_hasIndex"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__hasIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__hasIndex)},
-  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__open)},
-  {__Pyx_NAMESTR("getrname"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_getrname, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_getrname)},
-  {__Pyx_NAMESTR("gettid"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_gettid, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_gettid)},
-  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__parseRegion)},
-  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_seek)},
-  {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_tell)},
-  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_fetch)},
-  {__Pyx_NAMESTR("mate"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_mate, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_mate)},
-  {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_count, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_count)},
-  {__Pyx_NAMESTR("pileup"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_pileup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_pileup)},
-  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_close)},
-  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_write, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_write)},
-  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___enter__, METH_NOARGS, __Pyx_DOCSTR(0)},
-  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
-  {__Pyx_NAMESTR("_buildLine"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__buildLine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__buildLine)},
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___next__)},
+  return __pyx_pf_9csamtools_9Fastafile_8filename___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_Fastafile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__isOpen)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__open, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__open)},
+  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_close)},
+  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_fetch)},
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_Samfile[] = {
-  {(char *)"filename", __pyx_getprop_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
-  {(char *)"nreferences", __pyx_getprop_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_150), 0},
-  {(char *)"references", __pyx_getprop_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_151), 0},
-  {(char *)"lengths", __pyx_getprop_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_152), 0},
-  {(char *)"text", __pyx_getprop_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_153), 0},
-  {(char *)"header", __pyx_getprop_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+static struct PyGetSetDef __pyx_getsets_9csamtools_Fastafile[] = {
+  {(char *)"filename", __pyx_getprop_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
   {0, 0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_Samfile = {
+static PyNumberMethods __pyx_tp_as_number_Fastafile = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29429,8 +32157,8 @@ static PyNumberMethods __pyx_tp_as_number_Samfile = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_Samfile = {
-  0, /*sq_length*/
+static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
+  __pyx_pf_9csamtools_9Fastafile___len__, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
   0, /*sq_item*/
@@ -29442,13 +32170,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Samfile = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_Samfile = {
-  0, /*mp_length*/
+static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
+  __pyx_pf_9csamtools_9Fastafile___len__, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
+static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -29469,12 +32197,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
   #endif
 };
 
-PyTypeObject __pyx_type_9csamtools_Samfile = {
+PyTypeObject __pyx_type_9csamtools_Fastafile = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.Samfile"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_Samfile), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.Fastafile"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_Fastafile), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_Samfile, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_Fastafile, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -29484,26 +32212,26 @@ PyTypeObject __pyx_type_9csamtools_Samfile = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_Samfile, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Samfile, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Samfile, /*tp_as_mapping*/
+  &__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_Samfile, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("*(filename, mode='r', template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*\n              \n    A :term:`SAM`/:term:`BAM` formatted file. The file is automatically opened.\n    \n    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode so for binary \n    (:term:`BAM`) I/O you should append ``b`` for compressed or ``u`` for uncompressed :term:`BAM` output. \n    Use ``h`` to output header information  in text (:term:`TAM`)  mode.\n\n    If ``b`` is present, it must immediately follow ``r`` or ``w``. \n    Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open \n    a :term:`BAM` formatted file for reading, type::\n\n        import pysam\n        f = pysam.Samfile('ex1.bam','rb')\n\n    If an index for a BAM file exists (.bai), it will be opened automatically. Without an index random\n    access to reads via :meth:`fetch` and :meth:`pileup` is disabled.\n\n    For writing, the header of a :term:`SAM` file/:term:`BAM` file can be constituted from several\n    sources (see also the samtools format specification):\n\n        1. If *template* is given, the header is copied from a another *Samfile* \n           (*template* must be of type *Samfile*).\n\n        2. If *header* is given, the header is built from a multi-level dictionary. The first level \n           are the four types ('HD', 'SQ', ...). The second level are a list of lines, with each line \n           being a list of tag-value pairs.\n\n        3. If *text* is given, new header text is copied from raw text.\n\n        4. The names (*referencenames*) and lengths (*referencelengths*) are supplied directly as lists. \n\n    "), /*tp_doc*/
+  __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*/
-  __pyx_pf_9csamtools_7Samfile___iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_7Samfile___next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_Samfile, /*tp_methods*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_Fastafile, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_Samfile, /*tp_getset*/
+  __pyx_getsets_9csamtools_Fastafile, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -29511,7 +32239,7 @@ PyTypeObject __pyx_type_9csamtools_Samfile = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_Samfile, /*tp_new*/
+  __pyx_tp_new_9csamtools_Fastafile, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29874,7 +32602,7 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRowRegion, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|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 if\n    multiple operators work 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 iterator\n    creates its own file handle by re-opening the\n    file.\n\n    Note that the index will be shared between \n    samfile and the iterator.\n    "), /*tp_doc*/
+  __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 iterator\n    creates its own file handle by re-opening the\n    file.\n\n    Note that the index will be shared between \n    samfile and the iterator.\n    "), /*tp_doc*/
   __pyx_tp_traverse_9csamtools_IteratorRowRegion, /*tp_traverse*/
   __pyx_tp_clear_9csamtools_IteratorRowRegion, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -30007,13 +32735,223 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAll = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAll = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAll = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
+  #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
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRowAll"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowAll), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowAll, /*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_IteratorRowAll, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowAll, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowAll, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*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*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_14IteratorRowAll___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_14IteratorRowAll___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowAll, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_9csamtools_IteratorRowAll, /*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_9csamtools_IteratorRowAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  Py_XDECREF(((PyObject *)p->samfile));
+  Py_XDECREF(((PyObject *)p->rowiter));
+  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IteratorRowAllRefs(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
+    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->samfile) {
+    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  }
+  if (p->rowiter) {
+    e = (*v)(((PyObject*)p->rowiter), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IteratorRowAllRefs(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
+    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->samfile);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->rowiter);
+  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowAllRefs[] = {
+  {__Pyx_NAMESTR("nextiter"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
+  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_IteratorRowAllRefs = {
+  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_IteratorRowAllRefs = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30034,12 +32972,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
   #endif
 };
 
-PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
+PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowAll"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowAll), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowAll, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30049,24 +32987,24 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowAll, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowAll, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowAll, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorRowAllRefs, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowAllRefs, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowAllRefs, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*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 if\n    multiple operators work on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
+  &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorRowAllRefs, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_14IteratorRowAll___iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_14IteratorRowAll___next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowAll, /*tp_methods*/
+  __pyx_pf_9csamtools_18IteratorRowAllRefs___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_18IteratorRowAllRefs___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowAllRefs, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -30076,7 +33014,7 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowAll, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30089,64 +33027,66 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
   0, /*tp_version_tag*/
   #endif
 };
+static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection __pyx_vtable_9csamtools_IteratorRowSelection;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorRowAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p;
+static PyObject *__pyx_tp_new_9csamtools_IteratorRowSelection(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p;
   PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
-  if (__pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(o, a, k) < 0) {
+  p = ((struct __pyx_obj_9csamtools_IteratorRowSelection *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowSelection;
+  p->positions = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_20IteratorRowSelection___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
-  Py_XDECREF(((PyObject *)p->samfile));
-  Py_XDECREF(((PyObject *)p->rowiter));
+static void __pyx_tp_dealloc_9csamtools_IteratorRowSelection(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(p->positions);
   __pyx_tp_dealloc_9csamtools_IteratorRow(o);
 }
 
-static int __pyx_tp_traverse_9csamtools_IteratorRowAllRefs(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_9csamtools_IteratorRowSelection(PyObject *o, visitproc v, void *a) {
   int e;
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
   if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
     e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
   }
-  if (p->samfile) {
-    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
-  }
-  if (p->rowiter) {
-    e = (*v)(((PyObject*)p->rowiter), a); if (e) return e;
+  if (p->positions) {
+    e = (*v)(p->positions, a); if (e) return e;
   }
   return 0;
 }
 
-static int __pyx_tp_clear_9csamtools_IteratorRowAllRefs(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+static int __pyx_tp_clear_9csamtools_IteratorRowSelection(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
   PyObject* tmp;
   if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
     __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
   }
-  tmp = ((PyObject*)p->samfile);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  tmp = ((PyObject*)p->rowiter);
-  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  tmp = ((PyObject*)p->positions);
+  p->positions = Py_None; Py_INCREF(Py_None);
   Py_XDECREF(tmp);
   return 0;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorRowAllRefs[] = {
-  {__Pyx_NAMESTR("nextiter"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter, METH_NOARGS, __Pyx_DOCSTR(0)},
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs___next__)},
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowSelection[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorRowSelection___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorRowSelection___next__)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
+static PyNumberMethods __pyx_tp_as_number_IteratorRowSelection = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -30204,7 +33144,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRowSelection = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30217,13 +33157,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAllRefs = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowSelection = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30244,12 +33184,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
   #endif
 };
 
-PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
+PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorRowSelection"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowSelection), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowSelection, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30259,24 +33199,24 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowAllRefs, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowAllRefs, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowAllRefs, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorRowSelection, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowSelection, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowSelection, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_IteratorRowSelection, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorRowAllRefs, /*tp_clear*/
+  __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorRowSelection, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorRowSelection, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_18IteratorRowAllRefs___iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_18IteratorRowAllRefs___next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowAllRefs, /*tp_methods*/
+  __pyx_pf_9csamtools_20IteratorRowSelection___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_20IteratorRowSelection___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowSelection, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -30286,7 +33226,7 @@ PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorRowSelection, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30382,7 +33322,7 @@ static PyMethodDef __pyx_methods_9csamtools_IteratorColumn[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_IteratorColumn[] = {
-  {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_155), 0},
+  {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -30931,14 +33871,14 @@ static PyMethodDef __pyx_methods_9csamtools_SNPCall[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_SNPCall[] = {
-  {(char *)"tid", __pyx_getprop_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_142), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
-  {(char *)"reference_base", __pyx_getprop_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_157), 0},
-  {(char *)"genotype", __pyx_getprop_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
-  {(char *)"consensus_quality", __pyx_getprop_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
-  {(char *)"snp_quality", __pyx_getprop_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
-  {(char *)"mapping_quality", __pyx_getprop_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
-  {(char *)"coverage", __pyx_getprop_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
+  {(char *)"tid", __pyx_getprop_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
+  {(char *)"reference_base", __pyx_getprop_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_163), 0},
+  {(char *)"genotype", __pyx_getprop_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
+  {(char *)"consensus_quality", __pyx_getprop_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
+  {(char *)"snp_quality", __pyx_getprop_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
+  {(char *)"mapping_quality", __pyx_getprop_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
+  {(char *)"coverage", __pyx_getprop_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -31720,18 +34660,18 @@ static PyMethodDef __pyx_methods_9csamtools_IndelCall[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_9csamtools_IndelCall[] = {
-  {(char *)"tid", __pyx_getprop_9csamtools_9IndelCall_tid, 0, __Pyx_DOCSTR(__pyx_k_142), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_9IndelCall_pos, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
-  {(char *)"genotype", __pyx_getprop_9csamtools_9IndelCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
-  {(char *)"consensus_quality", __pyx_getprop_9csamtools_9IndelCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
-  {(char *)"snp_quality", __pyx_getprop_9csamtools_9IndelCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
-  {(char *)"mapping_quality", __pyx_getprop_9csamtools_9IndelCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
-  {(char *)"coverage", __pyx_getprop_9csamtools_9IndelCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
-  {(char *)"first_allele", __pyx_getprop_9csamtools_9IndelCall_first_allele, 0, __Pyx_DOCSTR(__pyx_k_163), 0},
-  {(char *)"second_allele", __pyx_getprop_9csamtools_9IndelCall_second_allele, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
-  {(char *)"reads_first", __pyx_getprop_9csamtools_9IndelCall_reads_first, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
-  {(char *)"reads_second", __pyx_getprop_9csamtools_9IndelCall_reads_second, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
-  {(char *)"reads_diff", __pyx_getprop_9csamtools_9IndelCall_reads_diff, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
+  {(char *)"tid", __pyx_getprop_9csamtools_9IndelCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_9IndelCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
+  {(char *)"genotype", __pyx_getprop_9csamtools_9IndelCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
+  {(char *)"consensus_quality", __pyx_getprop_9csamtools_9IndelCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
+  {(char *)"snp_quality", __pyx_getprop_9csamtools_9IndelCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
+  {(char *)"mapping_quality", __pyx_getprop_9csamtools_9IndelCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
+  {(char *)"coverage", __pyx_getprop_9csamtools_9IndelCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
+  {(char *)"first_allele", __pyx_getprop_9csamtools_9IndelCall_first_allele, 0, __Pyx_DOCSTR(__pyx_k_169), 0},
+  {(char *)"second_allele", __pyx_getprop_9csamtools_9IndelCall_second_allele, 0, __Pyx_DOCSTR(__pyx_k_170), 0},
+  {(char *)"reads_first", __pyx_getprop_9csamtools_9IndelCall_reads_first, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
+  {(char *)"reads_second", __pyx_getprop_9csamtools_9IndelCall_reads_second, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
+  {(char *)"reads_diff", __pyx_getprop_9csamtools_9IndelCall_reads_diff, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -31935,7 +34875,7 @@ static int __pyx_tp_clear_9csamtools_IndelCallerBase(PyObject *o) {
 }
 
 static PyMethodDef __pyx_methods_9csamtools_IndelCallerBase[] = {
-  {__Pyx_NAMESTR("_call"), (PyCFunction)__pyx_pf_9csamtools_15IndelCallerBase__call, METH_NOARGS, __Pyx_DOCSTR(0)},
+  {__Pyx_NAMESTR("_call"), (PyCFunction)__pyx_pf_9csamtools_15IndelCallerBase__call, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_15IndelCallerBase__call)},
   {0, 0, 0, 0}
 };
 
@@ -32230,14 +35170,182 @@ PyTypeObject __pyx_type_9csamtools_IndelCaller = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IndelCaller, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(IteratorColumn iterator_column )*\n\n    The samtools SNP caller.\n\n    This object will call SNPs in *samfile* against the reference\n    sequence in *fasta*.\n\n    This caller is fast for calling few SNPs in selected regions.\n\n    It is slow, if called over large genomic regions.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator_column )*\n\n    The samtools SNP caller.\n\n    This object will call SNPs in *samfile* against the reference\n    sequence in *fasta*.\n\n    This caller is fast for calling few SNPs in selected regions.\n\n    It is slow, if called over large genomic regions.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_IndelCaller, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*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_9csamtools_IndelCaller, /*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_9csamtools_IteratorIndelCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
+  if (!o) return 0;
+  if (__pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorIndelCalls[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorIndelCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorIndelCalls___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorIndelCalls = {
+  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_IteratorIndelCalls = {
+  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_IteratorIndelCalls = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorIndelCalls = {
+  #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
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorIndelCalls"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorIndelCalls), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*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_IteratorIndelCalls, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorIndelCalls, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorIndelCalls, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorIndelCalls, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator)*\n\n    call indels within a region.\n\n    *iterator* is a pileup iterator. SNPs will be called\n    on all positions returned by this iterator.\n\n    This caller is fast if SNPs are called over large continuous\n    regions. It is slow, if instantiated frequently and in random\n    order as the sequence will have to be reloaded.\n\n    "), /*tp_doc*/
   __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
   __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_IndelCaller, /*tp_methods*/
+  __pyx_pf_9csamtools_18IteratorIndelCalls___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_18IteratorIndelCalls___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorIndelCalls, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -32247,7 +35355,7 @@ PyTypeObject __pyx_type_9csamtools_IndelCaller = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IndelCaller, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorIndelCalls, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -32261,21 +35369,63 @@ PyTypeObject __pyx_type_9csamtools_IndelCaller = {
   #endif
 };
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorIndelCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
+static PyObject *__pyx_tp_new_9csamtools_IndexedReads(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IndexedReads *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  if (__pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
+  p = ((struct __pyx_obj_9csamtools_IndexedReads *)o);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  p->index = Py_None; Py_INCREF(Py_None);
   return o;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorIndelCalls[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorIndelCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorIndelCalls___next__)},
+static void __pyx_tp_dealloc_9csamtools_IndexedReads(PyObject *o) {
+  struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_12IndexedReads___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(((PyObject *)p->samfile));
+  Py_XDECREF(p->index);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IndexedReads(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
+  if (p->samfile) {
+    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  }
+  if (p->index) {
+    e = (*v)(p->index, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IndexedReads(PyObject *o) {
+  struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->samfile);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->index);
+  p->index = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IndexedReads[] = {
+  {__Pyx_NAMESTR("build"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_build, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_build)},
+  {__Pyx_NAMESTR("find"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_find, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_find)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorIndelCalls = {
+static PyNumberMethods __pyx_tp_as_number_IndexedReads = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -32333,7 +35483,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorIndelCalls = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorIndelCalls = {
+static PySequenceMethods __pyx_tp_as_sequence_IndexedReads = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -32346,13 +35496,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorIndelCalls = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorIndelCalls = {
+static PyMappingMethods __pyx_tp_as_mapping_IndexedReads = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorIndelCalls = {
+static PyBufferProcs __pyx_tp_as_buffer_IndexedReads = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -32373,12 +35523,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorIndelCalls = {
   #endif
 };
 
-PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
+PyTypeObject __pyx_type_9csamtools_IndexedReads = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorIndelCalls"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorIndelCalls), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IndexedReads"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IndexedReads), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IndexedReads, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -32388,24 +35538,24 @@ PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorIndelCalls, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorIndelCalls, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorIndelCalls, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IndexedReads, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IndexedReads, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IndexedReads, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorIndelCalls, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_IndexedReads, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(IteratorColumn iterator)*\n\n    call indels within a region.\n\n    *iterator* is a pileup iterator. SNPs will be called\n    on all positions returned by this iterator.\n\n    This caller is fast if SNPs are called over large continuous\n    regions. It is slow, if instantiated frequently and in random\n    order as the sequence will have to be reloaded.\n\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
+  __Pyx_DOCSTR("IndexedReads(Samfile samfile, int reopen=True)\nindex a bamfile by read.\n\n    The index is kept in memory.\n\n    By default, the file is re-openend to avoid conflicts if\n    multiple operators work on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IndexedReads, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IndexedReads, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_18IteratorIndelCalls___iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_18IteratorIndelCalls___next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorIndelCalls, /*tp_methods*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_IndexedReads, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -32413,9 +35563,9 @@ PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
   0, /*tp_descr_get*/
   0, /*tp_descr_set*/
   0, /*tp_dictoffset*/
-  0, /*tp_init*/
+  __pyx_pf_9csamtools_12IndexedReads___init__, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorIndelCalls, /*tp_new*/
+  __pyx_tp_new_9csamtools_IndexedReads, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -32451,28 +35601,27 @@ static struct PyModuleDef __pyx_moduledef = {
 static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
   {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
-  {&__pyx_n_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 1},
+  {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
   {&__pyx_kp_s_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0},
   {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
+  {&__pyx_n_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 1},
   {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
   {&__pyx_kp_s_105, __pyx_k_105, sizeof(__pyx_k_105), 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_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 0, 1, 0},
   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
+  {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0},
+  {&__pyx_kp_s_111, __pyx_k_111, sizeof(__pyx_k_111), 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_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
-  {&__pyx_kp_s_167, __pyx_k_167, sizeof(__pyx_k_167), 0, 0, 1, 0},
-  {&__pyx_kp_s_168, __pyx_k_168, sizeof(__pyx_k_168), 0, 0, 1, 0},
-  {&__pyx_kp_s_169, __pyx_k_169, sizeof(__pyx_k_169), 0, 0, 1, 0},
-  {&__pyx_kp_s_170, __pyx_k_170, sizeof(__pyx_k_170), 0, 0, 1, 0},
-  {&__pyx_kp_u_171, __pyx_k_171, sizeof(__pyx_k_171), 0, 1, 0, 0},
-  {&__pyx_kp_u_172, __pyx_k_172, sizeof(__pyx_k_172), 0, 1, 0, 0},
-  {&__pyx_kp_u_173, __pyx_k_173, sizeof(__pyx_k_173), 0, 1, 0, 0},
-  {&__pyx_kp_u_174, __pyx_k_174, sizeof(__pyx_k_174), 0, 1, 0, 0},
-  {&__pyx_kp_u_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 1, 0, 0},
-  {&__pyx_kp_u_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 1, 0, 0},
+  {&__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_u_177, __pyx_k_177, sizeof(__pyx_k_177), 0, 1, 0, 0},
   {&__pyx_kp_u_178, __pyx_k_178, sizeof(__pyx_k_178), 0, 1, 0, 0},
   {&__pyx_kp_u_179, __pyx_k_179, sizeof(__pyx_k_179), 0, 1, 0, 0},
@@ -32494,31 +35643,41 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_u_193, __pyx_k_193, sizeof(__pyx_k_193), 0, 1, 0, 0},
   {&__pyx_kp_u_194, __pyx_k_194, sizeof(__pyx_k_194), 0, 1, 0, 0},
   {&__pyx_kp_u_195, __pyx_k_195, sizeof(__pyx_k_195), 0, 1, 0, 0},
-  {&__pyx_n_s_196, __pyx_k_196, sizeof(__pyx_k_196), 0, 0, 1, 1},
+  {&__pyx_kp_u_196, __pyx_k_196, sizeof(__pyx_k_196), 0, 1, 0, 0},
   {&__pyx_kp_u_197, __pyx_k_197, sizeof(__pyx_k_197), 0, 1, 0, 0},
-  {&__pyx_n_s_198, __pyx_k_198, sizeof(__pyx_k_198), 0, 0, 1, 1},
+  {&__pyx_kp_u_198, __pyx_k_198, sizeof(__pyx_k_198), 0, 1, 0, 0},
   {&__pyx_kp_u_199, __pyx_k_199, sizeof(__pyx_k_199), 0, 1, 0, 0},
   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
   {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
-  {&__pyx_kp_u_200, __pyx_k_200, sizeof(__pyx_k_200), 0, 1, 0, 0},
+  {&__pyx_n_s_200, __pyx_k_200, sizeof(__pyx_k_200), 0, 0, 1, 1},
   {&__pyx_kp_u_201, __pyx_k_201, sizeof(__pyx_k_201), 0, 1, 0, 0},
   {&__pyx_kp_u_202, __pyx_k_202, sizeof(__pyx_k_202), 0, 1, 0, 0},
   {&__pyx_kp_u_203, __pyx_k_203, sizeof(__pyx_k_203), 0, 1, 0, 0},
-  {&__pyx_kp_u_204, __pyx_k_204, sizeof(__pyx_k_204), 0, 1, 0, 0},
+  {&__pyx_n_s_204, __pyx_k_204, sizeof(__pyx_k_204), 0, 0, 1, 1},
   {&__pyx_kp_u_205, __pyx_k_205, sizeof(__pyx_k_205), 0, 1, 0, 0},
-  {&__pyx_kp_u_206, __pyx_k_206, sizeof(__pyx_k_206), 0, 1, 0, 0},
+  {&__pyx_n_s_206, __pyx_k_206, sizeof(__pyx_k_206), 0, 0, 1, 1},
   {&__pyx_kp_u_207, __pyx_k_207, sizeof(__pyx_k_207), 0, 1, 0, 0},
   {&__pyx_kp_u_208, __pyx_k_208, sizeof(__pyx_k_208), 0, 1, 0, 0},
   {&__pyx_kp_u_209, __pyx_k_209, sizeof(__pyx_k_209), 0, 1, 0, 0},
   {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
   {&__pyx_kp_u_210, __pyx_k_210, sizeof(__pyx_k_210), 0, 1, 0, 0},
+  {&__pyx_kp_u_211, __pyx_k_211, sizeof(__pyx_k_211), 0, 1, 0, 0},
+  {&__pyx_kp_u_212, __pyx_k_212, sizeof(__pyx_k_212), 0, 1, 0, 0},
+  {&__pyx_kp_u_213, __pyx_k_213, sizeof(__pyx_k_213), 0, 1, 0, 0},
+  {&__pyx_kp_u_214, __pyx_k_214, sizeof(__pyx_k_214), 0, 1, 0, 0},
+  {&__pyx_kp_u_215, __pyx_k_215, sizeof(__pyx_k_215), 0, 1, 0, 0},
+  {&__pyx_kp_u_216, __pyx_k_216, sizeof(__pyx_k_216), 0, 1, 0, 0},
+  {&__pyx_kp_u_217, __pyx_k_217, sizeof(__pyx_k_217), 0, 1, 0, 0},
+  {&__pyx_kp_u_218, __pyx_k_218, sizeof(__pyx_k_218), 0, 1, 0, 0},
+  {&__pyx_kp_u_219, __pyx_k_219, sizeof(__pyx_k_219), 0, 1, 0, 0},
   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
+  {&__pyx_kp_u_220, __pyx_k_220, sizeof(__pyx_k_220), 0, 1, 0, 0},
   {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
   {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
   {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
+  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
   {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
-  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
   {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
   {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
@@ -32527,8 +35686,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__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_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_4, __pyx_k_4, sizeof(__pyx_k_4), 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},
@@ -32546,14 +35705,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 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_55, __pyx_k_55, sizeof(__pyx_k_55), 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_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
   {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0},
   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
-  {&__pyx_n_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 1},
   {&__pyx_kp_s_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 1, 0},
   {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
-  {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0},
+  {&__pyx_n_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 1},
   {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
   {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0},
   {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
@@ -32588,9 +35747,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
   {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
   {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
+  {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
+  {&__pyx_kp_s_96, __pyx_k_96, sizeof(__pyx_k_96), 0, 0, 1, 0},
   {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
-  {&__pyx_kp_s_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 1, 0},
-  {&__pyx_kp_s_99, __pyx_k_99, sizeof(__pyx_k_99), 0, 0, 1, 0},
   {&__pyx_n_s__A, __pyx_k__A, sizeof(__pyx_k__A), 0, 0, 1, 1},
   {&__pyx_n_s__AS, __pyx_k__AS, sizeof(__pyx_k__AS), 0, 0, 1, 1},
   {&__pyx_n_s__AlignedRead, __pyx_k__AlignedRead, sizeof(__pyx_k__AlignedRead), 0, 0, 1, 1},
@@ -32611,6 +35770,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__ID, __pyx_k__ID, sizeof(__pyx_k__ID), 0, 0, 1, 1},
   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
   {&__pyx_n_s__IndelCaller, __pyx_k__IndelCaller, sizeof(__pyx_k__IndelCaller), 0, 0, 1, 1},
+  {&__pyx_n_s__IndexedReads, __pyx_k__IndexedReads, sizeof(__pyx_k__IndexedReads), 0, 0, 1, 1},
   {&__pyx_n_s__IntType, __pyx_k__IntType, sizeof(__pyx_k__IntType), 0, 0, 1, 1},
   {&__pyx_n_s__IteratorColumn, __pyx_k__IteratorColumn, sizeof(__pyx_k__IteratorColumn), 0, 0, 1, 1},
   {&__pyx_n_s__IteratorIndelCalls, __pyx_k__IteratorIndelCalls, sizeof(__pyx_k__IteratorIndelCalls), 0, 0, 1, 1},
@@ -32627,6 +35787,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__O_CREAT, __pyx_k__O_CREAT, sizeof(__pyx_k__O_CREAT), 0, 0, 1, 1},
   {&__pyx_n_s__O_WRONLY, __pyx_k__O_WRONLY, sizeof(__pyx_k__O_WRONLY), 0, 0, 1, 1},
   {&__pyx_n_s__Outs, __pyx_k__Outs, sizeof(__pyx_k__Outs), 0, 0, 1, 1},
+  {&__pyx_n_s__OverflowError, __pyx_k__OverflowError, sizeof(__pyx_k__OverflowError), 0, 0, 1, 1},
   {&__pyx_n_s__PG, __pyx_k__PG, sizeof(__pyx_k__PG), 0, 0, 1, 1},
   {&__pyx_n_s__PI, __pyx_k__PI, sizeof(__pyx_k__PI), 0, 0, 1, 1},
   {&__pyx_n_s__PL, __pyx_k__PL, sizeof(__pyx_k__PL), 0, 0, 1, 1},
@@ -32645,6 +35806,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__SQ, __pyx_k__SQ, sizeof(__pyx_k__SQ), 0, 0, 1, 1},
   {&__pyx_n_s__Samfile, __pyx_k__Samfile, sizeof(__pyx_k__Samfile), 0, 0, 1, 1},
   {&__pyx_n_s__StderrStore, __pyx_k__StderrStore, sizeof(__pyx_k__StderrStore), 0, 0, 1, 1},
+  {&__pyx_n_s__StderrStoreWindows, __pyx_k__StderrStoreWindows, sizeof(__pyx_k__StderrStoreWindows), 0, 0, 1, 1},
   {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
   {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
   {&__pyx_n_s__UR, __pyx_k__UR, sizeof(__pyx_k__UR), 0, 0, 1, 1},
@@ -32654,6 +35816,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__VALID_HEADER_TYPES, __pyx_k__VALID_HEADER_TYPES, sizeof(__pyx_k__VALID_HEADER_TYPES), 0, 0, 1, 1},
   {&__pyx_n_s__VN, __pyx_k__VN, sizeof(__pyx_k__VN), 0, 0, 1, 1},
   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
+  {&__pyx_n_s__Windows, __pyx_k__Windows, sizeof(__pyx_k__Windows), 0, 0, 1, 1},
   {&__pyx_n_s__Z, __pyx_k__Z, sizeof(__pyx_k__Z), 0, 0, 1, 1},
   {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
   {&__pyx_n_s____del__, __pyx_k____del__, sizeof(__pyx_k____del__), 0, 0, 1, 1},
@@ -32699,6 +35862,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__beg, __pyx_k__beg, sizeof(__pyx_k__beg), 0, 0, 1, 1},
   {&__pyx_n_s__bin, __pyx_k__bin, sizeof(__pyx_k__bin), 0, 0, 1, 1},
   {&__pyx_n_s__bqual, __pyx_k__bqual, sizeof(__pyx_k__bqual), 0, 0, 1, 1},
+  {&__pyx_n_s__build, __pyx_k__build, sizeof(__pyx_k__build), 0, 0, 1, 1},
   {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
   {&__pyx_n_s__calcsize, __pyx_k__calcsize, sizeof(__pyx_k__calcsize), 0, 0, 1, 1},
   {&__pyx_n_s__call, __pyx_k__call, sizeof(__pyx_k__call), 0, 0, 1, 1},
@@ -32721,9 +35885,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__count, __pyx_k__count, sizeof(__pyx_k__count), 0, 0, 1, 1},
   {&__pyx_n_s__coverage, __pyx_k__coverage, sizeof(__pyx_k__coverage), 0, 0, 1, 1},
   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
+  {&__pyx_n_s__current_pos, __pyx_k__current_pos, sizeof(__pyx_k__current_pos), 0, 0, 1, 1},
   {&__pyx_n_s__d, __pyx_k__d, sizeof(__pyx_k__d), 0, 0, 1, 1},
   {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
   {&__pyx_n_s__data_len, __pyx_k__data_len, sizeof(__pyx_k__data_len), 0, 0, 1, 1},
+  {&__pyx_n_s__defaultdict, __pyx_k__defaultdict, sizeof(__pyx_k__defaultdict), 0, 0, 1, 1},
+  {&__pyx_n_s__devnull, __pyx_k__devnull, sizeof(__pyx_k__devnull), 0, 0, 1, 1},
   {&__pyx_n_s__dup, __pyx_k__dup, sizeof(__pyx_k__dup), 0, 0, 1, 1},
   {&__pyx_n_s__dup2, __pyx_k__dup2, sizeof(__pyx_k__dup2), 0, 0, 1, 1},
   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
@@ -32759,14 +35926,15 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
   {&__pyx_n_s__is_del, __pyx_k__is_del, sizeof(__pyx_k__is_del), 0, 0, 1, 1},
   {&__pyx_n_s__is_head, __pyx_k__is_head, sizeof(__pyx_k__is_head), 0, 0, 1, 1},
-  {&__pyx_n_s__is_paired, __pyx_k__is_paired, sizeof(__pyx_k__is_paired), 0, 0, 1, 1},
   {&__pyx_n_s__is_tail, __pyx_k__is_tail, sizeof(__pyx_k__is_tail), 0, 0, 1, 1},
   {&__pyx_n_s__isbam, __pyx_k__isbam, sizeof(__pyx_k__isbam), 0, 0, 1, 1},
   {&__pyx_n_s__isize, __pyx_k__isize, sizeof(__pyx_k__isize), 0, 0, 1, 1},
   {&__pyx_n_s__isremote, __pyx_k__isremote, sizeof(__pyx_k__isremote), 0, 0, 1, 1},
+  {&__pyx_n_s__isupper, __pyx_k__isupper, sizeof(__pyx_k__isupper), 0, 0, 1, 1},
   {&__pyx_n_s__iter, __pyx_k__iter, sizeof(__pyx_k__iter), 0, 0, 1, 1},
   {&__pyx_n_s__iterator_column, __pyx_k__iterator_column, sizeof(__pyx_k__iterator_column), 0, 0, 1, 1},
   {&__pyx_n_s__iterdata, __pyx_k__iterdata, sizeof(__pyx_k__iterdata), 0, 0, 1, 1},
+  {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
   {&__pyx_n_s__l_aux, __pyx_k__l_aux, sizeof(__pyx_k__l_aux), 0, 0, 1, 1},
   {&__pyx_n_s__l_qname, __pyx_k__l_qname, sizeof(__pyx_k__l_qname), 0, 0, 1, 1},
@@ -32779,13 +35947,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__mapq, __pyx_k__mapq, sizeof(__pyx_k__mapq), 0, 0, 1, 1},
   {&__pyx_n_s__mask, __pyx_k__mask, sizeof(__pyx_k__mask), 0, 0, 1, 1},
   {&__pyx_n_s__mate, __pyx_k__mate, sizeof(__pyx_k__mate), 0, 0, 1, 1},
-  {&__pyx_n_s__mate_is_unmapped, __pyx_k__mate_is_unmapped, sizeof(__pyx_k__mate_is_unmapped), 0, 0, 1, 1},
   {&__pyx_n_s__max_depth, __pyx_k__max_depth, sizeof(__pyx_k__max_depth), 0, 0, 1, 1},
   {&__pyx_n_s__method, __pyx_k__method, sizeof(__pyx_k__method), 0, 0, 1, 1},
   {&__pyx_n_s__min_baseQ, __pyx_k__min_baseQ, sizeof(__pyx_k__min_baseQ), 0, 0, 1, 1},
   {&__pyx_n_s__mkstemp, __pyx_k__mkstemp, sizeof(__pyx_k__mkstemp), 0, 0, 1, 1},
   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
   {&__pyx_n_s__mpos, __pyx_k__mpos, sizeof(__pyx_k__mpos), 0, 0, 1, 1},
+  {&__pyx_n_s__mrnm, __pyx_k__mrnm, sizeof(__pyx_k__mrnm), 0, 0, 1, 1},
   {&__pyx_n_s__mtid, __pyx_k__mtid, sizeof(__pyx_k__mtid), 0, 0, 1, 1},
   {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
   {&__pyx_n_s__n_cigar, __pyx_k__n_cigar, sizeof(__pyx_k__n_cigar), 0, 0, 1, 1},
@@ -32803,14 +35971,18 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__opt, __pyx_k__opt, sizeof(__pyx_k__opt), 0, 0, 1, 1},
   {&__pyx_n_s__options, __pyx_k__options, sizeof(__pyx_k__options), 0, 0, 1, 1},
   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
+  {&__pyx_n_s__overlap, __pyx_k__overlap, sizeof(__pyx_k__overlap), 0, 0, 1, 1},
+  {&__pyx_n_s__owns_samfile, __pyx_k__owns_samfile, sizeof(__pyx_k__owns_samfile), 0, 0, 1, 1},
   {&__pyx_n_s__pack_into, __pyx_k__pack_into, sizeof(__pyx_k__pack_into), 0, 0, 1, 1},
   {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
   {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
   {&__pyx_n_s__pileup_iter, __pyx_k__pileup_iter, sizeof(__pyx_k__pileup_iter), 0, 0, 1, 1},
   {&__pyx_n_s__pileups, __pyx_k__pileups, sizeof(__pyx_k__pileups), 0, 0, 1, 1},
+  {&__pyx_n_s__platform, __pyx_k__platform, sizeof(__pyx_k__platform), 0, 0, 1, 1},
   {&__pyx_n_s__plp, __pyx_k__plp, sizeof(__pyx_k__plp), 0, 0, 1, 1},
   {&__pyx_n_s__port, __pyx_k__port, sizeof(__pyx_k__port), 0, 0, 1, 1},
   {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
+  {&__pyx_n_s__positions, __pyx_k__positions, sizeof(__pyx_k__positions), 0, 0, 1, 1},
   {&__pyx_n_s__q_cns, __pyx_k__q_cns, sizeof(__pyx_k__q_cns), 0, 0, 1, 1},
   {&__pyx_n_s__q_indel, __pyx_k__q_indel, sizeof(__pyx_k__q_indel), 0, 0, 1, 1},
   {&__pyx_n_s__q_r, __pyx_k__q_r, sizeof(__pyx_k__q_r), 0, 0, 1, 1},
@@ -32843,6 +36015,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__restore, __pyx_k__restore, sizeof(__pyx_k__restore), 0, 0, 1, 1},
   {&__pyx_n_s__retval, __pyx_k__retval, sizeof(__pyx_k__retval), 0, 0, 1, 1},
   {&__pyx_n_s__rg2lib, __pyx_k__rg2lib, sizeof(__pyx_k__rg2lib), 0, 0, 1, 1},
+  {&__pyx_n_s__rlen, __pyx_k__rlen, sizeof(__pyx_k__rlen), 0, 0, 1, 1},
   {&__pyx_n_s__rname, __pyx_k__rname, sizeof(__pyx_k__rname), 0, 0, 1, 1},
   {&__pyx_n_s__rowiter, __pyx_k__rowiter, sizeof(__pyx_k__rowiter), 0, 0, 1, 1},
   {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
@@ -32871,6 +36044,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
   {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
   {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
+  {&__pyx_n_s__system, __pyx_k__system, sizeof(__pyx_k__system), 0, 0, 1, 1},
   {&__pyx_n_s__tags, __pyx_k__tags, sizeof(__pyx_k__tags), 0, 0, 1, 1},
   {&__pyx_n_s__target_len, __pyx_k__target_len, sizeof(__pyx_k__target_len), 0, 0, 1, 1},
   {&__pyx_n_s__target_name, __pyx_k__target_name, sizeof(__pyx_k__target_name), 0, 0, 1, 1},
@@ -32894,48 +36068,49 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {0, 0, 0, 0, 0, 0, 0}
 };
 static int __Pyx_InitCachedBuiltins(void) {
-  __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __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 = 106; __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 = 120; __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 = 249; __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 = 267; __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 = 652; __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 = 1074; __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 = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __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 = 2337; __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 = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __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 = 67; __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 = 117; __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 = 131; __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 = 271; __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 = 289; __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 = 666; __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 = 699; __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 = 1136; __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 = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __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 = 2547; __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 = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   return 0;
   __pyx_L1_error:;
   return -1;
 }
 
 static int __Pyx_InitGlobals(void) {
-  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_60 = PyInt_FromLong(60); if (unlikely(!__pyx_int_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_64 = PyInt_FromLong(64); if (unlikely(!__pyx_int_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_127 = PyInt_FromLong(-127); if (unlikely(!__pyx_int_neg_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_0660 = PyInt_FromLong(0660); if (unlikely(!__pyx_int_0660)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_65535 = PyInt_FromLong(65535); if (unlikely(!__pyx_int_65535)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_32767 = PyInt_FromLong(-32767); if (unlikely(!__pyx_int_neg_32767)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_536870912 = PyInt_FromLong(536870912); if (unlikely(!__pyx_int_536870912)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_2147483648 = PyInt_FromLong(-2147483648); if (unlikely(!__pyx_int_neg_2147483648)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_60 = PyInt_FromLong(60); if (unlikely(!__pyx_int_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_64 = PyInt_FromLong(64); if (unlikely(!__pyx_int_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_127 = PyInt_FromLong(-127); if (unlikely(!__pyx_int_neg_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0660 = PyInt_FromLong(0660); if (unlikely(!__pyx_int_0660)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_65535 = PyInt_FromLong(65535); if (unlikely(!__pyx_int_65535)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_32767 = PyInt_FromLong(-32767); if (unlikely(!__pyx_int_neg_32767)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_536870912 = PyInt_FromLong(536870912); if (unlikely(!__pyx_int_536870912)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_2147483648 = PyInt_FromLong(-2147483648); if (unlikely(!__pyx_int_neg_2147483648)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
   return 0;
   __pyx_L1_error:;
   return -1;
@@ -32953,6 +36128,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
   #if CYTHON_REFNANNY
   void* __pyx_refnanny = NULL;
   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
@@ -32964,10 +36140,10 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   }
   __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_csamtools(void)", __LINE__, __FILE__);
   #endif
-  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #ifdef __pyx_binding_PyCFunctionType_USED
-  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #endif
   /*--- Library function declarations ---*/
   /*--- Threads initialization code ---*/
@@ -32982,75 +36158,79 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   #else
   __pyx_m = PyModule_Create(&__pyx_moduledef);
   #endif
-  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
   #if PY_MAJOR_VERSION < 3
   Py_INCREF(__pyx_m);
   #endif
   __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
-  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
   /*--- Initialize various global constants etc. ---*/
-  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_module_is_main_csamtools) {
-    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
   }
   /*--- Builtin init code ---*/
-  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   /*--- Global init code ---*/
   /*--- Function export code ---*/
   /*--- Type init code ---*/
-  __pyx_ptype_9csamtools_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_9csamtools_file)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyType_Ready(&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_9csamtools_file)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_11AlignedRead___str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_11AlignedRead___str__.doc = __pyx_doc_9csamtools_11AlignedRead___str__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_11AlignedRead___str__;
     }
   }
-  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_AlignedRead = &__pyx_type_9csamtools_AlignedRead;
-  if (PyType_Ready(&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_PileupProxy = &__pyx_type_9csamtools_PileupProxy;
-  if (PyType_Ready(&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_PileupRead = &__pyx_type_9csamtools_PileupRead;
-  __pyx_vtabptr_9csamtools_Fastafile = &__pyx_vtable_9csamtools_Fastafile;
-  #if PY_MAJOR_VERSION >= 3
-  __pyx_vtable_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_9csamtools_9Fastafile__fetch;
-  #else
-  *(void(**)(void))&__pyx_vtable_9csamtools_Fastafile._fetch = (void(*)(void))__pyx_f_9csamtools_9Fastafile__fetch;
-  #endif
-  if (PyType_Ready(&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_Fastafile = &__pyx_type_9csamtools_Fastafile;
   __pyx_vtabptr_9csamtools_Samfile = &__pyx_vtable_9csamtools_Samfile;
   #if PY_MAJOR_VERSION >= 3
   __pyx_vtable_9csamtools_Samfile._buildHeader = (bam_header_t *(*)(struct __pyx_obj_9csamtools_Samfile *, PyObject *))__pyx_f_9csamtools_7Samfile__buildHeader;
   __pyx_vtable_9csamtools_Samfile.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_getCurrent;
   __pyx_vtable_9csamtools_Samfile.cnext = (int (*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_cnext;
+  __pyx_vtable_9csamtools_Samfile.write = (int (*)(struct __pyx_obj_9csamtools_Samfile *, struct __pyx_obj_9csamtools_AlignedRead *, int __pyx_skip_dispatch))__pyx_f_9csamtools_7Samfile_write;
+  __pyx_vtable_9csamtools_Samfile._getrname = (char *(*)(struct __pyx_obj_9csamtools_Samfile *, int))__pyx_f_9csamtools_7Samfile__getrname;
   #else
   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._buildHeader = (void(*)(void))__pyx_f_9csamtools_7Samfile__buildHeader;
   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.getCurrent = (void(*)(void))__pyx_f_9csamtools_7Samfile_getCurrent;
   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.cnext = (void(*)(void))__pyx_f_9csamtools_7Samfile_cnext;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.write = (void(*)(void))__pyx_f_9csamtools_7Samfile_write;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._getrname = (void(*)(void))__pyx_f_9csamtools_7Samfile__getrname;
   #endif
-  if (PyType_Ready(&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_7Samfile___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_7Samfile___next__.doc = __pyx_doc_9csamtools_7Samfile___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_7Samfile___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_Samfile.tp_dict, __pyx_vtabptr_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_Samfile.tp_dict, __pyx_vtabptr_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_Samfile = &__pyx_type_9csamtools_Samfile;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_PileupProxy = &__pyx_type_9csamtools_PileupProxy;
+  if (PyType_Ready(&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_PileupRead = &__pyx_type_9csamtools_PileupRead;
+  __pyx_vtabptr_9csamtools_Fastafile = &__pyx_vtable_9csamtools_Fastafile;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_9csamtools_9Fastafile__fetch;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_Fastafile._fetch = (void(*)(void))__pyx_f_9csamtools_9Fastafile__fetch;
+  #endif
+  if (PyType_Ready(&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_Fastafile = &__pyx_type_9csamtools_Fastafile;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorRow = &__pyx_type_9csamtools_IteratorRow;
   __pyx_vtabptr_9csamtools_IteratorRowRegion = &__pyx_vtable_9csamtools_IteratorRowRegion;
   #if PY_MAJOR_VERSION >= 3
@@ -33061,17 +36241,17 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.cnext = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
   #endif
   __pyx_type_9csamtools_IteratorRowRegion.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__.doc = __pyx_doc_9csamtools_17IteratorRowRegion___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorRowRegion = &__pyx_type_9csamtools_IteratorRowRegion;
   __pyx_vtabptr_9csamtools_IteratorRowAll = &__pyx_vtable_9csamtools_IteratorRowAll;
   #if PY_MAJOR_VERSION >= 3
@@ -33082,30 +36262,51 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_cnext;
   #endif
   __pyx_type_9csamtools_IteratorRowAll.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__.doc = __pyx_doc_9csamtools_14IteratorRowAll___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_14IteratorRowAll___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorRowAll = &__pyx_type_9csamtools_IteratorRowAll;
   __pyx_type_9csamtools_IteratorRowAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__.doc = __pyx_doc_9csamtools_18IteratorRowAllRefs___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__;
     }
   }
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorRowAllRefs = &__pyx_type_9csamtools_IteratorRowAllRefs;
+  __pyx_vtabptr_9csamtools_IteratorRowSelection = &__pyx_vtable_9csamtools_IteratorRowSelection;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
+  __pyx_vtable_9csamtools_IteratorRowSelection.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.cnext = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
+  #endif
+  __pyx_type_9csamtools_IteratorRowSelection.tp_base = __pyx_ptype_9csamtools_IteratorRow;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowSelection, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__.doc = __pyx_doc_9csamtools_20IteratorRowSelection___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowSelection.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowSelection", (PyObject *)&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRowSelection = &__pyx_type_9csamtools_IteratorRowSelection;
   __pyx_vtabptr_9csamtools_IteratorColumn = &__pyx_vtable_9csamtools_IteratorColumn;
   #if PY_MAJOR_VERSION >= 3
   __pyx_vtable_9csamtools_IteratorColumn.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_cnext;
@@ -33120,42 +36321,42 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData;
   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.reset = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_reset;
   #endif
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorColumn = &__pyx_type_9csamtools_IteratorColumn;
   __pyx_vtabptr_9csamtools_IteratorColumnRegion = &__pyx_vtable_9csamtools_IteratorColumnRegion;
   __pyx_vtable_9csamtools_IteratorColumnRegion.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
   __pyx_type_9csamtools_IteratorColumnRegion.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__.doc = __pyx_doc_9csamtools_20IteratorColumnRegion___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorColumnRegion = &__pyx_type_9csamtools_IteratorColumnRegion;
   __pyx_vtabptr_9csamtools_IteratorColumnAllRefs = &__pyx_vtable_9csamtools_IteratorColumnAllRefs;
   __pyx_vtable_9csamtools_IteratorColumnAllRefs.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
   __pyx_type_9csamtools_IteratorColumnAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__.doc = __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorColumnAllRefs = &__pyx_type_9csamtools_IteratorColumnAllRefs;
-  if (PyType_Ready(&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_SNPCall = &__pyx_type_9csamtools_SNPCall;
   __pyx_vtabptr_9csamtools_SNPCallerBase = &__pyx_vtable_9csamtools_SNPCallerBase;
   #if PY_MAJOR_VERSION >= 3
@@ -33163,109 +36364,192 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   #else
   *(void(**)(void))&__pyx_vtable_9csamtools_SNPCallerBase.__dump = (void(*)(void))__pyx_f_9csamtools_13SNPCallerBase___dump;
   #endif
-  if (PyType_Ready(&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCallerBase.tp_dict, __pyx_vtabptr_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "SNPCallerBase", (PyObject *)&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCallerBase.tp_dict, __pyx_vtabptr_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCallerBase", (PyObject *)&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_SNPCallerBase = &__pyx_type_9csamtools_SNPCallerBase;
   __pyx_vtabptr_9csamtools_IteratorSNPCalls = &__pyx_vtable_9csamtools_IteratorSNPCalls;
   __pyx_vtable_9csamtools_IteratorSNPCalls.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
   __pyx_type_9csamtools_IteratorSNPCalls.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__.doc = __pyx_doc_9csamtools_16IteratorSNPCalls___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorSNPCalls.tp_dict, __pyx_vtabptr_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorSNPCalls", (PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorSNPCalls.tp_dict, __pyx_vtabptr_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorSNPCalls", (PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorSNPCalls = &__pyx_type_9csamtools_IteratorSNPCalls;
   __pyx_vtabptr_9csamtools_SNPCaller = &__pyx_vtable_9csamtools_SNPCaller;
   __pyx_vtable_9csamtools_SNPCaller.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
   __pyx_type_9csamtools_SNPCaller.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
-  if (PyType_Ready(&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCaller.tp_dict, __pyx_vtabptr_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "SNPCaller", (PyObject *)&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCaller.tp_dict, __pyx_vtabptr_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCaller", (PyObject *)&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_SNPCaller = &__pyx_type_9csamtools_SNPCaller;
-  if (PyType_Ready(&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IndelCall", (PyObject *)&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCall", (PyObject *)&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IndelCall = &__pyx_type_9csamtools_IndelCall;
-  if (PyType_Ready(&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IndelCallerBase", (PyObject *)&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCallerBase", (PyObject *)&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IndelCallerBase = &__pyx_type_9csamtools_IndelCallerBase;
   __pyx_type_9csamtools_IndelCaller.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
-  if (PyType_Ready(&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IndelCaller", (PyObject *)&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCaller", (PyObject *)&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IndelCaller = &__pyx_type_9csamtools_IndelCaller;
   __pyx_type_9csamtools_IteratorIndelCalls.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__.doc = __pyx_doc_9csamtools_18IteratorIndelCalls___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
     }
   }
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorIndelCalls", (PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorIndelCalls", (PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_9csamtools_IteratorIndelCalls = &__pyx_type_9csamtools_IteratorIndelCalls;
+  if (PyType_Ready(&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndexedReads", (PyObject *)&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IndexedReads = &__pyx_type_9csamtools_IndexedReads;
   /*--- Type import code ---*/
   __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   /*--- Function import code ---*/
   /*--- Execution code ---*/
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":4
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":4
  * # cython: profile=True
  * # adds doc-strings for sphinx
- * import tempfile, os, sys, types, struct, ctypes, collections, re             # <<<<<<<<<<<<<<
- * 
- * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+ * import tempfile             # <<<<<<<<<<<<<<
+ * import os
+ * import sys
  */
   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__tempfile), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tempfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":5
+ * # adds doc-strings for sphinx
+ * import tempfile
+ * import os             # <<<<<<<<<<<<<<
+ * import sys
+ * import types
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":6
+ * import tempfile
+ * import os
+ * import sys             # <<<<<<<<<<<<<<
+ * import types
+ * import itertools
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":7
+ * import os
+ * import sys
+ * import types             # <<<<<<<<<<<<<<
+ * import itertools
+ * import struct
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":8
+ * import sys
+ * import types
+ * import itertools             # <<<<<<<<<<<<<<
+ * import struct
+ * import ctypes
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":9
+ * import types
+ * import itertools
+ * import struct             # <<<<<<<<<<<<<<
+ * import ctypes
+ * import collections
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":10
+ * import itertools
+ * import struct
+ * import ctypes             # <<<<<<<<<<<<<<
+ * import collections
+ * import re
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":11
+ * import struct
+ * import ctypes
+ * import collections             # <<<<<<<<<<<<<<
+ * import re
+ * import platform
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__collections, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":12
+ * import ctypes
+ * import collections
+ * import re             # <<<<<<<<<<<<<<
+ * import platform
+ * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__collections, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":13
+ * import collections
+ * import re
+ * import platform             # <<<<<<<<<<<<<<
+ * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+ * from cpython cimport PyErr_SetString
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__platform), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__platform, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":52
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":63
  * #####################################################################
  * # hard-coded constants
  * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"             # <<<<<<<<<<<<<<
  * cdef int max_pos = 2 << 29
  * 
  */
-  __pyx_v_9csamtools_bam_nt16_rev_table = __pyx_k_166;
+  __pyx_v_9csamtools_bam_nt16_rev_table = __pyx_k_172;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":53
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":64
  * # hard-coded constants
  * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
  * cdef int max_pos = 2 << 29             # <<<<<<<<<<<<<<
@@ -33274,1012 +36558,1160 @@ PyMODINIT_FUNC PyInit_csamtools(void)
  */
   __pyx_v_9csamtools_max_pos = 1073741824;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":56
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":67
  * 
  * # redirect stderr to 0
- * _logfile = open("/dev/null", "w")             # <<<<<<<<<<<<<<
+ * _logfile = open(os.path.devnull, "w")             # <<<<<<<<<<<<<<
  * pysam_set_stderr( PyFile_AsFile( _logfile ) )
  * 
  */
-  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __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 = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_167));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_167));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_167));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
-  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__w));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
-  __pyx_t_2 = PyObject_Call(__pyx_builtin_open, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___logfile, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__devnull); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __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(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__w));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_open, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __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___logfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":57
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":68
  * # redirect stderr to 0
- * _logfile = open("/dev/null", "w")
+ * _logfile = open(os.path.devnull, "w")
  * pysam_set_stderr( PyFile_AsFile( _logfile ) )             # <<<<<<<<<<<<<<
  * 
  * #####################################################################
  */
-  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s___logfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  pysam_set_stderr(PyFile_AsFile(__pyx_t_2));
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___logfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  pysam_set_stderr(PyFile_AsFile(__pyx_t_1));
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":106
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":117
  *     (<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 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __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 = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_builtin_object);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_object);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
   __Pyx_GIVEREF(__pyx_builtin_object);
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_168)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_1, ((PyObject *)__pyx_t_2), __pyx_n_s__PileupColumn, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_173)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_2, ((PyObject *)__pyx_t_1), __pyx_n_s__PileupColumn, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __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_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":119
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
  *         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_1 = PyCFunction_New(&__pyx_mdef_9csamtools_12PileupColumn___str__, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_12PileupColumn___str__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____str__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____str__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":163
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":174
  *     return 0
  * 
  * class StderrStore():             # <<<<<<<<<<<<<<
  *     '''
  *     stderr is captured.
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_169)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__StderrStore, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_174)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStore, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":167
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  */
-  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":173
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
  *         return []
  *         self.stderr_save.restore()
  */
-  __pyx_t_1 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_readAndRelease, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_readAndRelease, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":182
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_save.restore()
  */
-  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_release, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_release, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__release, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__release, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":188
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
  *         self.release()
  * 
  */
-  __pyx_t_1 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___del__, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___del__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____del__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____del__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":202
+ *         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 = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_175)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStoreWindows, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
+ * 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 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
+ *     def release(self): pass
+ * 
+ */
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows_readAndRelease, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []
+ *     def release(self): pass             # <<<<<<<<<<<<<<
+ * 
+ * if platform.system()=='Windows':
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows_release, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__release, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStoreWindows, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":208
+ *     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 = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__system); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __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 = 208; __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_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Windows), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __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 = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_5) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":209
+ * 
+ * if platform.system()=='Windows':
+ *     del StderrStore             # <<<<<<<<<<<<<<
+ *     StderrStore = StderrStoreWindows
+ * 
+ */
+    if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":210
+ * if platform.system()=='Windows':
+ *     del StderrStore
+ *     StderrStore = StderrStoreWindows             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStoreWindows); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":195
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":217
  * ######################################################################
  * # valid types for sam headers
  * VALID_HEADER_TYPES = { "HD" : dict,             # <<<<<<<<<<<<<<
  *                        "SQ" : list,
  *                        "RG" : list,
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)&PyDict_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)&PyDict_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":196
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":218
  * # valid types for sam headers
  * VALID_HEADER_TYPES = { "HD" : dict,
  *                        "SQ" : list,             # <<<<<<<<<<<<<<
  *                        "RG" : list,
  *                        "PG" : list,
  */
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":197
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":219
  * VALID_HEADER_TYPES = { "HD" : dict,
  *                        "SQ" : list,
  *                        "RG" : list,             # <<<<<<<<<<<<<<
  *                        "PG" : list,
  *                        "CO" : list }
  */
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":198
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":220
  *                        "SQ" : list,
  *                        "RG" : list,
  *                        "PG" : list,             # <<<<<<<<<<<<<<
  *                        "CO" : list }
  * 
  */
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":199
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":221
  *                        "RG" : list,
  *                        "PG" : list,
  *                        "CO" : list }             # <<<<<<<<<<<<<<
  * 
  * # order of records within sam headers
  */
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":202
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":224
  * 
  * # order of records within sam headers
  * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
  * 
  * # type conversions within sam header records
  */
-  __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__HD));
-  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__HD));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__HD));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__HD));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SQ));
-  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__SQ));
+  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__SQ));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SQ));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__RG));
-  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__RG));
+  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__RG));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__RG));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PG));
-  PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__PG));
+  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__PG));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PG));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__CO));
-  PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_n_s__CO));
+  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__CO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CO));
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":205
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":227
  * 
  * # 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, },
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SO), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__GO), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __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 = 227; __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 = 227; __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 = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":206
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":228
  * # 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, },
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
  */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__LN), ((PyObject *)((PyObject*)&PyInt_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__AS), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__M5), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__UR), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SP), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __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 = 228; __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 = 228; __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 = 228; __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 = 228; __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 = 228; __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 = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":207
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":229
  * 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, },             # <<<<<<<<<<<<<<
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
  * 
  */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SM), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__LB), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__DS), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PU), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PI), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__CN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__DT), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PL), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __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 = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":208
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":230
  *                         "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, },
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }             # <<<<<<<<<<<<<<
  * 
  * # output order of fields within records
  */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__CL), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __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 = 230; __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 = 230; __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 = 230; __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 = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __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_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":211
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":233
  * 
  * # 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" ),
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__VN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__VN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SO));
-  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__SO));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SO));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__GO));
-  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__GO));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__GO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GO));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__HD), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":212
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":234
  * # 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" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
  */
-  __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SN));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__SN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__SN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__LN));
-  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__LN));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__LN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__AS));
-  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__AS));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__AS));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AS));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__M5));
-  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__M5));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__M5));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__M5));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__UR));
-  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__UR));
+  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__UR));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UR));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SP));
-  PyTuple_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__SP));
+  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__SP));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SP));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__SQ), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":213
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":235
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),             # <<<<<<<<<<<<<<
  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
  * 
  */
-  __pyx_t_3 = PyTuple_New(9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__ID));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SM));
-  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__SM));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SM));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SM));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__LB));
-  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__LB));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__LB));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LB));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__DS));
-  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__DS));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__DS));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DS));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PU));
-  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__PU));
+  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__PU));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PU));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PI));
-  PyTuple_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__PI));
+  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__PI));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PI));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__CN));
-  PyTuple_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__CN));
+  PyTuple_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__CN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__DT));
-  PyTuple_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__DT));
+  PyTuple_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__DT));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DT));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PL));
-  PyTuple_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__PL));
+  PyTuple_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__PL));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PL));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__RG), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":214
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":236
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(4); 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_INCREF(((PyObject *)__pyx_n_s__PN));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__PN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__PN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
-  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__ID));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
-  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__VN));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__VN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__CL));
-  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__CL));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__CL));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CL));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__PG), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":672
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":719
  *                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_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_k_27 = __pyx_t_2;
-  __Pyx_GIVEREF(__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_29 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":781
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":830
  *                end = None,
  *                region = None,
  *                until_eof = False ):             # <<<<<<<<<<<<<<
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  * 
  */
-  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_k_37 = __pyx_t_2;
-  __Pyx_GIVEREF(__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_39 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":1573
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1718
  *                   int tid = 0,
  *                   int start = 0,
  *                   int end = max_pos,             # <<<<<<<<<<<<<<
  *                   **kwargs ):
  * 
  */
-  __pyx_k_55 = __pyx_v_9csamtools_max_pos;
+  __pyx_k_58 = __pyx_v_9csamtools_max_pos;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2489
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2699
  *             return self._level
  * 
  * class Outs:             # <<<<<<<<<<<<<<
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_2), "__doc__", ((PyObject *)__pyx_kp_s_170)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2), __pyx_n_s__Outs, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_3), "__doc__", ((PyObject *)__pyx_kp_s_176)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3), __pyx_n_s__Outs, "csamtools"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2491
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
  * 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_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs___init__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __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_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_1) < 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;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2495
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)
  */
-  __pyx_t_1 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setdevice, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setdevice, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__setdevice, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__setdevice, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2500
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  */
-  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfile, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfile, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; __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_t_1, __pyx_n_s__setfile, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__setfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2505
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
  *         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 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfd, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyMethod_New(__pyx_t_1, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfd, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__setfd, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__setfd, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2512
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
  *         '''restore previous output stream'''
  *         if self.streams:
  */
-  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_restore, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_restore, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __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_t_1, __pyx_n_s__restore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__restore, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __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 = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Outs, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2525
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2736
  * def _samtools_dispatch( method,
  *                         args = (),
  *                         catch_stdout = True,             # <<<<<<<<<<<<<<
  *                         catch_stderr = False,
  *                         ):
  */
-  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_k_95 = __pyx_t_2;
-  __Pyx_GIVEREF(__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_98 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2526
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2737
  *                         args = (),
  *                         catch_stdout = True,
  *                         catch_stderr = False,             # <<<<<<<<<<<<<<
  *                         ):
  *     '''call ``method`` in samtools providing arguments in args.
  */
-  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_k_96 = __pyx_t_2;
-  __Pyx_GIVEREF(__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_99 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":3157
- *         return self._call()
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3436
+ *         if self.owns_samfile: samclose( self.fp )
  * 
  * __all__ = ["Samfile",             # <<<<<<<<<<<<<<
  *            "Fastafile",
  *            "IteratorRow",
  */
-  __pyx_t_2 = PyList_New(12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_3 = PyList_New(13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__Samfile));
-  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__Samfile));
+  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Samfile));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Samfile));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastafile));
-  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__Fastafile));
+  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__Fastafile));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastafile));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorRow));
-  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__IteratorRow));
+  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__IteratorRow));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorRow));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorColumn));
-  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
+  PyList_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorColumn));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedRead));
-  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_n_s__AlignedRead));
+  PyList_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__AlignedRead));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedRead));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupColumn));
-  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)__pyx_n_s__PileupColumn));
+  PyList_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__PileupColumn));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupColumn));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupProxy));
-  PyList_SET_ITEM(__pyx_t_2, 6, ((PyObject *)__pyx_n_s__PileupProxy));
+  PyList_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__PileupProxy));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupProxy));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupRead));
-  PyList_SET_ITEM(__pyx_t_2, 7, ((PyObject *)__pyx_n_s__PileupRead));
+  PyList_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__PileupRead));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupRead));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
-  PyList_SET_ITEM(__pyx_t_2, 8, ((PyObject *)__pyx_n_s__IteratorSNPCalls));
+  PyList_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__IteratorSNPCalls));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SNPCaller));
-  PyList_SET_ITEM(__pyx_t_2, 9, ((PyObject *)__pyx_n_s__SNPCaller));
+  PyList_SET_ITEM(__pyx_t_3, 9, ((PyObject *)__pyx_n_s__SNPCaller));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SNPCaller));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IndelCaller));
-  PyList_SET_ITEM(__pyx_t_2, 10, ((PyObject *)__pyx_n_s__IndelCaller));
+  PyList_SET_ITEM(__pyx_t_3, 10, ((PyObject *)__pyx_n_s__IndelCaller));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndelCaller));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
-  PyList_SET_ITEM(__pyx_t_2, 11, ((PyObject *)__pyx_n_s__IteratorIndelCalls));
+  PyList_SET_ITEM(__pyx_t_3, 11, ((PyObject *)__pyx_n_s__IteratorIndelCalls));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IndexedReads));
+  PyList_SET_ITEM(__pyx_t_3, 12, ((PyObject *)__pyx_n_s__IndexedReads));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndexedReads));
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/csamtools.pyx":2
- *         # cython: embedsignature=True
- * # cython: profile=True             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1
+ * # cython: embedsignature=True             # <<<<<<<<<<<<<<
+ * # cython: profile=True
  * # adds doc-strings for sphinx
- * import tempfile, os, sys, types, struct, ctypes, collections, re
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_171), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_177), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_172), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fetch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_173), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_178), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_174), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fetch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_175), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_179), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_176), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__getrname); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_177), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_180), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_178), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_179), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_181), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_180), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__tell); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_181), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fetch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_182), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_182), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__mate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__gettid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_183), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_183), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_184), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__pileup); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getrname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_185), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_184), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_186), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_187), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s___buildLine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_185), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_186), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__tell); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_187), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fetch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_188), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__mate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_189), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_190), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__pileup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_191), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_192), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_193), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___buildLine); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_194), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_195), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_196), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_197), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAllRefs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_198), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_200); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_199), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__addReference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_201), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__hasReference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_202), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_204); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_203), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_188), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_206); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_189), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowRegion); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_205), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_190), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____str__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_191), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAllRefs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_207), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_192), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__addReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__compare); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_193), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_208), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_194), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s_196); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__overlap); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_195), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s_198); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_209), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_197), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____str__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__opt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_199), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__compare); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_210), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_200), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__opt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fancy_str); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_201), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fancy_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_211), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_202), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__setdevice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__setdevice); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_203), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__setfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_212), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_204), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__setfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_205), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s___samtools_dispatch); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_206), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_213), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorSNPCalls); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_207), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_214), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__SNPCaller); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s___samtools_dispatch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__call); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_215), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorSNPCalls); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_208), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_m, __pyx_n_s__IndelCaller); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_216), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__SNPCaller); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__call); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__call); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_217), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IndelCaller); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__call); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_209), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __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_m, __pyx_n_s__IteratorIndelCalls); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_218), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorIndelCalls); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_219), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IndexedReads); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__build); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_kp_u_210), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_220), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "/cpp-software/lib/python2.6/site-packages/Cython/Includes/cpython/iterator.pxd":1
+  /* "/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/Cython-0.13-py2.7-linux-x86_64.egg/Cython/Includes/cpython/type.pxd":2
+ * 
  * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
+ *     # The C structure of the objects used to describe built-in types.
  * 
- *     ############################################################################
  */
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -34639,15 +38071,6 @@ static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed
     return 0;
 }
 
-
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
-}
-
-static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
-}
-
 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
     PyObject *local_type, *local_value, *local_tb;
     PyObject *tmp_type, *tmp_value, *tmp_tb;
@@ -34694,6 +38117,15 @@ bad:
 }
 
 
+
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
+}
+
 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
     long q = a / b;
     long r = a - q*b;
@@ -35027,6 +38459,58 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int64_t(int64_t val) {
     }
 }
 
+static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject* x) {
+    const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
+    const int is_unsigned = const_zero < neg_one;
+    if (sizeof(uint64_t) == sizeof(char)) {
+        if (is_unsigned)
+            return (uint64_t)__Pyx_PyInt_AsUnsignedChar(x);
+        else
+            return (uint64_t)__Pyx_PyInt_AsSignedChar(x);
+    } else if (sizeof(uint64_t) == sizeof(short)) {
+        if (is_unsigned)
+            return (uint64_t)__Pyx_PyInt_AsUnsignedShort(x);
+        else
+            return (uint64_t)__Pyx_PyInt_AsSignedShort(x);
+    } else if (sizeof(uint64_t) == sizeof(int)) {
+        if (is_unsigned)
+            return (uint64_t)__Pyx_PyInt_AsUnsignedInt(x);
+        else
+            return (uint64_t)__Pyx_PyInt_AsSignedInt(x);
+    } else if (sizeof(uint64_t) == sizeof(long)) {
+        if (is_unsigned)
+            return (uint64_t)__Pyx_PyInt_AsUnsignedLong(x);
+        else
+            return (uint64_t)__Pyx_PyInt_AsSignedLong(x);
+    } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return (uint64_t)__Pyx_PyInt_AsUnsignedLongLong(x);
+        else
+            return (uint64_t)__Pyx_PyInt_AsSignedLongLong(x);
+    }  else {
+        uint64_t val;
+        PyObject *v = __Pyx_PyNumber_Int(x);
+        #if PY_VERSION_HEX < 0x03000000
+        if (likely(v) && !PyLong_Check(v)) {
+            PyObject *tmp = v;
+            v = PyNumber_Long(tmp);
+            Py_DECREF(tmp);
+        }
+        #endif
+        if (likely(v)) {
+            int one = 1; int is_little = (int)*(unsigned char *)&one;
+            unsigned char *bytes = (unsigned char *)&val;
+            int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                          bytes, sizeof(val),
+                                          is_little, !is_unsigned);
+            Py_DECREF(v);
+            if (likely(!ret))
+                return val;
+        }
+        return (uint64_t)-1;
+    }
+}
+
 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
     const int is_unsigned = const_zero < neg_one;
@@ -35241,6 +38725,31 @@ static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
 
 #endif
 
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t val) {
+    const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
+    const int is_unsigned = const_zero < neg_one;
+    if ((sizeof(uint64_t) == sizeof(char))  ||
+        (sizeof(uint64_t) == sizeof(short))) {
+        return PyInt_FromLong((long)val);
+    } else if ((sizeof(uint64_t) == sizeof(int)) ||
+               (sizeof(uint64_t) == sizeof(long))) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLong((unsigned long)val);
+        else
+            return PyInt_FromLong((long)val);
+    } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
+        else
+            return PyLong_FromLongLong((PY_LONG_LONG)val);
+    } else {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&val;
+        return _PyLong_FromByteArray(bytes, sizeof(uint64_t), 
+                                     little, !is_unsigned);
+    }
+}
+
 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
     const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
     const int is_unsigned = neg_one > const_zero;
@@ -35659,58 +39168,6 @@ static void __Pyx_WriteUnraisable(const char *name) {
     }
 }
 
-static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject* x) {
-    const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
-    const int is_unsigned = const_zero < neg_one;
-    if (sizeof(uint64_t) == sizeof(char)) {
-        if (is_unsigned)
-            return (uint64_t)__Pyx_PyInt_AsUnsignedChar(x);
-        else
-            return (uint64_t)__Pyx_PyInt_AsSignedChar(x);
-    } else if (sizeof(uint64_t) == sizeof(short)) {
-        if (is_unsigned)
-            return (uint64_t)__Pyx_PyInt_AsUnsignedShort(x);
-        else
-            return (uint64_t)__Pyx_PyInt_AsSignedShort(x);
-    } else if (sizeof(uint64_t) == sizeof(int)) {
-        if (is_unsigned)
-            return (uint64_t)__Pyx_PyInt_AsUnsignedInt(x);
-        else
-            return (uint64_t)__Pyx_PyInt_AsSignedInt(x);
-    } else if (sizeof(uint64_t) == sizeof(long)) {
-        if (is_unsigned)
-            return (uint64_t)__Pyx_PyInt_AsUnsignedLong(x);
-        else
-            return (uint64_t)__Pyx_PyInt_AsSignedLong(x);
-    } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
-        if (is_unsigned)
-            return (uint64_t)__Pyx_PyInt_AsUnsignedLongLong(x);
-        else
-            return (uint64_t)__Pyx_PyInt_AsSignedLongLong(x);
-    }  else {
-        uint64_t val;
-        PyObject *v = __Pyx_PyNumber_Int(x);
-        #if PY_VERSION_HEX < 0x03000000
-        if (likely(v) && !PyLong_Check(v)) {
-            PyObject *tmp = v;
-            v = PyNumber_Long(tmp);
-            Py_DECREF(tmp);
-        }
-        #endif
-        if (likely(v)) {
-            int one = 1; int is_little = (int)*(unsigned char *)&one;
-            unsigned char *bytes = (unsigned char *)&val;
-            int ret = _PyLong_AsByteArray((PyLongObject *)v,
-                                          bytes, sizeof(val),
-                                          is_little, !is_unsigned);
-            Py_DECREF(v);
-            if (likely(!ret))
-                return val;
-        }
-        return (uint64_t)-1;
-    }
-}
-
 #ifndef __PYX_HAVE_RT_ImportType
 #define __PYX_HAVE_RT_ImportType
 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
index 43cfe0cef5dcdb501c62ddc562a0345f2f9014e3..df3763802d7ee5742a5379acbfc43b4d052ddf6d 100644 (file)
@@ -1,4 +1,3 @@
-
 cdef extern from "string.h":
   ctypedef int size_t
   void *memcpy(void *dst,void *src,size_t len)
@@ -71,7 +70,6 @@ cdef extern from "stdint.h":
   ctypedef int uint8_t
   ctypedef int uint64_t
 
-
 cdef extern from "bam.h":
 
   # constants
@@ -236,6 +234,9 @@ cdef extern from "bam.h":
 
   uint32_t bam_calend(bam1_core_t *c, uint32_t *cigar)
 
+cdef extern from *:
+    ctypedef char* const_char_ptr "const char*"
+
 cdef extern from "sam.h":
 
   ctypedef struct samfile_t_un:
@@ -248,7 +249,7 @@ cdef extern from "sam.h":
      samfile_t_un x
      bam_header_t *header
 
-  samfile_t *samopen( char *fn, char * mode, void *aux)
+  samfile_t *samopen( const_char_ptr fn, char * mode, void *aux)
 
   int sampileup( samfile_t *fp, int mask, bam_pileup_f func, void *data)
 
@@ -266,16 +267,6 @@ cdef extern from "glf.h":
    ctypedef struct glf1_t:
       pass
 
-#      unsigned char ref_base, dummy
-#      unsigned char max_mapQ 
-#      unsigned char lk[10]   
-#      unsigned int min_lk, depth
-#      unsigned char ref_base:4, dummy:4
-#      unsigned char max_mapQ 
-#      unsigned char lk[10]   
-#      unsigned min_lk:8, depth:24; 
-
-
 cdef extern from "bam_maqcns.h":
 
   ctypedef struct bam_maqcns_t:
@@ -387,3 +378,34 @@ cdef extern from "pysam_util.h":
     uint32_t pysam_glf_depth( glf1_t * g )
 
     void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
+
+# need to declare all C fields and methods here
+cdef class AlignedRead:
+
+    # object that this AlignedRead represents
+    cdef bam1_t * _delegate
+
+cdef class Samfile:
+    cdef char * _filename
+    # pointer to samfile
+    cdef samfile_t * samfile
+    # pointer to index
+    cdef bam_index_t *index
+    # true if file is a bam file
+    cdef int isbam
+    # true if file is not on the local filesystem
+    cdef int isremote
+    # current read within iteration
+    cdef bam1_t * b
+    # file opening mode
+    cdef char * mode
+
+    cdef bam_header_t * _buildHeader( self, new_header )
+    cdef bam1_t * getCurrent( self )
+    cdef int cnext(self)
+
+    # write an aligned read
+    cpdef int write( self, AlignedRead read )
+
+    cdef char * _getrname( self, int tid )
+
index 105866baea27fe981fc94c0f591e7bab4f751778..471a445bed09a53bb137f9f2023ef56879d5b5fc 100644 (file)
@@ -1,11 +1,22 @@
-        # cython: embedsignature=True
+# cython: embedsignature=True
 # cython: profile=True
 # adds doc-strings for sphinx
-import tempfile, os, sys, types, struct, ctypes, collections, re
-
+import tempfile
+import os
+import sys
+import types
+import itertools
+import struct
+import ctypes
+import collections
+import re
+import platform
 from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
 from cpython cimport PyErr_SetString
 
+#from cpython.string cimport PyString_FromStringAndSize, PyString_AS_STRING
+#from cpython.exc    cimport PyErr_SetString, PyErr_NoMemory
+
 # defines imported from samtools
 DEF SEEK_SET = 0
 DEF SEEK_CUR = 1
@@ -53,7 +64,7 @@ cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
 cdef int max_pos = 2 << 29
 
 # redirect stderr to 0
-_logfile = open("/dev/null", "w")
+_logfile = open(os.path.devnull, "w")
 pysam_set_stderr( PyFile_AsFile( _logfile ) )
 
 #####################################################################
@@ -188,6 +199,17 @@ class StderrStore():
     def __del__(self):
         self.release()
 
+class StderrStoreWindows():
+    '''does nothing. stderr can't be redirected on windows'''
+    def __init__(self): pass
+    def readAndRelease(self): return []
+    def release(self): pass
+
+if platform.system()=='Windows':
+    del StderrStore
+    StderrStore = StderrStoreWindows
+
+
 ######################################################################
 ######################################################################
 ######################################################################
@@ -391,21 +413,26 @@ cdef int mate_callback( bam1_t *alignment, void *f):
 
 
 cdef class Samfile:
-    '''*(filename, mode='r', template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
+    '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
               
     A :term:`SAM`/:term:`BAM` formatted file. The file is automatically opened.
     
-    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode so for binary 
+    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode (:term:`SAM`). For binary 
     (:term:`BAM`) I/O you should append ``b`` for compressed or ``u`` for uncompressed :term:`BAM` output. 
-    Use ``h`` to output header information  in text (:term:`TAM`)  mode.
+    Use ``h`` to output header information in text (:term:`TAM`)  mode.
 
     If ``b`` is present, it must immediately follow ``r`` or ``w``. 
     Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open 
     a :term:`BAM` formatted file for reading, type::
 
-        import pysam
         f = pysam.Samfile('ex1.bam','rb')
 
+    If mode is not specified, we will try to auto-detect in the order 'r', 'rb', thus both the following
+    should work::
+
+        f1 = pysam.Samfile('ex1.bam' )
+        f2 = pysam.Samfile('ex1.bam' )
+
     If an index for a BAM file exists (.bai), it will be opened automatically. Without an index random
     access to reads via :meth:`fetch` and :meth:`pileup` is disabled.
 
@@ -425,20 +452,6 @@ cdef class Samfile:
 
     '''
 
-    cdef char * _filename
-    # pointer to samfile
-    cdef samfile_t * samfile
-    # pointer to index
-    cdef bam_index_t *index
-    # true if file is a bam file
-    cdef int isbam
-    # true if file is not on the local filesystem
-    cdef int isremote
-    # current read within iteration
-    cdef bam1_t * b
-    # file opening mode
-    cdef char * mode
-
     def __cinit__(self, *args, **kwargs ):
         self.samfile = NULL
         self._filename = NULL
@@ -458,7 +471,7 @@ cdef class Samfile:
 
     def _open( self, 
                char * filename, 
-               mode = 'r',
+               mode = None,
                Samfile template = None,
                referencenames = None,
                referencelengths = None,
@@ -472,6 +485,22 @@ cdef class Samfile:
         closed and a new file will be opened.
         '''
 
+        # read mode autodetection
+        if mode is None:
+            try:
+                self._open(filename, 'r', template=template,
+                           referencenames=referencenames,
+                           referencelengths=referencelengths,
+                           text=text, header=header, port=port)
+                return
+            except ValueError, msg:
+                pass
+            self._open(filename, 'rb', template=template,
+                       referencenames=referencenames,
+                       referencelengths=referencelengths,
+                       text=text, header=header, port=port)
+            return
+
         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
         assert filename != NULL
 
@@ -552,13 +581,14 @@ cdef class Samfile:
             # try to detect errors
             self.samfile = samopen( filename, mode, NULL )
             if self.samfile == NULL:
-                raise ValueError( "could not open file - is it SAM/BAM format?")
+                raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
 
             if self.samfile.header == NULL:
-                raise ValueError( "could not open file - is it SAM/BAM format?")
-
+                raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )
+            
+            #disabled for autodetection to work
             if self.samfile.header.n_targets == 0:
-                raise ValueError( "could not open file - is it SAM/BAM format?")
+                raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
 
         if self.samfile == NULL:
             raise IOError("could not open file `%s`" % filename )
@@ -579,22 +609,30 @@ cdef class Samfile:
                 if self.index == NULL:
                     raise IOError("error while opening index `%s` " % filename )
                                     
+    def gettid( self, reference ):
+        '''
+        convert :term:`reference` name into numerical :term:`tid`
+
+        returns -1 if reference is not known.
+        '''
+        if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+        return pysam_reference2tid( self.samfile.header, reference )
+
     def getrname( self, tid ):
         '''
         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 out of range 0<=tid<%i" % 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]
 
-    def gettid( self, reference ):
-        '''
-        convert :term:`reference` name into numerical :term:`tid`
-
-        returns -1 if reference is not known.
+    cdef char * _getrname( self, int tid ):
         '''
+        convert numerical :term:`tid` into :term:`reference` name.'''
         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
-        return pysam_reference2tid( self.samfile.header, reference )
+        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]
 
     def _parseRegion( self, 
                       reference = None, 
@@ -616,14 +654,23 @@ cdef class Samfile:
         # implementing it all in pysam (makes use of khash).
         
         cdef int rtid
-        cdef int rstart
-        cdef int rend
+        cdef long long rstart
+        cdef long long rend
 
         rtid = -1
         rstart = 0
         rend = max_pos
-        if start != None: rstart = start
-        if end != None: rend = end
+        if start != None: 
+            try:
+                rstart = start
+            except OverflowError:
+                raise ValueError( 'start out of range (%i)' % start )
+            
+        if end != None: 
+            try:
+                rend = end
+            except OverflowError:
+                raise ValueError( 'end out of range (%i)' % end )
 
         if region:
             parts = re.split( "[:-]", region )
@@ -745,10 +792,12 @@ cdef class Samfile:
             not re-opened the file.
 
         '''
-        if not read.is_paired:
-            raise ValueError( "read is unpaired" )
-        if read.mate_is_unmapped:
-            raise ValueError( "mate is unmapped" )
+        cdef uint32_t flag = read._delegate.core.flag
+
+        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))
         
         cdef MateData mate_data
 
@@ -756,7 +805,7 @@ cdef class Samfile:
         mate_data.mate = NULL
         # xor flags to get the other mate
         cdef int x = BAM_FREAD1 + BAM_FREAD2
-        mate_data.flag = ( read._delegate.core.flag ^ x) & x
+        mate_data.flag = ( flag ^ x) & x
 
         bam_fetch(self.samfile.x.bam, 
                   self.index, 
@@ -817,7 +866,6 @@ cdef class Samfile:
         else:   
             raise ValueError ("count for a region is not available for sam files" )
 
-
     def pileup( self, 
                 reference = None, 
                 start = None, 
@@ -863,6 +911,9 @@ cdef class Samfile:
             *all* reads which overlap the region are returned. The first base returned will be the 
             first base of the first read *not* necessarily the first base of the region used in the query.
 
+            The maximum number of reads considered for pileup is *8000*. This limit is set by
+            :term:`csamtools`.
+
         '''
         cdef int rtid, rstart, rend, has_coord
         cdef bam_plbuf_t *buf
@@ -915,14 +966,14 @@ cdef class Samfile:
         bam_destroy1(self.b)
         if self._filename != NULL: free( self._filename )
 
-    def write( self, AlignedRead read ):
+    cpdef int write( self, AlignedRead read ) except -1:
         '''
         write a single :class:`pysam.AlignedRead` to disk.
 
         returns the number of bytes written.
         '''
         if not self._isOpen():
-            raise ValueError( "I/O operation on closed file" )
+            return 0
 
         return samwrite( self.samfile, read._delegate )
 
@@ -1005,9 +1056,14 @@ cdef class Samfile:
                     x = {}
                     for field in fields[1:]:
                         key, value = field.split(":",1)
-                        if key not in VALID_HEADER_FIELDS[record]:
+                        # 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():
+                            x[key] = value
+                        else:
                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
-                        x[key] = VALID_HEADER_FIELDS[record][key](value)
 
                     if VALID_HEADER_TYPES[record] == dict:
                         if record in result:
@@ -1027,9 +1083,15 @@ cdef class Samfile:
         if record == "CO":
             line.append( fields )
         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])))
+            # write user fields
+            for key in fields:
+                if not key.isupper():
+                    line.append( "%s:%s" % (key, str(fields[key])))
+
         return "\t".join( line ) 
 
     cdef bam_header_t * _buildHeader( self, new_header ):
@@ -1146,8 +1208,8 @@ cdef class IteratorRowRegion(IteratorRow):
 
     iterate over mapped reads in a region.
 
-    By default, the file is re-openend to avoid conflicts if
-    multiple operators work on the same file. Set *reopen* = False
+    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*.
 
     The samtools iterators assume that the file
@@ -1166,6 +1228,8 @@ cdef class IteratorRowRegion(IteratorRow):
     cdef int                    retval
     cdef Samfile                samfile
     cdef samfile_t              * fp
+    # true if samfile belongs to this object
+    cdef int owns_samfile
 
     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):
 
@@ -1189,6 +1253,10 @@ cdef class IteratorRowRegion(IteratorRow):
             self.fp = samopen( samfile._filename, mode, NULL )
             store.release()
             assert self.fp != NULL
+            self.owns_samfile = True
+        else:
+            self.fp = self.samfile.samfile
+            self.owns_samfile = False
 
         self.retval = 0
 
@@ -1219,20 +1287,22 @@ cdef class IteratorRowRegion(IteratorRow):
 
     def __dealloc__(self):
         bam_destroy1(self.b)
-        samclose( self.fp )
+        if self.owns_samfile: samclose( self.fp )
 
 cdef class IteratorRowAll(IteratorRow):
     """*(Samfile samfile, int reopen = True)*
 
     iterate over all reads in *samfile*
 
-    By default, the file is re-openend to avoid conflicts if
-    multiple operators work on the same file. Set *reopen* = False
+    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*.
     """
 
     cdef bam1_t * b
     cdef samfile_t * fp
+    # true if samfile belongs to this object
+    cdef int owns_samfile
 
     def __cinit__(self, Samfile samfile, int reopen = True ):
 
@@ -1248,6 +1318,10 @@ cdef class IteratorRowAll(IteratorRow):
             self.fp = samopen( samfile._filename, mode, NULL )
             store.release()
             assert self.fp != NULL
+            self.owns_samfile = True
+        else:
+            self.fp = samfile.samfile
+            self.owns_samfile = False
 
         # allocate memory for alignment
         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
@@ -1277,8 +1351,7 @@ cdef class IteratorRowAll(IteratorRow):
 
     def __dealloc__(self):
         bam_destroy1(self.b)
-        samclose( self.fp )
-
+        if self.owns_samfile: samclose( self.fp )
 
 cdef class IteratorRowAllRefs(IteratorRow):
     """iterates over all mapped reads by chaining iterators over each reference
@@ -1326,6 +1399,79 @@ cdef class IteratorRowAllRefs(IteratorRow):
             else:
                 raise StopIteration
 
+cdef class IteratorRowSelection(IteratorRow):
+    """*(Samfile samfile)*
+
+    iterate over reads in *samfile* at a given list of file positions.
+    """
+
+    cdef bam1_t * b
+    cdef int current_pos 
+    cdef samfile_t * fp
+    cdef positions
+    # true if samfile belongs to this object
+    cdef int owns_samfile
+
+    def __cinit__(self, Samfile samfile, positions, int reopen = True ):
+
+        if not samfile._isOpen():
+            raise ValueError( "I/O operation on closed file" )
+
+        if not samfile._isOpen():
+            raise ValueError( "I/O operation on closed file" )
+
+        assert samfile.isbam, "can only use this iterator on bam files"
+        mode = "rb"
+
+        # reopen the file to avoid iterator conflict
+        if reopen:
+            store = StderrStore()
+            self.fp = samopen( samfile._filename, mode, NULL )
+            store.release()
+            assert self.fp != NULL
+            self.owns_samfile = True
+        else:
+            self.fp = samfile.samfile
+            self.owns_samfile = False
+
+        # allocate memory for alignment
+        self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
+
+        self.positions = positions
+        self.current_pos = 0
+
+    def __iter__(self):
+        return self 
+
+    cdef bam1_t * getCurrent( self ):
+        return self.b
+
+    cdef int cnext(self):
+        '''cversion of iterator'''
+
+        # end iteration if out of positions
+        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)
+
+    def __next__(self): 
+        """python version of next().
+
+        pyrex uses this non-standard name instead of next()
+        """
+
+        cdef int ret = self.cnext()
+        if (ret > 0):
+            return makeAlignedRead( self.b )
+        else:
+            raise StopIteration
+
+    def __dealloc__(self):
+        bam_destroy1(self.b)
+        if self.owns_samfile: samclose( self.fp )
+
 ##-------------------------------------------------------------------
 ##-------------------------------------------------------------------
 ##-------------------------------------------------------------------
@@ -1361,12 +1507,11 @@ cdef int __advance_snpcalls( void * data, bam1_t * b ):
     # reload sequence
     if d.fastafile != NULL and b.core.tid != d.tid:
         if d.seq != NULL: free(d.seq)
-        d.tid = b.core.tid;
+        d.tid = b.core.tid
         d.seq = faidx_fetch_seq(d.fastafile, 
                                 d.samfile.header.target_name[d.tid],
                                 0, max_pos, 
                                 &d.seq_len)
-
         if d.seq == NULL:
             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
                                   (d.samfile.header.target_name[d.tid], 
@@ -1721,7 +1866,8 @@ cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end):
 
 cdef class AlignedRead:
     '''
-    Class representing an aligned read. see SAM format specification for meaning of fields (http://samtools.sourceforge.net/).
+    Class representing an aligned read. see SAM format specification for 
+    the meaning of fields (http://samtools.sourceforge.net/).
 
     This class stores a handle to the samtools C-structure representing
     an aligned read. Member read access is forwarded to the C-structure
@@ -1739,8 +1885,6 @@ cdef class AlignedRead:
     be set *before* the quality scores. Setting the sequence will
     also erase any quality scores that were set previously.
     '''
-    cdef:
-         bam1_t * _delegate 
 
     # Now only called when instances are created from Python
     def __init__(self):
@@ -1757,17 +1901,29 @@ cdef class AlignedRead:
         bam_destroy1(self._delegate)
     
     def __str__(self):
-        """todo"""
+        """return string representation of alignment.
+
+        The representation is an approximate :term:`sam` format.
+
+        An aligned read might not be associated with a :term:`Samfile`.
+        As a result :term:`tid` is shown instead of the reference name.
+
+        Similarly, the tags field is returned in its parsed state.
+        """
+        # sam-parsing is done in sam.c/bam_format1_core which
+        # requires a valid header.
         return "\t".join(map(str, (self.qname,
+                                   self.flag,
                                    self.rname,
                                    self.pos,
+                                   self.mapq,
                                    self.cigar,
-                                   self.qual,
-                                   self.flag,
+                                   self.mrnm,
+                                   self.mpos,
+                                   self.rlen,
                                    self.seq,
-                                   self.mapq,
-                                   self.tags)))
-    
+                                   self.qual,
+                                   self.tags )))
        
     def compare(self, AlignedRead other):
         '''return -1,0,1, if contents in this are binary <,=,> to *other*'''
@@ -2322,12 +2478,66 @@ cdef class AlignedRead:
             if val: self._delegate.core.flag |= BAM_FQCFAIL
             else: self._delegate.core.flag &= ~BAM_FQCFAIL
     property is_duplicate:
-        """ true if optical or PCR duplicate"""
+        """true if optical or PCR duplicate"""
         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:
+        """a list of reference positions that this read aligns to."""
+        def __get__(self):
+            cdef uint32_t k, i, pos
+            cdef int op
+            cdef uint32_t * cigar_p
+            cdef bam1_t * src 
+
+            result = []
+            src = self._delegate
+            if src.core.n_cigar == 0: return []
+
+            pos = src.core.pos
+
+            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
+                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:
+                    pos += l
+
+            return result
+    def overlap( self, uint32_t start, uint32_t end ):
+        """return number of bases on reference overlapping *start* and *end*
+        """
+        cdef uint32_t k, i, pos, overlap
+        cdef int op, o
+        cdef uint32_t * cigar_p
+        cdef bam1_t * src 
+
+        overlap = 0
+
+        src = self._delegate
+        if src.core.n_cigar == 0: return 0
+        pos = src.core.pos
+        o = 0
+
+        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
+
+            if op == BAM_CMATCH:
+                o = min( pos + l, end) - max( pos, start )
+                if o > 0: overlap += o
+
+            if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
+                pos += l
+
+        return overlap
+
     def opt(self, tag):
         """retrieves optional data given a two-letter *tag*"""
         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc 
@@ -2506,6 +2716,7 @@ class Outs:
         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.
         os.close(fd)                #  Close other unit (look out, caller.)
             
@@ -3154,6 +3365,74 @@ cdef class IteratorIndelCalls( IndelCallerBase ):
 
         return self._call()
 
+
+
+cdef class IndexedReads:
+    """index a bamfile by read.
+
+    The index is kept in memory.
+
+    By default, the file is re-openend to avoid conflicts if
+    multiple operators work on the same file. Set *reopen* = False
+    to not re-open *samfile*.
+    """
+
+    cdef Samfile samfile
+    cdef samfile_t * fp
+    cdef index
+    # true if samfile belongs to this object
+    cdef int owns_samfile
+
+    def __init__(self, Samfile samfile, int reopen = True ):
+        self.samfile = samfile
+
+        if samfile.isbam: mode = "rb"
+        else: mode = "r"
+
+        # reopen the file - note that this makes the iterator
+        # slow and causes pileup to slow down significantly.
+        if reopen:
+            store = StderrStore()            
+            self.fp = samopen( samfile._filename, mode, NULL )
+            store.release()
+            assert self.fp != NULL
+            self.owns_samfile = True
+        else:
+            self.fp = samfile.samfile
+            self.owns_samfile = False
+
+        assert samfile.isbam, "can only IndexReads on bam files"
+
+    def build( self ):
+        '''build index.'''
+        
+        self.index = collections.defaultdict( list )
+
+        # this method will start indexing from the current file position
+        # if you decide
+        cdef int ret = 1
+        cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )
+        
+        cdef uint64_t pos
+
+        while ret > 0:
+            pos = bam_tell( self.fp.x.bam ) 
+            ret = samread( self.fp, b)
+            if ret > 0:
+                qname = bam1_qname( b )
+                self.index[qname].append( pos )                
+            
+        bam_destroy1( b )
+
+    def find( self, qname ):
+        if qname in self.index:
+            return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+        else:
+            raise KeyError( "read %s not found" % qname )
+
+    def __dealloc__(self):
+        if self.owns_samfile: samclose( self.fp )
+
 __all__ = ["Samfile", 
            "Fastafile",
            "IteratorRow", 
@@ -3165,7 +3444,8 @@ __all__ = ["Samfile",
            "IteratorSNPCalls",
            "SNPCaller",
            "IndelCaller",
-           "IteratorIndelCalls", ]
+           "IteratorIndelCalls", 
+           "IndexedReads" ]
 
                
 
index e0866c866a2c9c03d949345f571f93c88b055229..11a2c6f1310af4bc4bbd785d3fb8a17885e4c339 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.13 on Fri Feb 11 09:01:45 2011 */
+/* Generated by Cython 0.13 on Thu May  5 14:57:46 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdint.h"
 #include "bgzf.h"
 #include "tabix.h"
+#include "pythread.h"
 
 /* inline attribute */
 #ifndef CYTHON_INLINE
@@ -281,41 +282,121 @@ static const char *__pyx_filename;
 
 static const char *__pyx_f[] = {
   "ctabix.pyx",
+  "bool.pxd",
+  "TabProxies.pxd",
 };
 
 /* Type declarations */
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":215
- *         return str(v)
+/* "pysam/ctabix.pxd":178
+ *     cdef tabix_t * tabixfile
+ * 
+ * cdef class Parser:             # <<<<<<<<<<<<<<
+ *      pass
+ */
+
+struct __pyx_obj_6ctabix_Parser {
+  PyObject_HEAD
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":293
+ *         return r
+ * 
+ * cdef class asVCF( Parser ):             # <<<<<<<<<<<<<<
+ *     '''converts a :term:`tabix row` into a VCF record.'''
+ *     def __call__(self, char * buffer, int len ):
+ */
+
+struct __pyx_obj_6ctabix_asVCF {
+  struct __pyx_obj_6ctabix_Parser __pyx_base;
+};
+
+/* "pysam/TabProxies.pxd":42
+ *   ctypedef int uint64_t
  * 
  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to parsed row as a tuple.
  * 
+ *     cdef:
  */
 
-struct __pyx_obj_6ctabix_TupleProxy {
+struct __pyx_obj_10TabProxies_TupleProxy {
   PyObject_HEAD
-  struct __pyx_vtabstruct_6ctabix_TupleProxy *__pyx_vtab;
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtab;
   char *data;
   char **fields;
   int nfields;
   int index;
+  int nbytes;
+  int offset;
+  int is_modified;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":668
- *         self.fromDict( r )
+/* "pysam/TabProxies.pxd":77
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class Parser:             # <<<<<<<<<<<<<<
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
  *     pass
  * 
  */
 
-struct __pyx_obj_6ctabix_Parser {
-  PyObject_HEAD
+struct __pyx_obj_10TabProxies_NamedTupleProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+};
+
+/* "pysam/TabProxies.pxd":80
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_BedProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t start;
+  uint32_t end;
+  int bedfields;
+};
+
+/* "pysam/TabProxies.pxd":91
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_VCFProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t pos;
+};
+
+/* "pysam/TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_GTFProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+  char *contig;
+  char *source;
+  char *feature;
+  uint32_t start;
+  uint32_t end;
+  char *score;
+  char *strand;
+  char *frame;
+  char *attributes;
+  int hasOwnAttributes;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":156
- *            return result
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":161
+ *             return result
  * 
  * cdef class TabixIterator:             # <<<<<<<<<<<<<<
  *     """iterates over rows in *tabixfile* in region
@@ -328,12 +409,12 @@ struct __pyx_obj_6ctabix_TabixIterator {
   tabix_t *tabixfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":689
- *         return r
- * 
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":304
+ * #########################################################
+ * #########################################################
  * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
  *     """iterates over mapped reads in a region.
- *     """
+ * 
  */
 
 struct __pyx_obj_6ctabix_TabixIteratorParsed {
@@ -343,47 +424,35 @@ struct __pyx_obj_6ctabix_TabixIteratorParsed {
   struct __pyx_obj_6ctabix_Parser *parser;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":6
- * import tempfile, os, sys, types, itertools, struct, ctypes
- * 
- * cdef class Tabixfile:             # <<<<<<<<<<<<<<
- *     '''*(filename, mode='r')*
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":216
+ *             ti_iter_destroy(self.iterator)
  * 
+ * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
+ *     """return header lines.
+ *     """
  */
 
-struct __pyx_obj_6ctabix_Tabixfile {
+struct __pyx_obj_6ctabix_TabixHeaderIterator {
   PyObject_HEAD
-  char *filename;
+  ti_iter_t iterator;
   tabix_t *tabixfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":326
- *         return self.fields[self.index-1]
+/* "pysam/ctabix.pxd":172
+ *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
  * 
- * cdef class GTFProxy:             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to GTF fields.
+ * cdef class Tabixfile:             # <<<<<<<<<<<<<<
+ *     cdef char * filename
  * 
  */
 
-struct __pyx_obj_6ctabix_GTFProxy {
+struct __pyx_obj_6ctabix_Tabixfile {
   PyObject_HEAD
-  struct __pyx_vtabstruct_6ctabix_GTFProxy *__pyx_vtab;
-  char *contig;
-  char *source;
-  char *feature;
-  uint32_t start;
-  uint32_t end;
-  char *score;
-  char *strand;
-  char *frame;
-  char *attributes;
-  int nbytes;
-  char *data;
-  int isModified;
-  int hasOwnAttributes;
+  char *filename;
+  tabix_t *tabixfile;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":681
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":277
  *         return r
  * 
  * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
@@ -395,7 +464,19 @@ struct __pyx_obj_6ctabix_asGTF {
   struct __pyx_obj_6ctabix_Parser __pyx_base;
 };
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":671
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":285
+ *         return r
+ * 
+ * cdef class asBed( Parser ):             # <<<<<<<<<<<<<<
+ *     '''converts a :term:`tabix row` into a GTF record.'''
+ *     def __call__(self, char * buffer, int len):
+ */
+
+struct __pyx_obj_6ctabix_asBed {
+  struct __pyx_obj_6ctabix_Parser __pyx_base;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":267
  *     pass
  * 
  * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
@@ -408,38 +489,78 @@ struct __pyx_obj_6ctabix_asTuple {
 };
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":215
- *         return str(v)
+/* "pysam/TabProxies.pxd":42
+ *   ctypedef int uint64_t
  * 
  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to parsed row as a tuple.
  * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_TupleProxy {
+  int (*getMaxFields)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t);
+  PyObject *(*take)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*present)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*copy)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*update)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+};
+static struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtabptr_10TabProxies_TupleProxy;
+
+
+/* "pysam/TabProxies.pxd":77
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+
+
+/* "pysam/TabProxies.pxd":91
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_VCFProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_VCFProxy *__pyx_vtabptr_10TabProxies_VCFProxy;
+
+
+/* "pysam/TabProxies.pxd":80
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
  */
 
-struct __pyx_vtabstruct_6ctabix_TupleProxy {
-  PyObject *(*take)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t);
-  PyObject *(*present)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t);
-  PyObject *(*copy)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t);
-  PyObject *(*update)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t);
+struct __pyx_vtabstruct_10TabProxies_BedProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_6ctabix_TupleProxy *__pyx_vtabptr_6ctabix_TupleProxy;
+static struct __pyx_vtabstruct_10TabProxies_BedProxy *__pyx_vtabptr_10TabProxies_BedProxy;
 
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":326
- *         return self.fields[self.index-1]
+/* "pysam/TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class GTFProxy:             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to GTF fields.
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
  * 
+ *     cdef:
  */
 
-struct __pyx_vtabstruct_6ctabix_GTFProxy {
-  PyObject *(*take)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t);
-  PyObject *(*present)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t);
-  PyObject *(*copy)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t);
-  PyObject *(*update)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t);
+struct __pyx_vtabstruct_10TabProxies_GTFProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_6ctabix_GTFProxy *__pyx_vtabptr_6ctabix_GTFProxy;
+static struct __pyx_vtabstruct_10TabProxies_GTFProxy *__pyx_vtabptr_10TabProxies_GTFProxy;
 
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
@@ -584,17 +705,6 @@ static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
     const char *name, int exact); /*proto*/
 
-static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
-static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
-    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
-}
-
-static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
-
-#define __Pyx_PyObject_AsDouble(obj) \
-    ((likely(PyFloat_CheckExact(obj))) ? \
-     PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
-
 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
 
 
@@ -630,10 +740,6 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb
 
 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
-static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);
-
-static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *);
-
 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
 
 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
@@ -668,20 +774,105 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
 
 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
-static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
 
 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+/* Module declarations from cpython.version */
+
+/* Module declarations from cpython.ref */
+
+/* Module declarations from cpython.exc */
+
+/* Module declarations from cpython.module */
+
+/* Module declarations from cpython.mem */
+
+/* Module declarations from cpython.tuple */
+
+/* Module declarations from cpython.list */
+
+/* Module declarations from libc.stdio */
+
+/* Module declarations from cpython.object */
+
+/* Module declarations from cpython.sequence */
+
+/* Module declarations from cpython.mapping */
+
+/* Module declarations from cpython.iterator */
+
+/* Module declarations from cpython.type */
+
+/* Module declarations from cpython.number */
+
+/* Module declarations from cpython.int */
+
+/* Module declarations from __builtin__ */
+
+/* Module declarations from cpython.bool */
+
+static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
+/* Module declarations from cpython.long */
+
+/* Module declarations from cpython.float */
+
+/* Module declarations from cpython.complex */
+
+/* Module declarations from cpython.string */
+
+/* Module declarations from cpython.unicode */
+
+/* Module declarations from cpython.dict */
+
+/* Module declarations from cpython.instance */
+
+/* Module declarations from cpython.function */
+
+/* Module declarations from cpython.method */
+
+/* Module declarations from cpython.weakref */
+
+/* Module declarations from cpython.getargs */
+
+/* Module declarations from cpython.pythread */
+
+/* Module declarations from cpython.cobject */
+
+/* Module declarations from cpython.oldbuffer */
+
+/* Module declarations from cpython.set */
+
+/* Module declarations from cpython.buffer */
+
+/* Module declarations from cpython.bytes */
+
+/* Module declarations from cpython.pycapsule */
+
+/* Module declarations from cpython */
+
+/* Module declarations from TabProxies */
+
+static PyTypeObject *__pyx_ptype_10TabProxies_TupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_GTFProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_NamedTupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_BedProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_VCFProxy = 0;
 /* Module declarations from ctabix */
 
 static PyTypeObject *__pyx_ptype_6ctabix_Tabixfile = 0;
-static PyTypeObject *__pyx_ptype_6ctabix_TabixIterator = 0;
-static PyTypeObject *__pyx_ptype_6ctabix_TupleProxy = 0;
-static PyTypeObject *__pyx_ptype_6ctabix_GTFProxy = 0;
 static PyTypeObject *__pyx_ptype_6ctabix_Parser = 0;
+static PyTypeObject *__pyx_ptype_6ctabix_TabixIterator = 0;
+static PyTypeObject *__pyx_ptype_6ctabix_TabixHeaderIterator = 0;
 static PyTypeObject *__pyx_ptype_6ctabix_asTuple = 0;
 static PyTypeObject *__pyx_ptype_6ctabix_asGTF = 0;
+static PyTypeObject *__pyx_ptype_6ctabix_asBed = 0;
+static PyTypeObject *__pyx_ptype_6ctabix_asVCF = 0;
 static PyTypeObject *__pyx_ptype_6ctabix_TabixIteratorParsed = 0;
 #define __Pyx_MODULE_NAME "ctabix"
 int __pyx_module_is_main_ctabix = 0;
@@ -690,9 +881,6 @@ int __pyx_module_is_main_ctabix = 0;
 static PyObject *__pyx_builtin_IOError;
 static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_StopIteration;
-static PyObject *__pyx_builtin_IndexError;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_AttributeError;
 static PyObject *__pyx_builtin_OSError;
 static PyObject *__pyx_builtin_ord;
 static PyObject *__pyx_builtin_KeyError;
@@ -708,58 +896,28 @@ static char __pyx_k_9[] = "start out of range (%i)";
 static char __pyx_k_10[] = "end out of range (%i)";
 static char __pyx_k_11[] = "I/O operation on closed file";
 static char __pyx_k_12[] = "malformatted query or wrong sequence name.\n";
-static char __pyx_k_13[] = ".";
-static char __pyx_k_14[] = "\"%s\"";
-static char __pyx_k_15[] = "incomplete line at %s";
-static char __pyx_k_16[] = "row too large - more than %i fields";
-static char __pyx_k_17[] = "list index out of range";
-static char __pyx_k_18[] = "malformatted entry at %s";
-static char __pyx_k_19[] = ";";
-static char __pyx_k_20[] = " ";
-static char __pyx_k_21[] = "\"";
-static char __pyx_k_22[] = "%s \"%s\"";
-static char __pyx_k_23[] = "%s %s";
-static char __pyx_k_24[] = "; ";
-static char __pyx_k_25[] = "\t";
-static char __pyx_k_26[] = "";
-static char __pyx_k_27[] = "'GTFProxy' has no attribute '%s'";
-static char __pyx_k_29[] = "Filename '%s' already exists, use *force* to overwrite";
-static char __pyx_k_30[] = "could not open '%s' for writing";
-static char __pyx_k_31[] = "could not open '%s' for reading";
-static char __pyx_k_32[] = "writing failed";
-static char __pyx_k_34[] = "#";
-static char __pyx_k_36[] = "No such file '%s'";
-static char __pyx_k_37[] = ".gz";
-static char __pyx_k_38[] = "Filename '%s.tbi' already exists, use *force* to overwrite";
-static char __pyx_k_39[] = "unknown preset '%s', valid presets are '%s'";
-static char __pyx_k_40[] = ",";
-static char __pyx_k_41[] = "chromosome names";
-static char __pyx_k_42[] = "contig of feature.";
-static char __pyx_k_43[] = "feature name.";
-static char __pyx_k_44[] = "feature source.";
-static char __pyx_k_45[] = "feature start (in 0-based open/closed coordinates).";
-static char __pyx_k_46[] = "feature end (in 0-based open/closed coordinates).";
-static char __pyx_k_47[] = "feature score.";
-static char __pyx_k_48[] = "feature strand.";
-static char __pyx_k_49[] = "feature frame.";
-static char __pyx_k_50[] = "feature attributes (as a string).";
-static char __pyx_k_51[] = "Tabixfile._isOpen (line 22)";
-static char __pyx_k_52[] = "Tabixfile._open (line 26)";
-static char __pyx_k_53[] = "Tabixfile._parseRegion (line 60)";
-static char __pyx_k_54[] = "Tabixfile.fetch (line 105)";
-static char __pyx_k_55[] = "TabixIterator.__next__ (line 187)";
-static char __pyx_k_56[] = "toDot (line 203)";
-static char __pyx_k_57[] = "quote (line 208)";
-static char __pyx_k_58[] = "TupleProxy.__next__ (line 318)";
-static char __pyx_k_59[] = "GTFProxy.asDict (line 521)";
-static char __pyx_k_60[] = "GTFProxy.fromDict (line 556)";
-static char __pyx_k_61[] = "GTFProxy.invert (line 605)";
-static char __pyx_k_62[] = "GTFProxy.keys (line 616)";
-static char __pyx_k_63[] = "GTFProxy.__getattr__ (line 630)";
-static char __pyx_k_64[] = "GTFProxy.setAttribute (line 662)";
-static char __pyx_k_65[] = "TabixIteratorParsed.__next__ (line 725)";
-static char __pyx_k_66[] = "tabix_compress (line 741)";
-static char __pyx_k_67[] = "tabix_index (line 786)";
+static char __pyx_k_13[] = "can't open header.\n";
+static char __pyx_k_15[] = "Filename '%s' already exists, use *force* to overwrite";
+static char __pyx_k_16[] = "could not open '%s' for writing";
+static char __pyx_k_17[] = "could not open '%s' for reading";
+static char __pyx_k_18[] = "writing failed";
+static char __pyx_k_20[] = "#";
+static char __pyx_k_22[] = "No such file '%s'";
+static char __pyx_k_23[] = ".gz";
+static char __pyx_k_24[] = "Filename '%s.tbi' already exists, use *force* to overwrite";
+static char __pyx_k_25[] = "unknown preset '%s', valid presets are '%s'";
+static char __pyx_k_26[] = ",";
+static char __pyx_k_27[] = "chromosome names";
+static char __pyx_k_28[] = "Tabixfile._isOpen (line 19)";
+static char __pyx_k_29[] = "Tabixfile._open (line 23)";
+static char __pyx_k_30[] = "Tabixfile._parseRegion (line 57)";
+static char __pyx_k_31[] = "Tabixfile.fetch (line 102)";
+static char __pyx_k_32[] = "Tabixfile.header.__get__ (line 140)";
+static char __pyx_k_33[] = "TabixIterator.__next__ (line 192)";
+static char __pyx_k_34[] = "TabixHeaderIterator.__next__ (line 239)";
+static char __pyx_k_35[] = "TabixIteratorParsed.__next__ (line 342)";
+static char __pyx_k_36[] = "tabix_compress (line 362)";
+static char __pyx_k_37[] = "tabix_index (line 407)";
 static char __pyx_k__r[] = "r";
 static char __pyx_k__w[] = "w";
 static char __pyx_k__bc[] = "bc";
@@ -778,56 +936,39 @@ static char __pyx_k__sys[] = "sys";
 static char __pyx_k__tid[] = "tid";
 static char __pyx_k__vcf[] = "vcf";
 static char __pyx_k__copy[] = "copy";
-static char __pyx_k__data[] = "data";
+static char __pyx_k__gzip[] = "gzip";
 static char __pyx_k__join[] = "join";
 static char __pyx_k__keys[] = "keys";
 static char __pyx_k__mode[] = "mode";
-static char __pyx_k__name[] = "name";
 static char __pyx_k__path[] = "path";
 static char __pyx_k___open[] = "_open";
+static char __pyx_k__asBed[] = "asBed";
 static char __pyx_k__asGTF[] = "asGTF";
+static char __pyx_k__asVCF[] = "asVCF";
 static char __pyx_k__close[] = "close";
 static char __pyx_k__fetch[] = "fetch";
 static char __pyx_k__force[] = "force";
-static char __pyx_k__frame[] = "frame";
-static char __pyx_k__index[] = "index";
-static char __pyx_k__items[] = "items";
-static char __pyx_k__quote[] = "quote";
-static char __pyx_k__score[] = "score";
-static char __pyx_k__split[] = "split";
 static char __pyx_k__start[] = "start";
-static char __pyx_k__strip[] = "strip";
-static char __pyx_k__toDot[] = "toDot";
 static char __pyx_k__types[] = "types";
-static char __pyx_k__value[] = "value";
-static char __pyx_k__asDict[] = "asDict";
 static char __pyx_k__buffer[] = "buffer";
-static char __pyx_k__contig[] = "contig";
 static char __pyx_k__ctypes[] = "ctypes";
 static char __pyx_k__exists[] = "exists";
-static char __pyx_k__fields[] = "fields";
-static char __pyx_k__invert[] = "invert";
-static char __pyx_k__nbytes[] = "nbytes";
+static char __pyx_k__header[] = "header";
 static char __pyx_k__parser[] = "parser";
 static char __pyx_k__pileup[] = "pileup";
 static char __pyx_k__preset[] = "preset";
 static char __pyx_k__psltbl[] = "psltbl";
 static char __pyx_k__region[] = "region";
-static char __pyx_k__source[] = "source";
-static char __pyx_k__strand[] = "strand";
 static char __pyx_k__struct[] = "struct";
 static char __pyx_k__unlink[] = "unlink";
-static char __pyx_k__update[] = "update";
 static char __pyx_k__IOError[] = "IOError";
 static char __pyx_k__OSError[] = "OSError";
 static char __pyx_k____all__[] = "__all__";
+static char __pyx_k____get__[] = "__get__";
 static char __pyx_k___isOpen[] = "_isOpen";
 static char __pyx_k__asTuple[] = "asTuple";
 static char __pyx_k__end_col[] = "end_col";
-static char __pyx_k__feature[] = "feature";
-static char __pyx_k__nfields[] = "nfields";
 static char __pyx_k__seq_col[] = "seq_col";
-static char __pyx_k__GTFProxy[] = "GTFProxy";
 static char __pyx_k__KeyError[] = "KeyError";
 static char __pyx_k__O_RDONLY[] = "O_RDONLY";
 static char __pyx_k____main__[] = "__main__";
@@ -835,11 +976,9 @@ static char __pyx_k____next__[] = "__next__";
 static char __pyx_k____test__[] = "__test__";
 static char __pyx_k__endswith[] = "endswith";
 static char __pyx_k__filename[] = "filename";
-static char __pyx_k__fromDict[] = "fromDict";
 static char __pyx_k__iterator[] = "iterator";
 static char __pyx_k__tempfile[] = "tempfile";
 static char __pyx_k__Tabixfile[] = "Tabixfile";
-static char __pyx_k__TypeError[] = "TypeError";
 static char __pyx_k__itertools[] = "itertools";
 static char __pyx_k__line_skip[] = "line_skip";
 static char __pyx_k__meta_char[] = "meta_char";
@@ -847,137 +986,92 @@ static char __pyx_k__reference[] = "reference";
 static char __pyx_k__start_col[] = "start_col";
 static char __pyx_k__tabixfile[] = "tabixfile";
 static char __pyx_k__zerobased[] = "zerobased";
-static char __pyx_k__IndexError[] = "IndexError";
-static char __pyx_k__StringType[] = "StringType";
-static char __pyx_k__TupleProxy[] = "TupleProxy";
 static char __pyx_k__ValueError[] = "ValueError";
-static char __pyx_k__attributes[] = "attributes";
-static char __pyx_k__isModified[] = "isModified";
-static char __pyx_k__StringTypes[] = "StringTypes";
-static char __pyx_k____getattr__[] = "__getattr__";
 static char __pyx_k__filename_in[] = "filename_in";
 static char __pyx_k__tabix_index[] = "tabix_index";
 static char __pyx_k___parseRegion[] = "_parseRegion";
 static char __pyx_k__filename_out[] = "filename_out";
-static char __pyx_k__setAttribute[] = "setAttribute";
 static char __pyx_k__StopIteration[] = "StopIteration";
 static char __pyx_k__TabixIterator[] = "TabixIterator";
-static char __pyx_k__AttributeError[] = "AttributeError";
 static char __pyx_k__tabix_compress[] = "tabix_compress";
-static char __pyx_k__hasOwnAttributes[] = "hasOwnAttributes";
+static char __pyx_k__TabixHeaderIterator[] = "TabixHeaderIterator";
 static char __pyx_k__TabixIteratorParsed[] = "TabixIteratorParsed";
 static PyObject *__pyx_kp_s_1;
 static PyObject *__pyx_kp_s_10;
 static PyObject *__pyx_kp_s_11;
 static PyObject *__pyx_kp_s_12;
 static PyObject *__pyx_kp_s_13;
-static PyObject *__pyx_kp_s_14;
 static PyObject *__pyx_kp_s_15;
 static PyObject *__pyx_kp_s_16;
 static PyObject *__pyx_kp_s_17;
 static PyObject *__pyx_kp_s_18;
-static PyObject *__pyx_kp_s_19;
 static PyObject *__pyx_kp_s_2;
 static PyObject *__pyx_kp_s_20;
-static PyObject *__pyx_kp_s_21;
 static PyObject *__pyx_kp_s_22;
 static PyObject *__pyx_kp_s_23;
 static PyObject *__pyx_kp_s_24;
 static PyObject *__pyx_kp_s_25;
 static PyObject *__pyx_kp_s_26;
-static PyObject *__pyx_kp_s_27;
-static PyObject *__pyx_kp_s_29;
+static PyObject *__pyx_kp_u_28;
+static PyObject *__pyx_kp_u_29;
 static PyObject *__pyx_kp_s_3;
-static PyObject *__pyx_kp_s_30;
-static PyObject *__pyx_kp_s_31;
-static PyObject *__pyx_kp_s_32;
-static PyObject *__pyx_kp_s_34;
-static PyObject *__pyx_kp_s_36;
-static PyObject *__pyx_kp_s_37;
-static PyObject *__pyx_kp_s_38;
-static PyObject *__pyx_kp_s_39;
+static PyObject *__pyx_kp_u_30;
+static PyObject *__pyx_kp_u_31;
+static PyObject *__pyx_kp_u_32;
+static PyObject *__pyx_kp_u_33;
+static PyObject *__pyx_kp_u_34;
+static PyObject *__pyx_kp_u_35;
+static PyObject *__pyx_kp_u_36;
+static PyObject *__pyx_kp_u_37;
 static PyObject *__pyx_kp_s_4;
-static PyObject *__pyx_kp_s_40;
 static PyObject *__pyx_kp_s_5;
-static PyObject *__pyx_kp_u_51;
-static PyObject *__pyx_kp_u_52;
-static PyObject *__pyx_kp_u_53;
-static PyObject *__pyx_kp_u_54;
-static PyObject *__pyx_kp_u_55;
-static PyObject *__pyx_kp_u_56;
-static PyObject *__pyx_kp_u_57;
-static PyObject *__pyx_kp_u_58;
-static PyObject *__pyx_kp_u_59;
 static PyObject *__pyx_kp_s_6;
-static PyObject *__pyx_kp_u_60;
-static PyObject *__pyx_kp_u_61;
-static PyObject *__pyx_kp_u_62;
-static PyObject *__pyx_kp_u_63;
-static PyObject *__pyx_kp_u_64;
-static PyObject *__pyx_kp_u_65;
-static PyObject *__pyx_kp_u_66;
-static PyObject *__pyx_kp_u_67;
 static PyObject *__pyx_kp_s_7;
 static PyObject *__pyx_kp_s_8;
 static PyObject *__pyx_kp_s_9;
-static PyObject *__pyx_n_s__AttributeError;
-static PyObject *__pyx_n_s__GTFProxy;
 static PyObject *__pyx_n_s__IOError;
-static PyObject *__pyx_n_s__IndexError;
 static PyObject *__pyx_n_s__KeyError;
 static PyObject *__pyx_n_s__OSError;
 static PyObject *__pyx_n_s__O_RDONLY;
 static PyObject *__pyx_n_s__StopIteration;
-static PyObject *__pyx_n_s__StringType;
-static PyObject *__pyx_n_s__StringTypes;
+static PyObject *__pyx_n_s__TabixHeaderIterator;
 static PyObject *__pyx_n_s__TabixIterator;
 static PyObject *__pyx_n_s__TabixIteratorParsed;
 static PyObject *__pyx_n_s__Tabixfile;
-static PyObject *__pyx_n_s__TupleProxy;
-static PyObject *__pyx_n_s__TypeError;
 static PyObject *__pyx_n_s__ValueError;
 static PyObject *__pyx_n_s____all__;
-static PyObject *__pyx_n_s____getattr__;
+static PyObject *__pyx_n_s____get__;
 static PyObject *__pyx_n_s____main__;
 static PyObject *__pyx_n_s____next__;
 static PyObject *__pyx_n_s____test__;
 static PyObject *__pyx_n_s___isOpen;
 static PyObject *__pyx_n_s___open;
 static PyObject *__pyx_n_s___parseRegion;
-static PyObject *__pyx_n_s__asDict;
+static PyObject *__pyx_n_s__asBed;
 static PyObject *__pyx_n_s__asGTF;
 static PyObject *__pyx_n_s__asTuple;
-static PyObject *__pyx_n_s__attributes;
+static PyObject *__pyx_n_s__asVCF;
 static PyObject *__pyx_n_s__bc;
 static PyObject *__pyx_n_s__bed;
 static PyObject *__pyx_n_s__buffer;
 static PyObject *__pyx_n_s__close;
-static PyObject *__pyx_n_s__contig;
 static PyObject *__pyx_n_s__copy;
 static PyObject *__pyx_n_s__ctypes;
-static PyObject *__pyx_n_s__data;
 static PyObject *__pyx_n_s__ec;
 static PyObject *__pyx_n_s__end;
 static PyObject *__pyx_n_s__end_col;
 static PyObject *__pyx_n_s__endswith;
 static PyObject *__pyx_n_s__exists;
-static PyObject *__pyx_n_s__feature;
 static PyObject *__pyx_n_s__fetch;
-static PyObject *__pyx_n_s__fields;
 static PyObject *__pyx_n_s__filename;
 static PyObject *__pyx_n_s__filename_in;
 static PyObject *__pyx_n_s__filename_out;
 static PyObject *__pyx_n_s__force;
 static PyObject *__pyx_n_s__fp;
-static PyObject *__pyx_n_s__frame;
-static PyObject *__pyx_n_s__fromDict;
 static PyObject *__pyx_n_s__gff;
-static PyObject *__pyx_n_s__hasOwnAttributes;
+static PyObject *__pyx_n_s__gzip;
+static PyObject *__pyx_n_s__header;
 static PyObject *__pyx_n_s__idx;
-static PyObject *__pyx_n_s__index;
-static PyObject *__pyx_n_s__invert;
-static PyObject *__pyx_n_s__isModified;
-static PyObject *__pyx_n_s__items;
 static PyObject *__pyx_n_s__iterator;
 static PyObject *__pyx_n_s__itertools;
 static PyObject *__pyx_n_s__join;
@@ -986,9 +1080,6 @@ static PyObject *__pyx_n_s__len;
 static PyObject *__pyx_n_s__line_skip;
 static PyObject *__pyx_n_s__meta_char;
 static PyObject *__pyx_n_s__mode;
-static PyObject *__pyx_n_s__name;
-static PyObject *__pyx_n_s__nbytes;
-static PyObject *__pyx_n_s__nfields;
 static PyObject *__pyx_n_s__ord;
 static PyObject *__pyx_n_s__os;
 static PyObject *__pyx_n_s__parser;
@@ -996,21 +1087,14 @@ static PyObject *__pyx_n_s__path;
 static PyObject *__pyx_n_s__pileup;
 static PyObject *__pyx_n_s__preset;
 static PyObject *__pyx_n_s__psltbl;
-static PyObject *__pyx_n_s__quote;
 static PyObject *__pyx_n_s__r;
 static PyObject *__pyx_n_s__reference;
 static PyObject *__pyx_n_s__region;
 static PyObject *__pyx_n_s__sam;
 static PyObject *__pyx_n_s__sc;
-static PyObject *__pyx_n_s__score;
 static PyObject *__pyx_n_s__seq_col;
-static PyObject *__pyx_n_s__setAttribute;
-static PyObject *__pyx_n_s__source;
-static PyObject *__pyx_n_s__split;
 static PyObject *__pyx_n_s__start;
 static PyObject *__pyx_n_s__start_col;
-static PyObject *__pyx_n_s__strand;
-static PyObject *__pyx_n_s__strip;
 static PyObject *__pyx_n_s__struct;
 static PyObject *__pyx_n_s__sys;
 static PyObject *__pyx_n_s__tabix_compress;
@@ -1018,11 +1102,8 @@ static PyObject *__pyx_n_s__tabix_index;
 static PyObject *__pyx_n_s__tabixfile;
 static PyObject *__pyx_n_s__tempfile;
 static PyObject *__pyx_n_s__tid;
-static PyObject *__pyx_n_s__toDot;
 static PyObject *__pyx_n_s__types;
 static PyObject *__pyx_n_s__unlink;
-static PyObject *__pyx_n_s__update;
-static PyObject *__pyx_n_s__value;
 static PyObject *__pyx_n_s__vcf;
 static PyObject *__pyx_n_s__w;
 static PyObject *__pyx_n_s__zerobased;
@@ -1037,12 +1118,12 @@ static PyObject *__pyx_int_15;
 static PyObject *__pyx_int_17;
 static PyObject *__pyx_int_18;
 static PyObject *__pyx_int_0x10000;
-static PyObject *__pyx_k_28;
-static PyObject *__pyx_k_33;
-static PyObject *__pyx_k_35;
+static PyObject *__pyx_k_14;
+static PyObject *__pyx_k_19;
+static PyObject *__pyx_k_21;
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":18
- *     cdef tabix_t * tabixfile
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":15
+ *     '''
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
  *         self.tabixfile = NULL
@@ -1065,7 +1146,7 @@ static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObjec
   __Pyx_INCREF(__pyx_args);
   __pyx_v_args = __pyx_args;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":19
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":16
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
@@ -1074,18 +1155,18 @@ static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObjec
  */
   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":20
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":17
  *     def __cinit__(self, *args, **kwargs ):
  *         self.tabixfile = NULL
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *     def _isOpen( self ):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __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 = 20; __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 = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __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;
@@ -1106,7 +1187,7 @@ static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObjec
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":22
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":19
  *         self._open( *args, **kwargs )
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -1121,7 +1202,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYT
   PyObject *__pyx_t_1 = NULL;
   __Pyx_RefNannySetupContext("_isOpen");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":24
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":21
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.tabixfile != NULL             # <<<<<<<<<<<<<<
@@ -1129,7 +1210,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYT
  *     def _open( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -1147,7 +1228,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYT
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":26
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":23
  *         return self.tabixfile != NULL
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -1192,22 +1273,22 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_mode = values[1];
   } else {
     __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  2: __pyx_v_mode = PyTuple_GET_ITEM(__pyx_args, 1);
-      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.Tabixfile._open");
   __Pyx_RefNannyFinishContext();
@@ -1215,7 +1296,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_filename_index = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":33
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":30
  *         '''
  * 
  *         assert mode in ( "r",), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
@@ -1225,21 +1306,21 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
   #ifndef PYREX_WITHOUT_ASSERTIONS
   __Pyx_INCREF(__pyx_v_mode);
   __pyx_t_1 = __pyx_v_mode;
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (unlikely(!__pyx_t_3)) {
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_v_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_v_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":36
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":33
  * 
  *         # close a previously opened file
  *         if self.tabixfile != NULL: self.close()             # <<<<<<<<<<<<<<
@@ -1248,9 +1329,9 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
  */
   __pyx_t_3 = (((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile != NULL);
   if (__pyx_t_3) {
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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 = 36; __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 = 33; __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;
@@ -1258,7 +1339,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":37
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":34
  *         # close a previously opened file
  *         if self.tabixfile != NULL: self.close()
  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
@@ -1267,7 +1348,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
  */
   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":39
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":36
  *         self.tabixfile = NULL
  * 
  *         self.filename = filename             # <<<<<<<<<<<<<<
@@ -1276,181 +1357,181 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
  */
   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename = __pyx_v_filename;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":40
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":37
  * 
  *         self.filename = filename
  *         filename_index = filename + ".tbi"             # <<<<<<<<<<<<<<
  * 
  *         if mode[0] == 'w':
  */
-  __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __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_v_filename_index);
   __pyx_v_filename_index = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":42
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":39
  *         filename_index = filename + ".tbi"
  * 
  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
  *             # open file for writing
  *             pass
  */
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __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 = 42; __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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
     goto __pyx_L7;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":46
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":43
  *             pass
  * 
  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
  *             # open file for reading
  *             if not os.path.exists( self.filename ):
  */
-  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __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 = 46; __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 = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":48
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":45
  *         elif mode[0] == "r":
  *             # open file for reading
  *             if not os.path.exists( self.filename ):             # <<<<<<<<<<<<<<
  *                 raise IOError( "file `%s` not found" % self.filename)
  * 
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 45; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __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_4); __pyx_t_4 = 0;
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_5 = (!__pyx_t_3);
     if (__pyx_t_5) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":49
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":46
  *             # open file for reading
  *             if not os.path.exists( self.filename ):
  *                 raise IOError( "file `%s` not found" % self.filename)             # <<<<<<<<<<<<<<
  * 
  *             if not os.path.exists( filename_index ):
  */
-      __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
       __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 = 49; __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 = 46; __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_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_4, 0, 0);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":51
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":48
  *                 raise IOError( "file `%s` not found" % self.filename)
  * 
  *             if not os.path.exists( filename_index ):             # <<<<<<<<<<<<<<
  *                 raise IOError( "index `%s` not found" % filename_index)
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __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 = 51; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_filename_index);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename_index);
     __Pyx_GIVEREF(__pyx_v_filename_index);
-    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_3 = (!__pyx_t_5);
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":52
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":49
  * 
  *             if not os.path.exists( filename_index ):
  *                 raise IOError( "index `%s` not found" % filename_index)             # <<<<<<<<<<<<<<
  * 
  *             # open file and load index
  */
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_filename_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_filename_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 52; __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 = 49; __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_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":55
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":52
  * 
  *             # open file and load index
  *             self.tabixfile = ti_open( self.filename, filename_index )             # <<<<<<<<<<<<<<
  * 
  *         if self.tabixfile == NULL:
  */
-    __pyx_t_6 = PyBytes_AsString(__pyx_v_filename_index); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyBytes_AsString(__pyx_v_filename_index); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = ti_open(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename, __pyx_t_6);
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":57
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":54
  *             self.tabixfile = ti_open( self.filename, filename_index )
  * 
  *         if self.tabixfile == NULL:             # <<<<<<<<<<<<<<
@@ -1460,29 +1541,29 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
   __pyx_t_3 = (((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile == NULL);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":58
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":55
  * 
  *         if self.tabixfile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *     def _parseRegion( self,
  */
-    __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __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 = 58; __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 = 55; __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_IOError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L10;
   }
   __pyx_L10:;
@@ -1502,7 +1583,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObj
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":60
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":57
  *             raise IOError("could not open file `%s`" % filename )
  * 
  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
@@ -1536,7 +1617,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":61
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -1545,7 +1626,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":62
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -1554,7 +1635,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":63
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -1563,7 +1644,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":64
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -1602,7 +1683,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -1610,7 +1691,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     __pyx_v_region = values[3];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":61
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -1619,7 +1700,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":62
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -1628,7 +1709,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":63
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -1637,7 +1718,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":64
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -1656,7 +1737,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   }
   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 = 60; __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 = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion");
   __Pyx_RefNannyFinishContext();
@@ -1664,7 +1745,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":75
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":72
  *         Note that regions are 1-based, while start,end are python coordinates.
  *         '''
  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
@@ -1673,7 +1754,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":81
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":78
  *         cdef int rend
  *         cdef int max_pos
  *         max_pos = 2 << 29             # <<<<<<<<<<<<<<
@@ -1682,7 +1763,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
   __pyx_v_max_pos = 1073741824;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":83
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":80
  *         max_pos = 2 << 29
  * 
  *         rtid = rstart = rend = 0             # <<<<<<<<<<<<<<
@@ -1693,31 +1774,31 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   __pyx_v_rstart = 0;
   __pyx_v_rend = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":86
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":83
  * 
  *         # translate to a region
  *         if reference:             # <<<<<<<<<<<<<<
  *             if start != None and end != None:
  *                 region = "%s:%i-%i" % (reference, start+1, end)
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":87
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":84
  *         # translate to a region
  *         if reference:
  *             if start != None and end != None:             # <<<<<<<<<<<<<<
  *                 region = "%s:%i-%i" % (reference, start+1, end)
  *             elif start == None and end != None:
  */
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __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 = 87; __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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (__pyx_t_1) {
-      __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __pyx_t_4 = __pyx_t_3;
     } else {
@@ -1725,16 +1806,16 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     if (__pyx_t_4) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":88
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":85
  *         if reference:
  *             if start != None and end != None:
  *                 region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
  *             elif start == None and end != None:
  *                 region = "%s:%i-%i" % (reference, 1, end)
  */
-      __pyx_t_2 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __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 = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_INCREF(__pyx_v_reference);
       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference);
@@ -1745,7 +1826,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_end);
       __Pyx_GIVEREF(__pyx_v_end);
       __pyx_t_2 = 0;
-      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_DECREF(__pyx_v_region);
@@ -1754,21 +1835,21 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       goto __pyx_L7;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":89
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":86
  *             if start != None and end != None:
  *                 region = "%s:%i-%i" % (reference, start+1, end)
  *             elif start == None and end != None:             # <<<<<<<<<<<<<<
  *                 region = "%s:%i-%i" % (reference, 1, end)
  *             elif end == None and start != None:
  */
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __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 = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (__pyx_t_4) {
-      __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __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 = 89; __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 = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __pyx_t_3 = __pyx_t_1;
     } else {
@@ -1776,14 +1857,14 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     if (__pyx_t_3) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":90
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":87
  *                 region = "%s:%i-%i" % (reference, start+1, end)
  *             elif start == None and end != None:
  *                 region = "%s:%i-%i" % (reference, 1, end)             # <<<<<<<<<<<<<<
  *             elif end == None and start != None:
  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
  */
-      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __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 = 87; __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);
@@ -1794,7 +1875,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       __Pyx_INCREF(__pyx_v_end);
       PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
       __Pyx_GIVEREF(__pyx_v_end);
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_v_region);
@@ -1803,21 +1884,21 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       goto __pyx_L7;
     }
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":91
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":88
  *             elif start == None and end != None:
  *                 region = "%s:%i-%i" % (reference, 1, end)
  *             elif end == None and start != None:             # <<<<<<<<<<<<<<
  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
  *             else:
  */
-    __pyx_t_5 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_t_1 = __pyx_t_4;
     } else {
@@ -1825,18 +1906,18 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     if (__pyx_t_1) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":92
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":89
  *                 region = "%s:%i-%i" % (reference, 1, end)
  *             elif end == None and start != None:
  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)             # <<<<<<<<<<<<<<
  *             else:
  *                 region = reference
  */
-      __pyx_t_5 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_2 = PyInt_FromLong((__pyx_v_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong((__pyx_v_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __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 = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_INCREF(__pyx_v_reference);
       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
@@ -1847,7 +1928,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       __Pyx_GIVEREF(__pyx_t_2);
       __pyx_t_5 = 0;
       __pyx_t_2 = 0;
-      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_v_region);
@@ -1857,7 +1938,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":94
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":91
  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
  *             else:
  *                 region = reference             # <<<<<<<<<<<<<<
@@ -1873,27 +1954,27 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":96
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":93
  *                 region = reference
  * 
  *         if region:             # <<<<<<<<<<<<<<
  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":97
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":94
  * 
  *         if region:
  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)             # <<<<<<<<<<<<<<
  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
  */
-    __pyx_t_7 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ti_parse_region(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile->idx, __pyx_t_7, (&__pyx_v_rtid), (&__pyx_v_rstart), (&__pyx_v_rend));
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":98
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":95
  *         if region:
  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )             # <<<<<<<<<<<<<<
@@ -1902,24 +1983,24 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     __pyx_t_1 = (__pyx_v_rtid < 0);
     if (__pyx_t_1) {
-      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_v_region); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_v_region); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __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 = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
       __pyx_t_2 = 0;
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":99
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":96
  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
@@ -1928,11 +2009,11 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  */
     __pyx_t_1 = (__pyx_v_rstart > __pyx_v_rend);
     if (__pyx_t_1) {
-      __pyx_t_2 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __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 = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __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 = 96; __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);
@@ -1940,25 +2021,25 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
       __Pyx_GIVEREF(__pyx_t_6);
       __pyx_t_2 = 0;
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__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 = 99; __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 = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_6, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L10;
     }
     __pyx_L10:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":100
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":97
  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
@@ -1971,27 +2052,27 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     __pyx_t_3 = (!__pyx_t_1);
     if (__pyx_t_3) {
-      __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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 = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
       __Pyx_DECREF(__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 = 100; __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 = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L11;
     }
     __pyx_L11:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":101
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":98
  *             if rstart > rend: raise ValueError( 'invalid region: 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 )             # <<<<<<<<<<<<<<
@@ -2004,22 +2085,22 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
     }
     __pyx_t_1 = (!__pyx_t_3);
     if (__pyx_t_1) {
-      __pyx_t_5 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__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 = 101; __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 = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_6, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L12;
     }
     __pyx_L12:;
@@ -2027,7 +2108,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":103
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":100
  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
  * 
  *         return region, rtid, rstart, rend             # <<<<<<<<<<<<<<
@@ -2035,13 +2116,13 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __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 = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_region);
@@ -2075,7 +2156,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":105
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":102
  *         return region, rtid, rstart, rend
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -2109,7 +2190,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":106
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":103
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -2118,7 +2199,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":107
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -2127,7 +2208,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":108
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -2136,7 +2217,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":109
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -2145,7 +2226,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":110
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107
  *                end = None,
  *                region = None,
  *                parser = None ):             # <<<<<<<<<<<<<<
@@ -2190,7 +2271,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -2199,7 +2280,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     __pyx_v_parser = values[4];
   } else {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":106
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":103
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -2208,7 +2289,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":107
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -2217,7 +2298,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":108
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -2226,7 +2307,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":109
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -2235,7 +2316,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
     __pyx_v_region = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":110
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107
  *                end = None,
  *                region = None,
  *                parser = None ):             # <<<<<<<<<<<<<<
@@ -2255,7 +2336,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.Tabixfile.fetch");
   __Pyx_RefNannyFinishContext();
@@ -2266,7 +2347,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
   __pyx_v_rstart = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_rend = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":124
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":121
  *         data (see for example :meth:`asTuple` and :meth:`asGTF`).
  *         '''
  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
@@ -2275,55 +2356,55 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  */
   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":126
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":123
  *         ti_lazy_index_load( self.tabixfile )
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __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 = 126; __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 = 123; __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 = 126; __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 = 123; __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) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":127
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":124
  * 
  *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __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 = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_11));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":129
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":126
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if parser == None:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __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 = 129; __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 = 126; __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);
@@ -2337,7 +2418,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -2361,18 +2442,18 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     __pyx_v_rend = __pyx_t_7;
     __pyx_t_7 = 0;
   } else {
-    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __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 = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_8, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_8, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_8, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_8, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_8, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_8, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_8, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_8, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    if (__Pyx_EndUnpack(__pyx_t_8, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_8, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = __pyx_t_2;
@@ -2388,30 +2469,30 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     __pyx_t_7 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":131
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":128
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if parser == None:             # <<<<<<<<<<<<<<
  *             if region:
  *                 return TabixIterator( self, rtid, rstart, rend )
  */
-  __pyx_t_5 = PyObject_RichCompare(__pyx_v_parser, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_RichCompare(__pyx_v_parser, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":132
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":129
  * 
  *         if parser == None:
  *             if region:             # <<<<<<<<<<<<<<
  *                 return TabixIterator( self, rtid, rstart, rend )
  *             else:
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __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 = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_4) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":133
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":130
  *         if parser == None:
  *             if region:
  *                 return TabixIterator( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
@@ -2419,7 +2500,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  *                 return TabixIterator( self, -1, 0, 0 )
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_INCREF(__pyx_v_self);
       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
@@ -2433,7 +2514,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
       __Pyx_INCREF(__pyx_v_rend);
       PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend);
       __Pyx_GIVEREF(__pyx_v_rend);
-      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_r = __pyx_t_7;
@@ -2443,7 +2524,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":135
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":132
  *                 return TabixIterator( self, rtid, rstart, rend )
  *             else:
  *                 return TabixIterator( self, -1, 0, 0 )             # <<<<<<<<<<<<<<
@@ -2451,7 +2532,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  *             if region:
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_INCREF(__pyx_v_self);
       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
@@ -2465,7 +2546,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
       __Pyx_INCREF(__pyx_int_0);
       PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0);
       __Pyx_GIVEREF(__pyx_int_0);
-      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_r = __pyx_t_5;
@@ -2477,17 +2558,17 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":137
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":134
  *                 return TabixIterator( self, -1, 0, 0 )
  *         else:
  *             if region:             # <<<<<<<<<<<<<<
  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
  *             else:
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __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 = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_4) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":138
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":135
  *         else:
  *             if region:
  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )             # <<<<<<<<<<<<<<
@@ -2495,7 +2576,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __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 = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_INCREF(__pyx_v_self);
       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
@@ -2512,7 +2593,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
       __Pyx_INCREF(__pyx_v_parser);
       PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_parser);
       __Pyx_GIVEREF(__pyx_v_parser);
-      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_r = __pyx_t_7;
@@ -2522,15 +2603,15 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
     }
     /*else*/ {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":140
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":137
  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
  *             else:
  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )             # <<<<<<<<<<<<<<
  * 
- *     property contigs:
+ *     property header:
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_INCREF(__pyx_v_self);
       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
@@ -2547,7 +2628,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
       __Pyx_INCREF(__pyx_v_parser);
       PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_parser);
       __Pyx_GIVEREF(__pyx_v_parser);
-      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_r = __pyx_t_5;
@@ -2579,12 +2660,60 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObj
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":144
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":140
+ * 
+ *     property header:
+ *         def __get__( self ):             # <<<<<<<<<<<<<<
+ *             '''return header lines as an iterator.
+ * 
+ */
+
+static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":145
+ *             Note that the header lines do not contain the newline '\n' character.
+ *             '''
+ *             return TabixHeaderIterator( self )             # <<<<<<<<<<<<<<
+ * 
+ *     property contigs:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixHeaderIterator)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __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("ctabix.Tabixfile.header.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":149
  *     property contigs:
- *        '''chromosome names'''
- *        def __get__(self):             # <<<<<<<<<<<<<<
- *            cdef char ** sequences
- *            cdef int nsequences
+ *         '''chromosome names'''
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             cdef char ** sequences
+ *             cdef int nsequences
  */
 
 static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_self); /*proto*/
@@ -2600,67 +2729,67 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_
   __Pyx_RefNannySetupContext("__get__");
   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":148
- *            cdef int nsequences
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":153
+ *             cdef int nsequences
  * 
- *            ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
- *            sequences = ti_seqname( self.tabixfile.idx, &nsequences )
- *            cdef int x
+ *             ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
+ *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
+ *             cdef int x
  */
   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":149
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":154
  * 
- *            ti_lazy_index_load( self.tabixfile )
- *            sequences = ti_seqname( self.tabixfile.idx, &nsequences )             # <<<<<<<<<<<<<<
- *            cdef int x
- *            result = []
+ *             ti_lazy_index_load( self.tabixfile )
+ *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )             # <<<<<<<<<<<<<<
+ *             cdef int x
+ *             result = []
  */
   __pyx_v_sequences = ti_seqname(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile->idx, (&__pyx_v_nsequences));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":151
- *            sequences = ti_seqname( self.tabixfile.idx, &nsequences )
- *            cdef int x
- *            result = []             # <<<<<<<<<<<<<<
- *            for x from 0 <= x < nsequences:
- *                result.append( sequences[x] )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":156
+ *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
+ *             cdef int x
+ *             result = []             # <<<<<<<<<<<<<<
+ *             for x from 0 <= x < nsequences:
+ *                 result.append( sequences[x] )
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __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 = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
   __pyx_v_result = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":152
- *            cdef int x
- *            result = []
- *            for x from 0 <= x < nsequences:             # <<<<<<<<<<<<<<
- *                result.append( sequences[x] )
- *            return result
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":157
+ *             cdef int x
+ *             result = []
+ *             for x from 0 <= x < nsequences:             # <<<<<<<<<<<<<<
+ *                 result.append( sequences[x] )
+ *             return result
  */
   __pyx_t_2 = __pyx_v_nsequences;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":153
- *            result = []
- *            for x from 0 <= x < nsequences:
- *                result.append( sequences[x] )             # <<<<<<<<<<<<<<
- *            return result
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":158
+ *             result = []
+ *             for x from 0 <= x < nsequences:
+ *                 result.append( sequences[x] )             # <<<<<<<<<<<<<<
+ *             return result
  * 
  */
     if (unlikely(__pyx_v_result == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_1 = PyBytes_FromString((__pyx_v_sequences[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyBytes_FromString((__pyx_v_sequences[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":154
- *            for x from 0 <= x < nsequences:
- *                result.append( sequences[x] )
- *            return result             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":159
+ *             for x from 0 <= x < nsequences:
+ *                 result.append( sequences[x] )
+ *             return result             # <<<<<<<<<<<<<<
  * 
  * cdef class TabixIterator:
  */
@@ -2682,7 +2811,7 @@ static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":164
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":169
  *     cdef tabix_t * tabixfile
  * 
  *     def __cinit__(self, Tabixfile tabixfile,             # <<<<<<<<<<<<<<
@@ -2722,47 +2851,47 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  3:
       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
       if (likely(values[3])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)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 = 165; __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 = 165; __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 = 165; __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 = 170; __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 = 170; __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 = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
     goto __pyx_L5_argtuple_error;
   } else {
     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
-    __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":167
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":172
  *                   int tid, int start, int end ):
  * 
  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
@@ -2770,20 +2899,20 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
  *         # makes sure that samfile stays alive as long as the
  */
   #ifndef PYREX_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __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 = 167; __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 = 172; __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 = 167; __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 = 172; __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 = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":171
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":176
  *         # makes sure that samfile stays alive as long as the
  *         # iterator is alive.
  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
@@ -2792,7 +2921,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":173
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":178
  *         self.tabixfile = tabixfile.tabixfile
  * 
  *         if tid < 0:             # <<<<<<<<<<<<<<
@@ -2802,7 +2931,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
   __pyx_t_3 = (__pyx_v_tid < 0);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":176
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":181
  *             # seek to start of file to ensure iteration is over
  *             # all entries.
  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
@@ -2811,7 +2940,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
  */
     bgzf_seek(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile->fp, 0, 0);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":177
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":182
  *             # all entries.
  *             bgzf_seek( self.tabixfile.fp, 0, 0)
  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
@@ -2823,7 +2952,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":179
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":184
  *             self.iterator = ti_iter_first()
  *         else:
  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
@@ -2834,7 +2963,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":181
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":186
  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
  * 
  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
@@ -2844,24 +2973,24 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
   __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) == NULL);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":182
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":187
  * 
  *         if <void*>self.iterator == NULL:
  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
  * 
  *     def __iter__(self):
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __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 = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_12));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
@@ -2878,7 +3007,7 @@ static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":184
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":189
  *             raise ValueError("malformatted query or wrong sequence name.\n")
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -2891,7 +3020,7 @@ static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_sel
   PyObject *__pyx_r = NULL;
   __Pyx_RefNannySetupContext("__iter__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":185
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":190
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -2910,7 +3039,7 @@ static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":187
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":192
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -2929,39 +3058,65 @@ static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_2 = NULL;
   __Pyx_RefNannySetupContext("__next__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":195
- *         cdef char * s
- *         cdef int len
- *         s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
- *         if s == NULL: raise StopIteration
- *         return s
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":205
+ * 
+ *         # simply use '#' for now.
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             s = ti_read(self.tabixfile, self.iterator, &len)
+ *             if s == NULL: raise StopIteration
  */
-  __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator, (&__pyx_v_len));
+  while (1) {
+    if (!1) break;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":196
- *         cdef int len
- *         s = ti_read(self.tabixfile, self.iterator, &len)
- *         if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
- *         return s
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":206
+ *         # simply use '#' for now.
+ *         while 1:
+ *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
+ *             if s == NULL: raise StopIteration
+ *             if s[0] != '#': break
+ */
+    __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator, (&__pyx_v_len));
+
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":207
+ *         while 1:
+ *             s = ti_read(self.tabixfile, self.iterator, &len)
+ *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
+ *             if s[0] != '#': break
  * 
  */
-  __pyx_t_1 = (__pyx_v_s == NULL);
-  if (__pyx_t_1) {
-    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
+    __pyx_t_1 = (__pyx_v_s == NULL);
+    if (__pyx_t_1) {
+      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":208
+ *             s = ti_read(self.tabixfile, self.iterator, &len)
+ *             if s == NULL: raise StopIteration
+ *             if s[0] != '#': break             # <<<<<<<<<<<<<<
+ * 
+ *         return s
+ */
+    __pyx_t_1 = ((__pyx_v_s[0]) != '#');
+    if (__pyx_t_1) {
+      goto __pyx_L6_break;
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
   }
-  __pyx_L5:;
+  __pyx_L6_break:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":197
- *         s = ti_read(self.tabixfile, self.iterator, &len)
- *         if s == NULL: raise StopIteration
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":210
+ *             if s[0] != '#': break
+ * 
  *         return s             # <<<<<<<<<<<<<<
  * 
  *     def __dealloc__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -2979,7 +3134,7 @@ static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":199
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":212
  *         return s
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -2992,7 +3147,7 @@ static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self)
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("__dealloc__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":200
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":213
  * 
  *     def __dealloc__(self):
  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
@@ -3002,12 +3157,12 @@ static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self)
   __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":201
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":214
  *     def __dealloc__(self):
  *         if <void*>self.iterator != NULL:
  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
  * 
- * def toDot( v ):
+ * cdef class TabixHeaderIterator:
  */
     ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator);
     goto __pyx_L5;
@@ -3017,4221 +3172,418 @@ static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self)
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":203
- *             ti_iter_destroy(self.iterator)
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":223
+ *     cdef tabix_t * tabixfile
+ * 
+ *     def __cinit__(self, Tabixfile tabixfile ):             # <<<<<<<<<<<<<<
  * 
- * def toDot( v ):             # <<<<<<<<<<<<<<
- *     '''convert value to '.' if None'''
- *     if v == None: return "."
+ *         assert tabixfile._isOpen()
  */
 
-static PyObject *__pyx_pf_6ctabix_toDot(PyObject *__pyx_self, PyObject *__pyx_v_v); /*proto*/
-static char __pyx_doc_6ctabix_toDot[] = "toDot(v)\nconvert value to '.' if None";
-static PyObject *__pyx_pf_6ctabix_toDot(PyObject *__pyx_self, PyObject *__pyx_v_v) {
-  PyObject *__pyx_r = NULL;
+static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
+  int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
-  int __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  __Pyx_RefNannySetupContext("toDot");
-  __pyx_self = __pyx_self;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":205
- * def toDot( v ):
- *     '''convert value to '.' if None'''
- *     if v == None: return "."             # <<<<<<<<<<<<<<
- *     else: return str(v)
- * 
- */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_v, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __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 = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (__pyx_t_2) {
-    __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
-    __pyx_r = ((PyObject *)__pyx_kp_s_13);
-    goto __pyx_L0;
-    goto __pyx_L5;
-  }
-  /*else*/ {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":206
- *     '''convert value to '.' if None'''
- *     if v == None: return "."
- *     else: return str(v)             # <<<<<<<<<<<<<<
- * 
- * def quote( v ):
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(__pyx_v_v);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_v);
-    __Pyx_GIVEREF(__pyx_v_v);
-    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_r = __pyx_t_3;
-    __pyx_t_3 = 0;
-    goto __pyx_L0;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,0};
+  __Pyx_RefNannySetupContext("__cinit__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
   }
-  __pyx_L5:;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("ctabix.toDot");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
+  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 = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__");
   __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":208
- *     else: return str(v)
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":225
+ *     def __cinit__(self, Tabixfile tabixfile ):
  * 
- * def quote( v ):             # <<<<<<<<<<<<<<
- *     '''return a quoted attribute.'''
- *     if type(v) in types.StringTypes:
- */
-
-static PyObject *__pyx_pf_6ctabix_quote(PyObject *__pyx_self, PyObject *__pyx_v_v); /*proto*/
-static char __pyx_doc_6ctabix_quote[] = "quote(v)\nreturn a quoted attribute.";
-static PyObject *__pyx_pf_6ctabix_quote(PyObject *__pyx_self, PyObject *__pyx_v_v) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  __Pyx_RefNannySetupContext("quote");
-  __pyx_self = __pyx_self;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":210
- * def quote( v ):
- *     '''return a quoted attribute.'''
- *     if type(v) in types.StringTypes:             # <<<<<<<<<<<<<<
- *         return '"%s"' % v
- *     else:
+ *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
+ * 
+ *         # makes sure that samfile stays alive as long as the
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__StringTypes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __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 = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = ((PySequence_Contains(__pyx_t_2, ((PyObject *)Py_TYPE(__pyx_v_v))))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __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 = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (__pyx_t_3) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":211
- *     '''return a quoted attribute.'''
- *     if type(v) in types.StringTypes:
- *         return '"%s"' % v             # <<<<<<<<<<<<<<
- *     else:
- *         return str(v)
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_v_v); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __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;
-    goto __pyx_L5;
-  }
-  /*else*/ {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":213
- *         return '"%s"' % v
- *     else:
- *         return str(v)             # <<<<<<<<<<<<<<
- * 
- * cdef class TupleProxy:
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_INCREF(__pyx_v_v);
-    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_v);
-    __Pyx_GIVEREF(__pyx_v_v);
-    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_r = __pyx_t_1;
-    __pyx_t_1 = 0;
-    goto __pyx_L0;
+  if (unlikely(!__pyx_t_3)) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_L5:;
-
-  __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("ctabix.quote");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":227
- *         int index
- * 
- *     def __cinit__(self ):             # <<<<<<<<<<<<<<
- * 
- *         self.data = NULL
- */
-
-static int __pyx_pf_6ctabix_10TupleProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_6ctabix_10TupleProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  int __pyx_r;
-  __Pyx_RefNannySetupContext("__cinit__");
-  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
-    __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
+  #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":229
- *     def __cinit__(self ):
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":229
+ *         # makes sure that samfile stays alive as long as the
+ *         # iterator is alive.
+ *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
  * 
- *         self.data = NULL             # <<<<<<<<<<<<<<
- *         self.fields = NULL
- *         self.index = 0
+ *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
  */
-  ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->data = NULL;
+  ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":230
- * 
- *         self.data = NULL
- *         self.fields = NULL             # <<<<<<<<<<<<<<
- *         self.index = 0
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":231
+ *         self.tabixfile = tabixfile.tabixfile
  * 
- */
-  ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->fields = NULL;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":231
- *         self.data = NULL
- *         self.fields = NULL
- *         self.index = 0             # <<<<<<<<<<<<<<
+ *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)             # <<<<<<<<<<<<<<
  * 
- *     cdef take( self, char * buffer, size_t nbytes ):
+ *         if <void*>self.iterator == NULL:
  */
-  ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->index = 0;
-
-  __pyx_r = 0;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator = ti_query(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, NULL, 0, 0);
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":233
- *         self.index = 0
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":233
+ *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
  * 
- *     cdef take( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
+ *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
+ *             raise ValueError("can't open header.\n")
  * 
  */
+  __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator) == NULL);
+  if (__pyx_t_3) {
 
-static  PyObject *__pyx_f_6ctabix_10TupleProxy_take(struct __pyx_obj_6ctabix_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("take");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":238
- *         Take ownership of the pointer.
- *         '''
- *         self.data = buffer             # <<<<<<<<<<<<<<
- *         self.update( buffer, nbytes )
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":234
  * 
- */
-  __pyx_v_self->data = __pyx_v_buffer;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":239
- *         '''
- *         self.data = buffer
- *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
+ *         if <void*>self.iterator == NULL:
+ *             raise ValueError("can't open header.\n")             # <<<<<<<<<<<<<<
  * 
- *     cdef present( self, char * buffer, size_t nbytes ):
+ *     def __iter__(self):
  */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_13));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.TupleProxy.take");
-  __pyx_r = 0;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__");
+  __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":241
- *         self.update( buffer, nbytes )
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":236
+ *             raise ValueError("can't open header.\n")
  * 
- *     cdef present( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
  * 
  */
 
-static  PyObject *__pyx_f_6ctabix_10TupleProxy_present(struct __pyx_obj_6ctabix_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("present");
+  __Pyx_RefNannySetupContext("__iter__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":246
- *         Do not take ownership of the pointer.
- *         '''
- *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":237
  * 
- *     cdef copy( self, char * buffer, size_t nbytes ):
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     def __next__(self):
  */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __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_AddTraceback("ctabix.TupleProxy.present");
-  __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":248
- *         self.update( buffer, nbytes )
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":239
+ *         return self
  * 
- *     cdef copy( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
  * 
  */
 
-static  PyObject *__pyx_f_6ctabix_10TupleProxy_copy(struct __pyx_obj_6ctabix_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  int __pyx_v_s;
+static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_6ctabix_19TabixHeaderIterator___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
+struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__;
+static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___next__(PyObject *__pyx_v_self) {
+  char *__pyx_v_s;
+  int __pyx_v_len;
   PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("copy");
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  __Pyx_RefNannySetupContext("__next__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":255
- *         cdef int s
- *         # +1 for '\0'
- *         s = sizeof(char) *  (nbytes + 1)             # <<<<<<<<<<<<<<
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":250
+ *         # Getting the metachar is a pain as ti_index_t is incomplete type.
+ *         # simply use '#' for now.
+ *         s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
+ *         if s == NULL: raise StopIteration
+ *         # stop at first non-header line
  */
-  __pyx_v_s = ((sizeof(char)) * (__pyx_v_nbytes + 1));
+  __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator, (&__pyx_v_len));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":256
- *         # +1 for '\0'
- *         s = sizeof(char) *  (nbytes + 1)
- *         self.data = <char*>malloc( s )             # <<<<<<<<<<<<<<
- *         memcpy( <char*>self.data, buffer, s )
- *         self.update( self.data, nbytes )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":251
+ *         # simply use '#' for now.
+ *         s = ti_read(self.tabixfile, self.iterator, &len)
+ *         if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
+ *         # stop at first non-header line
+ *         if s[0] != '#': raise StopIteration
  */
-  __pyx_v_self->data = ((char *)malloc(__pyx_v_s));
+  __pyx_t_1 = (__pyx_v_s == NULL);
+  if (__pyx_t_1) {
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":257
- *         s = sizeof(char) *  (nbytes + 1)
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )             # <<<<<<<<<<<<<<
- *         self.update( self.data, nbytes )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":253
+ *         if s == NULL: raise StopIteration
+ *         # stop at first non-header line
+ *         if s[0] != '#': raise StopIteration             # <<<<<<<<<<<<<<
  * 
+ *         return s
  */
-  memcpy(__pyx_v_self->data, __pyx_v_buffer, __pyx_v_s);
+  __pyx_t_1 = ((__pyx_v_s[0]) != '#');
+  if (__pyx_t_1) {
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":258
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )
- *         self.update( self.data, nbytes )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":255
+ *         if s[0] != '#': raise StopIteration
  * 
- *     cdef update( self, char * buffer, size_t nbytes ):
+ *         return s             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
  */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_self->data, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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_AddTraceback("ctabix.TupleProxy.copy");
-  __pyx_r = 0;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__next__");
+  __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":260
- *         self.update( self.data, nbytes )
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":257
+ *         return s
  * 
- *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''update internal data.'''
- *         cdef char * pos
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         if <void*>self.iterator != NULL:
+ *             ti_iter_destroy(self.iterator)
  */
 
-static  PyObject *__pyx_f_6ctabix_10TupleProxy_update(struct __pyx_obj_6ctabix_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  char *__pyx_v_pos;
-  char *__pyx_v_old_pos;
-  int __pyx_v_field;
-  int __pyx_v_max_fields;
-  PyObject *__pyx_r = NULL;
+static void __pyx_pf_6ctabix_19TabixHeaderIterator___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_6ctabix_19TabixHeaderIterator___dealloc__(PyObject *__pyx_v_self) {
   int __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  __Pyx_RefNannySetupContext("update");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":266
- *         cdef int field
- *         cdef int max_fields
- *         field = 0             # <<<<<<<<<<<<<<
- * 
- *         if buffer[nbytes] != 0:
- */
-  __pyx_v_field = 0;
+  __Pyx_RefNannySetupContext("__dealloc__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":268
- *         field = 0
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":258
  * 
- *         if buffer[nbytes] != 0:             # <<<<<<<<<<<<<<
- *             raise ValueError( "incomplete line at %s" % buffer )
+ *     def __dealloc__(self):
+ *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
+ *             ti_iter_destroy(self.iterator)
  * 
  */
-  __pyx_t_1 = ((__pyx_v_buffer[__pyx_v_nbytes]) != 0);
+  __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator) != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":269
- * 
- *         if buffer[nbytes] != 0:
- *             raise ValueError( "incomplete line at %s" % buffer )             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":259
+ *     def __dealloc__(self):
+ *         if <void*>self.iterator != NULL:
+ *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
  * 
- *         if self.fields != NULL:
+ * #########################################################
  */
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 269; __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_ValueError, __pyx_t_2, NULL); 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_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L3;
+    ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator);
+    goto __pyx_L5;
   }
-  __pyx_L3:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":271
- *             raise ValueError( "incomplete line at %s" % buffer )
- * 
- *         if self.fields != NULL:             # <<<<<<<<<<<<<<
- *             free(self.fields)
- * 
- */
-  __pyx_t_1 = (__pyx_v_self->fields != NULL);
-  if (__pyx_t_1) {
+  __pyx_L5:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":272
- * 
- *         if self.fields != NULL:
- *             free(self.fields)             # <<<<<<<<<<<<<<
- * 
- *         max_fields = nbytes / 4
- */
-    free(__pyx_v_self->fields);
-    goto __pyx_L4;
-  }
-  __pyx_L4:;
+  __Pyx_RefNannyFinishContext();
+}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":274
- *             free(self.fields)
- * 
- *         max_fields = nbytes / 4             # <<<<<<<<<<<<<<
- *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
- * 
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":269
+ * cdef class asTuple(Parser):
+ *     '''converts a :term:`tabix row` into a python tuple.'''
+ *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
+ *         cdef TabProxies.TupleProxy r
+ *         r = TabProxies.TupleProxy()
  */
-  __pyx_v_max_fields = (__pyx_v_nbytes / 4);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":275
- * 
- *         max_fields = nbytes / 4
- *         self.fields = <char **>calloc( max_fields, sizeof(char *) )             # <<<<<<<<<<<<<<
- * 
- *         pos = buffer
- */
-  __pyx_v_self->fields = ((char **)calloc(__pyx_v_max_fields, (sizeof(char *))));
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":277
- *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
- * 
- *         pos = buffer             # <<<<<<<<<<<<<<
- *         self.fields[0] = pos
- *         field += 1
- */
-  __pyx_v_pos = __pyx_v_buffer;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":278
- * 
- *         pos = buffer
- *         self.fields[0] = pos             # <<<<<<<<<<<<<<
- *         field += 1
- *         old_pos = pos
- */
-  (__pyx_v_self->fields[0]) = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":279
- *         pos = buffer
- *         self.fields[0] = pos
- *         field += 1             # <<<<<<<<<<<<<<
- *         old_pos = pos
- * 
- */
-  __pyx_v_field += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":280
- *         self.fields[0] = pos
- *         field += 1
- *         old_pos = pos             # <<<<<<<<<<<<<<
- * 
- *         while 1:
- */
-  __pyx_v_old_pos = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":282
- *         old_pos = pos
- * 
- *         while 1:             # <<<<<<<<<<<<<<
- * 
- *             pos = <char*>memchr( pos, '\t', nbytes )
- */
-  while (1) {
-    if (!1) break;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":284
- *         while 1:
- * 
- *             pos = <char*>memchr( pos, '\t', nbytes )             # <<<<<<<<<<<<<<
- *             if pos == NULL: break
- *             pos[0] = '\0'
- */
-    __pyx_v_pos = ((char *)memchr(__pyx_v_pos, '\t', __pyx_v_nbytes));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":285
- * 
- *             pos = <char*>memchr( pos, '\t', nbytes )
- *             if pos == NULL: break             # <<<<<<<<<<<<<<
- *             pos[0] = '\0'
- *             pos += 1
- */
-    __pyx_t_1 = (__pyx_v_pos == NULL);
-    if (__pyx_t_1) {
-      goto __pyx_L6_break;
-      goto __pyx_L7;
-    }
-    __pyx_L7:;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":286
- *             pos = <char*>memchr( pos, '\t', nbytes )
- *             if pos == NULL: break
- *             pos[0] = '\0'             # <<<<<<<<<<<<<<
- *             pos += 1
- *             self.fields[field] = pos
- */
-    (__pyx_v_pos[0]) = '\x00';
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":287
- *             if pos == NULL: break
- *             pos[0] = '\0'
- *             pos += 1             # <<<<<<<<<<<<<<
- *             self.fields[field] = pos
- *             field += 1
- */
-    __pyx_v_pos += 1;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":288
- *             pos[0] = '\0'
- *             pos += 1
- *             self.fields[field] = pos             # <<<<<<<<<<<<<<
- *             field += 1
- *             if field >= max_fields:
- */
-    (__pyx_v_self->fields[__pyx_v_field]) = __pyx_v_pos;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":289
- *             pos += 1
- *             self.fields[field] = pos
- *             field += 1             # <<<<<<<<<<<<<<
- *             if field >= max_fields:
- *                 raise ValueError("row too large - more than %i fields" % max_fields )
- */
-    __pyx_v_field += 1;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":290
- *             self.fields[field] = pos
- *             field += 1
- *             if field >= max_fields:             # <<<<<<<<<<<<<<
- *                 raise ValueError("row too large - more than %i fields" % max_fields )
- *             nbytes -= pos - old_pos
- */
-    __pyx_t_1 = (__pyx_v_field >= __pyx_v_max_fields);
-    if (__pyx_t_1) {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":291
- *             field += 1
- *             if field >= max_fields:
- *                 raise ValueError("row too large - more than %i fields" % max_fields )             # <<<<<<<<<<<<<<
- *             nbytes -= pos - old_pos
- *             if nbytes < 0: break
- */
-      __pyx_t_3 = PyInt_FromLong(__pyx_v_max_fields); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__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 = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-      __pyx_t_2 = 0;
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); 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);
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __Pyx_Raise(__pyx_t_2, 0, 0);
-      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L8;
-    }
-    __pyx_L8:;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":292
- *             if field >= max_fields:
- *                 raise ValueError("row too large - more than %i fields" % max_fields )
- *             nbytes -= pos - old_pos             # <<<<<<<<<<<<<<
- *             if nbytes < 0: break
- *             old_pos = pos
- */
-    __pyx_v_nbytes -= (__pyx_v_pos - __pyx_v_old_pos);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":293
- *                 raise ValueError("row too large - more than %i fields" % max_fields )
- *             nbytes -= pos - old_pos
- *             if nbytes < 0: break             # <<<<<<<<<<<<<<
- *             old_pos = pos
- * 
- */
-    __pyx_t_1 = (__pyx_v_nbytes < 0);
-    if (__pyx_t_1) {
-      goto __pyx_L6_break;
-      goto __pyx_L9;
-    }
-    __pyx_L9:;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":294
- *             nbytes -= pos - old_pos
- *             if nbytes < 0: break
- *             old_pos = pos             # <<<<<<<<<<<<<<
- * 
- *         self.nfields = field
- */
-    __pyx_v_old_pos = __pyx_v_pos;
-  }
-  __pyx_L6_break:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":296
- *             old_pos = pos
- * 
- *         self.nfields = field             # <<<<<<<<<<<<<<
- * 
- *     def __getitem__( self, key ):
- */
-  __pyx_v_self->nfields = __pyx_v_field;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("ctabix.TupleProxy.update");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":298
- *         self.nfields = field
- * 
- *     def __getitem__( self, key ):             # <<<<<<<<<<<<<<
- * 
- *         cdef int i
- */
-
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
-  int __pyx_v_i;
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  int __pyx_t_2;
-  int __pyx_t_3;
-  int __pyx_t_4;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  __Pyx_RefNannySetupContext("__getitem__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":301
- * 
- *         cdef int i
- *         i = key             # <<<<<<<<<<<<<<
- *         if i < 0: i += self.nfields
- *         if i >= self.nfields or i < 0:
- */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_key); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_i = __pyx_t_1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":302
- *         cdef int i
- *         i = key
- *         if i < 0: i += self.nfields             # <<<<<<<<<<<<<<
- *         if i >= self.nfields or i < 0:
- *             raise IndexError( "list index out of range" )
- */
-  __pyx_t_2 = (__pyx_v_i < 0);
-  if (__pyx_t_2) {
-    __pyx_v_i += ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->nfields;
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":303
- *         i = key
- *         if i < 0: i += self.nfields
- *         if i >= self.nfields or i < 0:             # <<<<<<<<<<<<<<
- *             raise IndexError( "list index out of range" )
- *         return self.fields[i]
- */
-  __pyx_t_2 = (__pyx_v_i >= ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->nfields);
-  if (!__pyx_t_2) {
-    __pyx_t_3 = (__pyx_v_i < 0);
-    __pyx_t_4 = __pyx_t_3;
-  } else {
-    __pyx_t_4 = __pyx_t_2;
-  }
-  if (__pyx_t_4) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":304
- *         if i < 0: i += self.nfields
- *         if i >= self.nfields or i < 0:
- *             raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
- *         return self.fields[i]
- * 
- */
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_17));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
-    __pyx_t_6 = PyObject_Call(__pyx_builtin_IndexError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_Raise(__pyx_t_6, 0, 0);
-    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":305
- *         if i >= self.nfields or i < 0:
- *             raise IndexError( "list index out of range" )
- *         return self.fields[i]             # <<<<<<<<<<<<<<
- * 
- *     def __len__(self):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_6 = PyBytes_FromString((((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->fields[__pyx_v_i])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-  __pyx_r = ((PyObject *)__pyx_t_6);
-  __pyx_t_6 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_AddTraceback("ctabix.TupleProxy.__getitem__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":307
- *         return self.fields[i]
- * 
- *     def __len__(self):             # <<<<<<<<<<<<<<
- *         return self.nfields
- * 
- */
-
-static Py_ssize_t __pyx_pf_6ctabix_10TupleProxy___len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pf_6ctabix_10TupleProxy___len__(PyObject *__pyx_v_self) {
-  Py_ssize_t __pyx_r;
-  __Pyx_RefNannySetupContext("__len__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":308
- * 
- *     def __len__(self):
- *         return self.nfields             # <<<<<<<<<<<<<<
- * 
- *     def __dealloc__(self):
- */
-  __pyx_r = ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->nfields;
-  goto __pyx_L0;
-
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":310
- *         return self.nfields
- * 
- *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         if self.data != NULL:
- *             free(self.data)
- */
-
-static void __pyx_pf_6ctabix_10TupleProxy___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_6ctabix_10TupleProxy___dealloc__(PyObject *__pyx_v_self) {
-  int __pyx_t_1;
-  __Pyx_RefNannySetupContext("__dealloc__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":311
- * 
- *     def __dealloc__(self):
- *         if self.data != NULL:             # <<<<<<<<<<<<<<
- *             free(self.data)
- * 
- */
-  __pyx_t_1 = (((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->data != NULL);
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":312
- *     def __dealloc__(self):
- *         if self.data != NULL:
- *             free(self.data)             # <<<<<<<<<<<<<<
- * 
- *     def __iter__(self):
- */
-    free(((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->data);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  __Pyx_RefNannyFinishContext();
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":314
- *             free(self.data)
- * 
- *     def __iter__(self):             # <<<<<<<<<<<<<<
- *         self.index = 0
- *         return self
- */
-
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___iter__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  __Pyx_RefNannySetupContext("__iter__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":315
- * 
- *     def __iter__(self):
- *         self.index = 0             # <<<<<<<<<<<<<<
- *         return self
- * 
- */
-  ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->index = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":316
- *     def __iter__(self):
- *         self.index = 0
- *         return self             # <<<<<<<<<<<<<<
- * 
- *     def __next__(self):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(__pyx_v_self);
-  __pyx_r = __pyx_v_self;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":318
- *         return self
- * 
- *     def __next__(self):             # <<<<<<<<<<<<<<
- *         """python version of next().
- *         """
- */
-
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_6ctabix_10TupleProxy___next__[] = "python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_6ctabix_10TupleProxy___next__;
-static PyObject *__pyx_pf_6ctabix_10TupleProxy___next__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
-  __Pyx_RefNannySetupContext("__next__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":321
- *         """python version of next().
- *         """
- *         if self.index >= self.nfields:             # <<<<<<<<<<<<<<
- *             raise StopIteration
- *         self.index += 1
- */
-  __pyx_t_1 = (((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->index >= ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->nfields);
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":322
- *         """
- *         if self.index >= self.nfields:
- *             raise StopIteration             # <<<<<<<<<<<<<<
- *         self.index += 1
- *         return self.fields[self.index-1]
- */
-    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":323
- *         if self.index >= self.nfields:
- *             raise StopIteration
- *         self.index += 1             # <<<<<<<<<<<<<<
- *         return self.fields[self.index-1]
- * 
- */
-  ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->index += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":324
- *             raise StopIteration
- *         self.index += 1
- *         return self.fields[self.index-1]             # <<<<<<<<<<<<<<
- * 
- * cdef class GTFProxy:
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->fields[(((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_v_self)->index - 1)])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __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_2);
-  __Pyx_AddTraceback("ctabix.TupleProxy.__next__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":355
- *         cdef bint hasOwnAttributes
- * 
- *     def __cinit__(self ):             # <<<<<<<<<<<<<<
- *         self.data = NULL
- *         self.isModified = False
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  int __pyx_r;
-  __Pyx_RefNannySetupContext("__cinit__");
-  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
-    __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":356
- * 
- *     def __cinit__(self ):
- *         self.data = NULL             # <<<<<<<<<<<<<<
- *         self.isModified = False
- *         self.hasOwnAttributes = False
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->data = NULL;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":357
- *     def __cinit__(self ):
- *         self.data = NULL
- *         self.isModified = False             # <<<<<<<<<<<<<<
- *         self.hasOwnAttributes = False
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":358
- *         self.data = NULL
- *         self.isModified = False
- *         self.hasOwnAttributes = False             # <<<<<<<<<<<<<<
- * 
- *     cdef take( self, char * buffer, size_t nbytes ):
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->hasOwnAttributes = 0;
-
-  __pyx_r = 0;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":360
- *         self.hasOwnAttributes = False
- * 
- *     cdef take( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
- * 
- */
-
-static  PyObject *__pyx_f_6ctabix_8GTFProxy_take(struct __pyx_obj_6ctabix_GTFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("take");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":365
- *         Take ownership of the pointer.
- *         '''
- *         self.data = buffer             # <<<<<<<<<<<<<<
- *         self.update( buffer, nbytes )
- *         self.isModified = False
- */
-  __pyx_v_self->data = __pyx_v_buffer;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":366
- *         '''
- *         self.data = buffer
- *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
- *         self.isModified = False
- * 
- */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_GTFProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":367
- *         self.data = buffer
- *         self.update( buffer, nbytes )
- *         self.isModified = False             # <<<<<<<<<<<<<<
- * 
- *     cdef present( self, char * buffer, size_t nbytes ):
- */
-  __pyx_v_self->isModified = 0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.GTFProxy.take");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":369
- *         self.isModified = False
- * 
- *     cdef present( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
- * 
- */
-
-static  PyObject *__pyx_f_6ctabix_8GTFProxy_present(struct __pyx_obj_6ctabix_GTFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("present");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":374
- *         Do not take ownership of the pointer.
- *         '''
- *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
- *         self.isModified = False
- * 
- */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_GTFProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":375
- *         '''
- *         self.update( buffer, nbytes )
- *         self.isModified = False             # <<<<<<<<<<<<<<
- * 
- *     cdef copy( self, char * buffer, size_t nbytes ):
- */
-  __pyx_v_self->isModified = 0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.GTFProxy.present");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":377
- *         self.isModified = False
- * 
- *     cdef copy( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''start presenting buffer.
- * 
- */
-
-static  PyObject *__pyx_f_6ctabix_8GTFProxy_copy(struct __pyx_obj_6ctabix_GTFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  int __pyx_v_s;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("copy");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":384
- *         cdef int s
- *         # +1 for '\0'
- *         s = sizeof(char) *  (nbytes + 1)             # <<<<<<<<<<<<<<
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )
- */
-  __pyx_v_s = ((sizeof(char)) * (__pyx_v_nbytes + 1));
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":385
- *         # +1 for '\0'
- *         s = sizeof(char) *  (nbytes + 1)
- *         self.data = <char*>malloc( s )             # <<<<<<<<<<<<<<
- *         memcpy( <char*>self.data, buffer, s )
- *         self.update( self.data, nbytes )
- */
-  __pyx_v_self->data = ((char *)malloc(__pyx_v_s));
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":386
- *         s = sizeof(char) *  (nbytes + 1)
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )             # <<<<<<<<<<<<<<
- *         self.update( self.data, nbytes )
- *         self.isModified = False
- */
-  memcpy(__pyx_v_self->data, __pyx_v_buffer, __pyx_v_s);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":387
- *         self.data = <char*>malloc( s )
- *         memcpy( <char*>self.data, buffer, s )
- *         self.update( self.data, nbytes )             # <<<<<<<<<<<<<<
- *         self.isModified = False
- * 
- */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_GTFProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_self->data, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":388
- *         memcpy( <char*>self.data, buffer, s )
- *         self.update( self.data, nbytes )
- *         self.isModified = False             # <<<<<<<<<<<<<<
- * 
- *     cdef update( self, char * buffer, size_t nbytes ):
- */
-  __pyx_v_self->isModified = 0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.GTFProxy.copy");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":390
- *         self.isModified = False
- * 
- *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
- *         '''update internal data.
- * 
- */
-
-static  PyObject *__pyx_f_6ctabix_8GTFProxy_update(struct __pyx_obj_6ctabix_GTFProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
-  char *__pyx_v_cstart;
-  char *__pyx_v_cend;
-  char *__pyx_v_pos;
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  __Pyx_RefNannySetupContext("update");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":397
- *         cdef int end
- *         cdef char * cstart, * cend, * cscore
- *         self.contig = buffer             # <<<<<<<<<<<<<<
- *         self.nbytes = nbytes
- *         cdef char * pos
- */
-  __pyx_v_self->contig = __pyx_v_buffer;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":398
- *         cdef char * cstart, * cend, * cscore
- *         self.contig = buffer
- *         self.nbytes = nbytes             # <<<<<<<<<<<<<<
- *         cdef char * pos
- * 
- */
-  __pyx_v_self->nbytes = __pyx_v_nbytes;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":401
- *         cdef char * pos
- * 
- *         if buffer[nbytes] != 0:             # <<<<<<<<<<<<<<
- *             raise ValueError( "incomplete line at %s" % buffer )
- * 
- */
-  __pyx_t_1 = ((__pyx_v_buffer[__pyx_v_nbytes]) != 0);
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":402
- * 
- *         if buffer[nbytes] != 0:
- *             raise ValueError( "incomplete line at %s" % buffer )             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( buffer, '\t' )
- */
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 402; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L3;
-  }
-  __pyx_L3:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":404
- *             raise ValueError( "incomplete line at %s" % buffer )
- * 
- *         pos = strchr( buffer, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_buffer, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":405
- * 
- *         pos = strchr( buffer, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __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 = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, 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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L4;
-  }
-  __pyx_L4:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":406
- *         pos = strchr( buffer, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.source = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":407
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.source = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":408
- *         pos[0] = '\0'
- *         pos += 1
- *         self.source = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_self->source = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":410
- *         self.source = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":411
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 411; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":412
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.feature = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":413
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.feature = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":414
- *         pos[0] = '\0'
- *         pos += 1
- *         self.feature = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_self->feature = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":416
- *         self.feature = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":417
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __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 = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); 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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":418
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         cstart = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":419
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         cstart = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":420
- *         pos[0] = '\0'
- *         pos += 1
- *         cstart = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_cstart = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":422
- *         cstart = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":423
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 423; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L7;
-  }
-  __pyx_L7:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":424
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         cend = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":425
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         cend = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":426
- *         pos[0] = '\0'
- *         pos += 1
- *         cend = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_cend = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":428
- *         cend = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":429
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __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 = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L8;
-  }
-  __pyx_L8:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":430
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.score = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":431
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.score = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":432
- *         pos[0] = '\0'
- *         pos += 1
- *         self.score = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_self->score = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":434
- *         self.score = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":435
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 435; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L9;
-  }
-  __pyx_L9:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":436
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.strand = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":437
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.strand = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":438
- *         pos[0] = '\0'
- *         pos += 1
- *         self.strand = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_self->strand = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":440
- *         self.strand = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":441
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __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 = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L10;
-  }
-  __pyx_L10:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":442
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.frame = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":443
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.frame = pos
- * 
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":444
- *         pos[0] = '\0'
- *         pos += 1
- *         self.frame = pos             # <<<<<<<<<<<<<<
- * 
- *         pos = strchr( pos, '\t' )
- */
-  __pyx_v_self->frame = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":446
- *         self.frame = pos
- * 
- *         pos = strchr( pos, '\t' )             # <<<<<<<<<<<<<<
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- */
-  __pyx_v_pos = strchr(__pyx_v_pos, '\t');
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":447
- * 
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )             # <<<<<<<<<<<<<<
- *         pos[0] = '\0'
- *         pos += 1
- */
-  __pyx_t_1 = (__pyx_v_pos == NULL);
-  if (__pyx_t_1) {
-    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __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 = 447; __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_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L11;
-  }
-  __pyx_L11:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":448
- *         pos = strchr( pos, '\t' )
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'             # <<<<<<<<<<<<<<
- *         pos += 1
- *         self.attributes = pos
- */
-  (__pyx_v_pos[0]) = '\x00';
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":449
- *         if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
- *         pos[0] = '\0'
- *         pos += 1             # <<<<<<<<<<<<<<
- *         self.attributes = pos
- *         self.start = atoi( cstart ) - 1
- */
-  __pyx_v_pos += 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":450
- *         pos[0] = '\0'
- *         pos += 1
- *         self.attributes = pos             # <<<<<<<<<<<<<<
- *         self.start = atoi( cstart ) - 1
- *         self.end = atoi( cend )
- */
-  __pyx_v_self->attributes = __pyx_v_pos;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":451
- *         pos += 1
- *         self.attributes = pos
- *         self.start = atoi( cstart ) - 1             # <<<<<<<<<<<<<<
- *         self.end = atoi( cend )
- * 
- */
-  __pyx_v_self->start = (atoi(__pyx_v_cstart) - 1);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":452
- *         self.attributes = pos
- *         self.start = atoi( cstart ) - 1
- *         self.end = atoi( cend )             # <<<<<<<<<<<<<<
- * 
- *     property contig:
- */
-  __pyx_v_self->end = atoi(__pyx_v_cend);
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("ctabix.GTFProxy.update");
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":456
- *     property contig:
- *        '''contig of feature.'''
- *        def __get__( self ): return self.contig             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6contig___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6contig___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->contig); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __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("ctabix.GTFProxy.contig.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":457
- *        '''contig of feature.'''
- *        def __get__( self ): return self.contig
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.contig = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_6contig___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_6contig___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":458
- *        def __get__( self ): return self.contig
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.contig = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":459
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.contig = value             # <<<<<<<<<<<<<<
- * 
- *     property feature:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->contig = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.contig.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":463
- *     property feature:
- *        '''feature name.'''
- *        def __get__( self ): return self.feature             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_7feature___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_7feature___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __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("ctabix.GTFProxy.feature.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":464
- *        '''feature name.'''
- *        def __get__( self ): return self.feature
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.feature = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_7feature___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_7feature___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":465
- *        def __get__( self ): return self.feature
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.feature = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":466
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.feature = value             # <<<<<<<<<<<<<<
- * 
- *     property source:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->feature = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.feature.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":470
- *     property source:
- *        '''feature source.'''
- *        def __get__( self ): return self.source             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6source___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6source___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->source); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __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("ctabix.GTFProxy.source.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":471
- *        '''feature source.'''
- *        def __get__( self ): return self.source
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.source = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_6source___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_6source___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":472
- *        def __get__( self ): return self.source
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.source = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":473
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.source = value             # <<<<<<<<<<<<<<
- * 
- *     property start:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->source = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.source.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":477
- *     property start:
- *        '''feature start (in 0-based open/closed coordinates).'''
- *        def __get__( self ): return self.start             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5start___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5start___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start); 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_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("ctabix.GTFProxy.start.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":478
- *        '''feature start (in 0-based open/closed coordinates).'''
- *        def __get__( self ): return self.start
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.start = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_5start___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_5start___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  uint32_t __pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":479
- *        def __get__( self ): return self.start
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.start = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":480
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.start = value             # <<<<<<<<<<<<<<
- * 
- *     property end:
- */
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.start.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":484
- *     property end:
- *        '''feature end (in 0-based open/closed coordinates).'''
- *        def __get__( self ): return self.end             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_3end___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_3end___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __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("ctabix.GTFProxy.end.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":485
- *        '''feature end (in 0-based open/closed coordinates).'''
- *        def __get__( self ): return self.end
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.end = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_3end___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_3end___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  uint32_t __pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":486
- *        def __get__( self ): return self.end
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.end = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":487
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.end = value             # <<<<<<<<<<<<<<
- * 
- *     property score:
- */
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.end.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":491
- *     property score:
- *        '''feature score.'''
- *        def __get__( self ):             # <<<<<<<<<<<<<<
- *            if self.score[0] == '.' and self.score[1] == '\0' :
- *                return None
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5score___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5score___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  int __pyx_t_2;
-  int __pyx_t_3;
-  PyObject *__pyx_t_4 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":492
- *        '''feature score.'''
- *        def __get__( self ):
- *            if self.score[0] == '.' and self.score[1] == '\0' :             # <<<<<<<<<<<<<<
- *                return None
- *            else:
- */
-  __pyx_t_1 = ((((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->score[0]) == '.');
-  if (__pyx_t_1) {
-    __pyx_t_2 = ((((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->score[1]) == '\x00');
-    __pyx_t_3 = __pyx_t_2;
-  } else {
-    __pyx_t_3 = __pyx_t_1;
-  }
-  if (__pyx_t_3) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":493
- *        def __get__( self ):
- *            if self.score[0] == '.' and self.score[1] == '\0' :
- *                return None             # <<<<<<<<<<<<<<
- *            else:
- *                return atof(self.score)
- */
-    __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(Py_None);
-    __pyx_r = Py_None;
-    goto __pyx_L0;
-    goto __pyx_L5;
-  }
-  /*else*/ {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":495
- *                return None
- *            else:
- *                return atof(self.score)             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_4 = PyFloat_FromDouble(atof(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->score)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __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_L5:;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_AddTraceback("ctabix.GTFProxy.score.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":496
- *            else:
- *                return atof(self.score)
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.score = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_5score___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_5score___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":497
- *                return atof(self.score)
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.score = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":498
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.score = value             # <<<<<<<<<<<<<<
- * 
- *     property strand:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->score = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.score.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":502
- *     property strand:
- *        '''feature strand.'''
- *        def __get__( self ): return self.strand             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6strand___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_6strand___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __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("ctabix.GTFProxy.strand.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":503
- *        '''feature strand.'''
- *        def __get__( self ): return self.strand
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.strand = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_6strand___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_6strand___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":504
- *        def __get__( self ): return self.strand
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.strand = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":505
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.strand = value             # <<<<<<<<<<<<<<
- * 
- *     property frame:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->strand = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.strand.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":509
- *     property frame:
- *        '''feature frame.'''
- *        def __get__( self ): return self.frame             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5frame___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_5frame___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __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("ctabix.GTFProxy.frame.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":510
- *        '''feature frame.'''
- *        def __get__( self ): return self.frame
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.frame = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_5frame___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_5frame___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":511
- *        def __get__( self ): return self.frame
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.frame = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":512
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.frame = value             # <<<<<<<<<<<<<<
- * 
- *     property attributes:
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->frame = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.frame.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":516
- *     property attributes:
- *        '''feature attributes (as a string).'''
- *        def __get__( self ): return self.attributes             # <<<<<<<<<<<<<<
- *        def __set__( self, value ):
- *            self.isModified = True
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_10attributes___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_10attributes___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __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("ctabix.GTFProxy.attributes.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":517
- *        '''feature attributes (as a string).'''
- *        def __get__( self ): return self.attributes
- *        def __set__( self, value ):             # <<<<<<<<<<<<<<
- *            self.isModified = True
- *            self.attributes = value
- */
-
-static int __pyx_pf_6ctabix_8GTFProxy_10attributes___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pf_6ctabix_8GTFProxy_10attributes___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
-  int __pyx_r;
-  char *__pyx_t_1;
-  __Pyx_RefNannySetupContext("__set__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":518
- *        def __get__( self ): return self.attributes
- *        def __set__( self, value ):
- *            self.isModified = True             # <<<<<<<<<<<<<<
- *            self.attributes = value
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":519
- *        def __set__( self, value ):
- *            self.isModified = True
- *            self.attributes = value             # <<<<<<<<<<<<<<
- * 
- *     def asDict( self ):
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.attributes.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":521
- *            self.attributes = value
- * 
- *     def asDict( self ):             # <<<<<<<<<<<<<<
- *         """parse attributes - return as dict
- *         """
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_asDict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy_asDict[] = "GTFProxy.asDict(self)\nparse attributes - return as dict\n        ";
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_asDict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  char *__pyx_v_attributes;
-  PyObject *__pyx_v_fields;
-  PyObject *__pyx_v_result;
-  PyObject *__pyx_v_f;
-  PyObject *__pyx_v_d;
-  PyObject *__pyx_v_n;
-  PyObject *__pyx_v_v;
-  PyObject *__pyx_v_x;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  Py_ssize_t __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  Py_ssize_t __pyx_t_6;
-  PyObject *__pyx_t_7 = NULL;
-  int __pyx_t_8;
-  int __pyx_t_9;
-  int __pyx_t_10;
-  double __pyx_t_11;
-  int __pyx_t_12;
-  __Pyx_RefNannySetupContext("asDict");
-  __pyx_v_fields = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_d = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":526
- * 
- *         # remove comments
- *         attributes = self.attributes             # <<<<<<<<<<<<<<
- * 
- *         # separate into fields
- */
-  __pyx_v_attributes = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":529
- * 
- *         # separate into fields
- *         fields = [ x.strip() for x in attributes.split(";")[:-1]]             # <<<<<<<<<<<<<<
- * 
- *         result = {}
- */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_3 = PyBytes_FromString(__pyx_v_attributes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __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 = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_19));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
-  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PySequence_GetSlice(__pyx_t_5, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
-    __pyx_t_2 = 0; __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5);
-  } else {
-    __pyx_t_2 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-  }
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_5))) {
-      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
-      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
-      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
-      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
-    } else {
-      __pyx_t_3 = PyIter_Next(__pyx_t_5);
-      if (!__pyx_t_3) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        break;
-      }
-      __Pyx_GOTREF(__pyx_t_3);
-    }
-    __Pyx_DECREF(__pyx_v_x);
-    __pyx_v_x = __pyx_t_3;
-    __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  }
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __Pyx_INCREF(((PyObject *)__pyx_t_1));
-  __Pyx_DECREF(((PyObject *)__pyx_v_fields));
-  __pyx_v_fields = __pyx_t_1;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":531
- *         fields = [ x.strip() for x in attributes.split(";")[:-1]]
- * 
- *         result = {}             # <<<<<<<<<<<<<<
- * 
- *         for f in fields:
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __Pyx_DECREF(((PyObject *)__pyx_v_result));
-  __pyx_v_result = __pyx_t_1;
-  __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":533
- *         result = {}
- * 
- *         for f in fields:             # <<<<<<<<<<<<<<
- * 
- *             d = [ x.strip() for x in f.split(" ")]
- */
-  if (likely(((PyObject *)__pyx_v_fields) != Py_None)) {
-    __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields); __Pyx_INCREF(__pyx_t_1);
-  } else {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  for (;;) {
-    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
-    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
-    __Pyx_DECREF(__pyx_v_f);
-    __pyx_v_f = __pyx_t_5;
-    __pyx_t_5 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":535
- *         for f in fields:
- * 
- *             d = [ x.strip() for x in f.split(" ")]             # <<<<<<<<<<<<<<
- * 
- *             n,v = d[0], d[1]
- */
-    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_20));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
-    __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_7);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
-      __pyx_t_6 = 0; __pyx_t_3 = __pyx_t_7; __Pyx_INCREF(__pyx_t_3);
-    } else {
-      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-    }
-    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    for (;;) {
-      if (likely(PyList_CheckExact(__pyx_t_3))) {
-        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
-        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
-      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
-        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
-        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
-      } else {
-        __pyx_t_7 = PyIter_Next(__pyx_t_3);
-        if (!__pyx_t_7) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          break;
-        }
-        __Pyx_GOTREF(__pyx_t_7);
-      }
-      __Pyx_DECREF(__pyx_v_x);
-      __pyx_v_x = __pyx_t_7;
-      __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_4 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      if (unlikely(PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    }
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_INCREF(((PyObject *)__pyx_t_5));
-    __Pyx_DECREF(((PyObject *)__pyx_v_d));
-    __pyx_v_d = __pyx_t_5;
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":537
- *             d = [ x.strip() for x in f.split(" ")]
- * 
- *             n,v = d[0], d[1]             # <<<<<<<<<<<<<<
- *             if len(d) > 2: v = d[1:]
- * 
- */
-    __pyx_t_5 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_d), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_d), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_v_n);
-    __pyx_v_n = __pyx_t_5;
-    __pyx_t_5 = 0;
-    __Pyx_DECREF(__pyx_v_v);
-    __pyx_v_v = __pyx_t_3;
-    __pyx_t_3 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":538
- * 
- *             n,v = d[0], d[1]
- *             if len(d) > 2: v = d[1:]             # <<<<<<<<<<<<<<
- * 
- *             if v[0] == '"' and v[-1] == '"':
- */
-    if (unlikely(__pyx_v_d == Py_None)) {
-      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-    }
-    __pyx_t_6 = PyList_GET_SIZE(((PyObject *)__pyx_v_d)); 
-    __pyx_t_8 = (__pyx_t_6 > 2);
-    if (__pyx_t_8) {
-      __pyx_t_3 = PySequence_GetSlice(((PyObject *)__pyx_v_d), 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-      __Pyx_DECREF(__pyx_v_v);
-      __pyx_v_v = ((PyObject *)__pyx_t_3);
-      __pyx_t_3 = 0;
-      goto __pyx_L11;
-    }
-    __pyx_L11:;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":540
- *             if len(d) > 2: v = d[1:]
- * 
- *             if v[0] == '"' and v[-1] == '"':             # <<<<<<<<<<<<<<
- *                 v = v[1:-1]
- *             else:
- */
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_v, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_kp_s_21), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    if (__pyx_t_8) {
-      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_v, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_kp_s_21), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_10 = __pyx_t_9;
-    } else {
-      __pyx_t_10 = __pyx_t_8;
-    }
-    if (__pyx_t_10) {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":541
- * 
- *             if v[0] == '"' and v[-1] == '"':
- *                 v = v[1:-1]             # <<<<<<<<<<<<<<
- *             else:
- *                 ## try to convert to a value
- */
-      __pyx_t_3 = PySequence_GetSlice(__pyx_v_v, 1, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(__pyx_v_v);
-      __pyx_v_v = __pyx_t_3;
-      __pyx_t_3 = 0;
-      goto __pyx_L12;
-    }
-    /*else*/ {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":544
- *             else:
- *                 ## try to convert to a value
- *                 try:             # <<<<<<<<<<<<<<
- *                     v = float( v )
- *                     v = int( v )
- */
-      {
-        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
-        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
-        __Pyx_XGOTREF(__pyx_save_exc_type);
-        __Pyx_XGOTREF(__pyx_save_exc_value);
-        __Pyx_XGOTREF(__pyx_save_exc_tb);
-        /*try:*/ {
-
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":545
- *                 ## try to convert to a value
- *                 try:
- *                     v = float( v )             # <<<<<<<<<<<<<<
- *                     v = int( v )
- *                 except ValueError:
- */
-          __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_v_v); if (unlikely(__pyx_t_11 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
-          __pyx_t_3 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
-          __Pyx_GOTREF(__pyx_t_3);
-          __Pyx_DECREF(__pyx_v_v);
-          __pyx_v_v = __pyx_t_3;
-          __pyx_t_3 = 0;
-
-          /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":546
- *                 try:
- *                     v = float( v )
- *                     v = int( v )             # <<<<<<<<<<<<<<
- *                 except ValueError:
- *                     pass
- */
-          __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
-          __Pyx_GOTREF(__pyx_t_3);
-          __Pyx_INCREF(__pyx_v_v);
-          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_v);
-          __Pyx_GIVEREF(__pyx_v_v);
-          __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
-          __Pyx_GOTREF(__pyx_t_5);
-          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-          __Pyx_DECREF(__pyx_v_v);
-          __pyx_v_v = __pyx_t_5;
-          __pyx_t_5 = 0;
-        }
-        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
-        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
-        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
-        goto __pyx_L20_try_end;
-        __pyx_L13_error:;
-        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
-        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":547
- *                     v = float( v )
- *                     v = int( v )
- *                 except ValueError:             # <<<<<<<<<<<<<<
- *                     pass
- *                 except TypeError:
- */
-        __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
-        if (__pyx_t_12) {
-          PyErr_Restore(0,0,0);
-          goto __pyx_L14_exception_handled;
-        }
-
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":549
- *                 except ValueError:
- *                     pass
- *                 except TypeError:             # <<<<<<<<<<<<<<
- *                     pass
- * 
- */
-        __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
-        if (__pyx_t_12) {
-          PyErr_Restore(0,0,0);
-          goto __pyx_L14_exception_handled;
-        }
-        __Pyx_XGIVEREF(__pyx_save_exc_type);
-        __Pyx_XGIVEREF(__pyx_save_exc_value);
-        __Pyx_XGIVEREF(__pyx_save_exc_tb);
-        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
-        goto __pyx_L1_error;
-        __pyx_L14_exception_handled:;
-        __Pyx_XGIVEREF(__pyx_save_exc_type);
-        __Pyx_XGIVEREF(__pyx_save_exc_value);
-        __Pyx_XGIVEREF(__pyx_save_exc_tb);
-        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
-        __pyx_L20_try_end:;
-      }
-    }
-    __pyx_L12:;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":552
- *                     pass
- * 
- *             result[n] = v             # <<<<<<<<<<<<<<
- * 
- *         return result
- */
-    if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_n, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":554
- *             result[n] = v
- * 
- *         return result             # <<<<<<<<<<<<<<
- * 
- *     def fromDict( self, d ):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(((PyObject *)__pyx_v_result));
-  __pyx_r = ((PyObject *)__pyx_v_result);
-  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_3);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_7);
-  __Pyx_AddTraceback("ctabix.GTFProxy.asDict");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_fields);
-  __Pyx_DECREF(__pyx_v_result);
-  __Pyx_DECREF(__pyx_v_f);
-  __Pyx_DECREF(__pyx_v_d);
-  __Pyx_DECREF(__pyx_v_n);
-  __Pyx_DECREF(__pyx_v_v);
-  __Pyx_DECREF(__pyx_v_x);
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":556
- *         return result
- * 
- *     def fromDict( self, d ):             # <<<<<<<<<<<<<<
- *         '''set attributes from a dictionary.'''
- *         cdef char * p
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_fromDict(PyObject *__pyx_v_self, PyObject *__pyx_v_d); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy_fromDict[] = "GTFProxy.fromDict(self, d)\nset attributes from a dictionary.";
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_fromDict(PyObject *__pyx_v_self, PyObject *__pyx_v_d) {
-  char *__pyx_v_p;
-  int __pyx_v_l;
-  PyObject *__pyx_v_aa;
-  PyObject *__pyx_v_k;
-  PyObject *__pyx_v_v;
-  PyObject *__pyx_v_a;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  Py_ssize_t __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  int __pyx_t_7;
-  int __pyx_t_8;
-  char *__pyx_t_9;
-  __Pyx_RefNannySetupContext("fromDict");
-  __pyx_v_aa = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":562
- * 
- *         # clean up if this field is set twice
- *         if self.hasOwnAttributes:             # <<<<<<<<<<<<<<
- *             free(self.attributes)
- * 
- */
-  if (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->hasOwnAttributes) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":563
- *         # clean up if this field is set twice
- *         if self.hasOwnAttributes:
- *             free(self.attributes)             # <<<<<<<<<<<<<<
- * 
- *         aa = []
- */
-    free(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":565
- *             free(self.attributes)
- * 
- *         aa = []             # <<<<<<<<<<<<<<
- *         for k,v in d.items():
- *             if type(v) == types.StringType:
- */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __Pyx_DECREF(((PyObject *)__pyx_v_aa));
-  __pyx_v_aa = __pyx_t_1;
-  __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":566
- * 
- *         aa = []
- *         for k,v in d.items():             # <<<<<<<<<<<<<<
- *             if type(v) == types.StringType:
- *                 aa.append( '%s "%s"' % (k,v) )
- */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_d, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __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 = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
-    __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1);
-  } else {
-    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-  }
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_1))) {
-      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
-      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
-      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
-      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
-    } else {
-      __pyx_t_3 = PyIter_Next(__pyx_t_1);
-      if (!__pyx_t_3) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        break;
-      }
-      __Pyx_GOTREF(__pyx_t_3);
-    }
-    if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
-      PyObject* tuple = __pyx_t_3;
-      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
-      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __Pyx_DECREF(__pyx_v_k);
-      __pyx_v_k = __pyx_t_4;
-      __pyx_t_4 = 0;
-      __Pyx_DECREF(__pyx_v_v);
-      __pyx_v_v = __pyx_t_5;
-      __pyx_t_5 = 0;
-    } else {
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __Pyx_DECREF(__pyx_v_k);
-      __pyx_v_k = __pyx_t_4;
-      __pyx_t_4 = 0;
-      __Pyx_DECREF(__pyx_v_v);
-      __pyx_v_v = __pyx_t_5;
-      __pyx_t_5 = 0;
-    }
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":567
- *         aa = []
- *         for k,v in d.items():
- *             if type(v) == types.StringType:             # <<<<<<<<<<<<<<
- *                 aa.append( '%s "%s"' % (k,v) )
- *             else:
- */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__StringType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_v)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    if (__pyx_t_7) {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":568
- *         for k,v in d.items():
- *             if type(v) == types.StringType:
- *                 aa.append( '%s "%s"' % (k,v) )             # <<<<<<<<<<<<<<
- *             else:
- *                 aa.append( '%s %s' % (k,str(v)) )
- */
-      if (unlikely(__pyx_v_aa == Py_None)) {
-        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __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 = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_INCREF(__pyx_v_k);
-      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_k);
-      __Pyx_GIVEREF(__pyx_v_k);
-      __Pyx_INCREF(__pyx_v_v);
-      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_v);
-      __Pyx_GIVEREF(__pyx_v_v);
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_aa), ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-      goto __pyx_L8;
-    }
-    /*else*/ {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":570
- *                 aa.append( '%s "%s"' % (k,v) )
- *             else:
- *                 aa.append( '%s %s' % (k,str(v)) )             # <<<<<<<<<<<<<<
- * 
- *         a = "; ".join( aa ) + ";"
- */
-      if (unlikely(__pyx_v_aa == Py_None)) {
-        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __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 = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(__pyx_v_v);
-      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_v);
-      __Pyx_GIVEREF(__pyx_v_v);
-      __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, 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(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_INCREF(__pyx_v_k);
-      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_k);
-      __Pyx_GIVEREF(__pyx_v_k);
-      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
-      __Pyx_GIVEREF(__pyx_t_3);
-      __pyx_t_3 = 0;
-      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), __pyx_t_5); 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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_aa), ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    }
-    __pyx_L8:;
-  }
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":572
- *                 aa.append( '%s %s' % (k,str(v)) )
- * 
- *         a = "; ".join( aa ) + ";"             # <<<<<<<<<<<<<<
- *         p = a
- *         l = len(a)
- */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_24), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __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 = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_INCREF(((PyObject *)__pyx_v_aa));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_aa));
-  __Pyx_GIVEREF(((PyObject *)__pyx_v_aa));
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_19)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __Pyx_DECREF(__pyx_v_a);
-  __pyx_v_a = __pyx_t_3;
-  __pyx_t_3 = 0;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":573
- * 
- *         a = "; ".join( aa ) + ";"
- *         p = a             # <<<<<<<<<<<<<<
- *         l = len(a)
- *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
- */
-  __pyx_t_9 = PyBytes_AsString(__pyx_v_a); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_p = __pyx_t_9;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":574
- *         a = "; ".join( aa ) + ";"
- *         p = a
- *         l = len(a)             # <<<<<<<<<<<<<<
- *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
- *         memcpy( self.attributes, p, l )
- */
-  __pyx_t_2 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_l = __pyx_t_2;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":575
- *         p = a
- *         l = len(a)
- *         self.attributes = <char *>calloc( l + 1, sizeof(char) )             # <<<<<<<<<<<<<<
- *         memcpy( self.attributes, p, l )
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes = ((char *)calloc((__pyx_v_l + 1), (sizeof(char))));
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":576
- *         l = len(a)
- *         self.attributes = <char *>calloc( l + 1, sizeof(char) )
- *         memcpy( self.attributes, p, l )             # <<<<<<<<<<<<<<
- * 
- *         self.hasOwnAttributes = True
- */
-  memcpy(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes, __pyx_v_p, __pyx_v_l);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":578
- *         memcpy( self.attributes, p, l )
- * 
- *         self.hasOwnAttributes = True             # <<<<<<<<<<<<<<
- *         self.isModified = True
- * 
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->hasOwnAttributes = 1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":579
- * 
- *         self.hasOwnAttributes = True
- *         self.isModified = True             # <<<<<<<<<<<<<<
- * 
- *     def __str__(self):
- */
-  ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified = 1;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_AddTraceback("ctabix.GTFProxy.fromDict");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_aa);
-  __Pyx_DECREF(__pyx_v_k);
-  __Pyx_DECREF(__pyx_v_v);
-  __Pyx_DECREF(__pyx_v_a);
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":581
- *         self.isModified = True
- * 
- *     def __str__(self):             # <<<<<<<<<<<<<<
- *         cdef char * cpy
- *         cdef int x
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___str__(PyObject *__pyx_v_self) {
-  char *__pyx_v_cpy;
-  int __pyx_v_x;
-  char *__pyx_v_result;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  PyObject *__pyx_t_7 = NULL;
-  PyObject *__pyx_t_8 = NULL;
-  PyObject *__pyx_t_9 = NULL;
-  PyObject *__pyx_t_10 = NULL;
-  PyObject *__pyx_t_11 = NULL;
-  int __pyx_t_12;
-  int __pyx_t_13;
-  __Pyx_RefNannySetupContext("__str__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":585
- *         cdef int x
- * 
- *         if self.isModified:             # <<<<<<<<<<<<<<
- *             return "\t".join(
- *                 (self.contig,
- */
-  if (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->isModified) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":586
- * 
- *         if self.isModified:
- *             return "\t".join(             # <<<<<<<<<<<<<<
- *                 (self.contig,
- *                  self.source,
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_25), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":587
- *         if self.isModified:
- *             return "\t".join(
- *                 (self.contig,             # <<<<<<<<<<<<<<
- *                  self.source,
- *                  self.feature,
- */
-    __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->contig); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":588
- *             return "\t".join(
- *                 (self.contig,
- *                  self.source,             # <<<<<<<<<<<<<<
- *                  self.feature,
- *                  str(self.start+1),
- */
-    __pyx_t_3 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->source); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":589
- *                 (self.contig,
- *                  self.source,
- *                  self.feature,             # <<<<<<<<<<<<<<
- *                  str(self.start+1),
- *                  str(self.end),
- */
-    __pyx_t_4 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->feature); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":590
- *                  self.source,
- *                  self.feature,
- *                  str(self.start+1),             # <<<<<<<<<<<<<<
- *                  str(self.end),
- *                  toDot(self.score),
- */
-    __pyx_t_5 = PyInt_FromLong((((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
-    __Pyx_GIVEREF(__pyx_t_5);
-    __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":591
- *                  self.feature,
- *                  str(self.start+1),
- *                  str(self.end),             # <<<<<<<<<<<<<<
- *                  toDot(self.score),
- *                  self.strand,
- */
-    __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_7);
-    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
-    __Pyx_GIVEREF(__pyx_t_6);
-    __pyx_t_6 = 0;
-    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":592
- *                  str(self.start+1),
- *                  str(self.end),
- *                  toDot(self.score),             # <<<<<<<<<<<<<<
- *                  self.strand,
- *                  self.frame,
- */
-    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__toDot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->score); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __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 = 592; __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_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __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_9); __pyx_t_9 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":593
- *                  str(self.end),
- *                  toDot(self.score),
- *                  self.strand,             # <<<<<<<<<<<<<<
- *                  self.frame,
- *                  self.attributes ) )
- */
-    __pyx_t_9 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->strand); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":594
- *                  toDot(self.score),
- *                  self.strand,
- *                  self.frame,             # <<<<<<<<<<<<<<
- *                  self.attributes ) )
- *         else:
- */
-    __pyx_t_7 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->frame); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":595
- *                  self.strand,
- *                  self.frame,
- *                  self.attributes ) )             # <<<<<<<<<<<<<<
- *         else:
- *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
- */
-    __pyx_t_10 = PyBytes_FromString(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
-    __pyx_t_11 = PyTuple_New(9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_11);
-    PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    PyTuple_SET_ITEM(__pyx_t_11, 1, ((PyObject *)__pyx_t_3));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-    PyTuple_SET_ITEM(__pyx_t_11, 2, ((PyObject *)__pyx_t_4));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
-    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_5);
-    __Pyx_GIVEREF(__pyx_t_5);
-    PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_6);
-    __Pyx_GIVEREF(__pyx_t_6);
-    PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_8);
-    __Pyx_GIVEREF(__pyx_t_8);
-    PyTuple_SET_ITEM(__pyx_t_11, 6, ((PyObject *)__pyx_t_9));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
-    PyTuple_SET_ITEM(__pyx_t_11, 7, ((PyObject *)__pyx_t_7));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
-    PyTuple_SET_ITEM(__pyx_t_11, 8, ((PyObject *)__pyx_t_10));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
-    __pyx_t_2 = 0;
-    __pyx_t_3 = 0;
-    __pyx_t_4 = 0;
-    __pyx_t_5 = 0;
-    __pyx_t_6 = 0;
-    __pyx_t_8 = 0;
-    __pyx_t_9 = 0;
-    __pyx_t_7 = 0;
-    __pyx_t_10 = 0;
-    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_10);
-    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
-    __Pyx_GIVEREF(__pyx_t_11);
-    __pyx_t_11 = 0;
-    __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_11);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-    __pyx_r = __pyx_t_11;
-    __pyx_t_11 = 0;
-    goto __pyx_L0;
-    goto __pyx_L5;
-  }
-  /*else*/ {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":597
- *                  self.attributes ) )
- *         else:
- *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )             # <<<<<<<<<<<<<<
- *             memcpy( cpy, self.data, self.nbytes+1)
- *             for x from 0 <= x < self.nbytes:
- */
-    __pyx_v_cpy = ((char *)calloc((sizeof(char)), (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->nbytes + 1)));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":598
- *         else:
- *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
- *             memcpy( cpy, self.data, self.nbytes+1)             # <<<<<<<<<<<<<<
- *             for x from 0 <= x < self.nbytes:
- *                 if cpy[x] == '\0': cpy[x] = '\t'
- */
-    memcpy(__pyx_v_cpy, ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->data, (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->nbytes + 1));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":599
- *             cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
- *             memcpy( cpy, self.data, self.nbytes+1)
- *             for x from 0 <= x < self.nbytes:             # <<<<<<<<<<<<<<
- *                 if cpy[x] == '\0': cpy[x] = '\t'
- *             result = cpy
- */
-    __pyx_t_12 = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->nbytes;
-    for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_12; __pyx_v_x++) {
-
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":600
- *             memcpy( cpy, self.data, self.nbytes+1)
- *             for x from 0 <= x < self.nbytes:
- *                 if cpy[x] == '\0': cpy[x] = '\t'             # <<<<<<<<<<<<<<
- *             result = cpy
- *             free(cpy)
- */
-      __pyx_t_13 = ((__pyx_v_cpy[__pyx_v_x]) == '\x00');
-      if (__pyx_t_13) {
-        (__pyx_v_cpy[__pyx_v_x]) = '\t';
-        goto __pyx_L8;
-      }
-      __pyx_L8:;
-    }
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":601
- *             for x from 0 <= x < self.nbytes:
- *                 if cpy[x] == '\0': cpy[x] = '\t'
- *             result = cpy             # <<<<<<<<<<<<<<
- *             free(cpy)
- *             return result
- */
-    __pyx_v_result = __pyx_v_cpy;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":602
- *                 if cpy[x] == '\0': cpy[x] = '\t'
- *             result = cpy
- *             free(cpy)             # <<<<<<<<<<<<<<
- *             return result
- * 
- */
-    free(__pyx_v_cpy);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":603
- *             result = cpy
- *             free(cpy)
- *             return result             # <<<<<<<<<<<<<<
- * 
- *     def invert( self, int lcontig ):
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_11 = PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
-    __pyx_r = ((PyObject *)__pyx_t_11);
-    __pyx_t_11 = 0;
-    goto __pyx_L0;
-  }
-  __pyx_L5:;
-
-  __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_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_XDECREF(__pyx_t_7);
-  __Pyx_XDECREF(__pyx_t_8);
-  __Pyx_XDECREF(__pyx_t_9);
-  __Pyx_XDECREF(__pyx_t_10);
-  __Pyx_XDECREF(__pyx_t_11);
-  __Pyx_AddTraceback("ctabix.GTFProxy.__str__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":605
- *             return result
- * 
- *     def invert( self, int lcontig ):             # <<<<<<<<<<<<<<
- *         '''invert coordinates to negative strand coordinates
- * 
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_invert(PyObject *__pyx_v_self, PyObject *__pyx_arg_lcontig); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy_invert[] = "GTFProxy.invert(self, int lcontig)\ninvert coordinates to negative strand coordinates\n        \n        This method will only act if the feature is on the\n        negative strand.";
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_invert(PyObject *__pyx_v_self, PyObject *__pyx_arg_lcontig) {
-  int __pyx_v_lcontig;
-  PyObject *__pyx_v_start;
-  PyObject *__pyx_v_end;
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
-  uint32_t __pyx_t_2;
-  uint32_t __pyx_t_3;
-  uint32_t __pyx_t_4;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  __Pyx_RefNannySetupContext("invert");
-  assert(__pyx_arg_lcontig); {
-    __pyx_v_lcontig = __Pyx_PyInt_AsInt(__pyx_arg_lcontig); if (unlikely((__pyx_v_lcontig == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  }
-  goto __pyx_L4_argument_unpacking_done;
-  __pyx_L3_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.invert");
-  __Pyx_RefNannyFinishContext();
-  return NULL;
-  __pyx_L4_argument_unpacking_done:;
-  __pyx_v_start = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_end = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":611
- *         negative strand.'''
- * 
- *         if self.strand[0] == '-':             # <<<<<<<<<<<<<<
- *             start = min(self.start, self.end)
- *             end = max(self.start, self.end)
- */
-  __pyx_t_1 = ((((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->strand[0]) == '-');
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":612
- * 
- *         if self.strand[0] == '-':
- *             start = min(self.start, self.end)             # <<<<<<<<<<<<<<
- *             end = max(self.start, self.end)
- *             self.start, self.end = lcontig - end, lcontig - start
- */
-    __pyx_t_2 = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end;
-    __pyx_t_3 = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start;
-    if ((__pyx_t_2 < __pyx_t_3)) {
-      __pyx_t_4 = __pyx_t_2;
-    } else {
-      __pyx_t_4 = __pyx_t_3;
-    }
-    __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_v_start);
-    __pyx_v_start = __pyx_t_5;
-    __pyx_t_5 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":613
- *         if self.strand[0] == '-':
- *             start = min(self.start, self.end)
- *             end = max(self.start, self.end)             # <<<<<<<<<<<<<<
- *             self.start, self.end = lcontig - end, lcontig - start
- * 
- */
-    __pyx_t_4 = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end;
-    __pyx_t_2 = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start;
-    if ((__pyx_t_4 > __pyx_t_2)) {
-      __pyx_t_3 = __pyx_t_4;
-    } else {
-      __pyx_t_3 = __pyx_t_2;
-    }
-    __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_v_end);
-    __pyx_v_end = __pyx_t_5;
-    __pyx_t_5 = 0;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":614
- *             start = min(self.start, self.end)
- *             end = max(self.start, self.end)
- *             self.start, self.end = lcontig - end, lcontig - start             # <<<<<<<<<<<<<<
- * 
- *     def keys( self ):
- */
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_lcontig); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_6 = PyNumber_Subtract(__pyx_t_5, __pyx_v_end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_3 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_3 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_6 = PyInt_FromLong(__pyx_v_lcontig); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_v_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_4 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_5); if (unlikely((__pyx_t_4 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->start = __pyx_t_3;
-    ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->end = __pyx_t_4;
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_6);
-  __Pyx_AddTraceback("ctabix.GTFProxy.invert");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_start);
-  __Pyx_DECREF(__pyx_v_end);
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":616
- *             self.start, self.end = lcontig - end, lcontig - start
- * 
- *     def keys( self ):             # <<<<<<<<<<<<<<
- *         '''return a list of attributes defined in this entry.'''
- *         r = self.attributes
- */
-
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy_keys[] = "GTFProxy.keys(self)\nreturn a list of attributes defined in this entry.";
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  char *__pyx_v_r;
-  PyObject *__pyx_v_x;
+static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  char *__pyx_v_buffer;
+  int __pyx_v_len;
+  struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_r;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
-  Py_ssize_t __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  int __pyx_t_6;
-  PyObject *__pyx_t_7 = NULL;
-  __Pyx_RefNannySetupContext("keys");
-  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":618
- *     def keys( self ):
- *         '''return a list of attributes defined in this entry.'''
- *         r = self.attributes             # <<<<<<<<<<<<<<
- *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
- * 
- */
-  __pyx_v_r = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":619
- *         '''return a list of attributes defined in this entry.'''
- *         r = self.attributes
- *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]             # <<<<<<<<<<<<<<
- * 
- *     def __getitem__(self, item):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_3 = PyBytes_FromString(__pyx_v_r); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __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 = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_19));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
-  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
-    __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_5; __Pyx_INCREF(__pyx_t_3);
-  } else {
-    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-  }
-  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_3))) {
-      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
-      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
-      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
-      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
-    } else {
-      __pyx_t_5 = PyIter_Next(__pyx_t_3);
-      if (!__pyx_t_5) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        break;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
+  __Pyx_RefNannySetupContext("__call__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
-      __Pyx_GOTREF(__pyx_t_5);
     }
-    __Pyx_DECREF(__pyx_v_x);
-    __pyx_v_x = __pyx_t_5;
-    __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, ((PyObject *)__pyx_kp_s_26), Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    if (__pyx_t_6) {
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __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 = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
-      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_20));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
-      __pyx_t_7 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_7, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      goto __pyx_L7;
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_L7:;
+    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_INCREF(((PyObject *)__pyx_t_1));
-  __pyx_r = ((PyObject *)__pyx_t_1);
-  __Pyx_DECREF(((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_XDECREF(__pyx_t_3);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_5);
-  __Pyx_XDECREF(__pyx_t_7);
-  __Pyx_AddTraceback("ctabix.GTFProxy.keys");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_x);
-  __Pyx_XGIVEREF(__pyx_r);
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("ctabix.asTuple.__call__");
   __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)Py_None); __Pyx_INCREF(Py_None);
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":621
- *         return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
- * 
- *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
- *         return self.__getattr__( item )
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":271
+ *     def __call__(self, char * buffer, int len):
+ *         cdef TabProxies.TupleProxy r
+ *         r = TabProxies.TupleProxy()             # <<<<<<<<<<<<<<
+ *         # need to copy - there were some
+ *         # persistence issues with "present"
  */
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_v_r));
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_t_1);
+  __pyx_t_1 = 0;
 
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  __Pyx_RefNannySetupContext("__getitem__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":622
- * 
- *     def __getitem__(self, item):
- *         return self.__getattr__( item )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":274
+ *         # need to copy - there were some
+ *         # persistence issues with "present"
+ *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
+ *         return r
  * 
- *     def __dealloc__(self):
  */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_r->__pyx_vtab)->copy(__pyx_v_r, __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_INCREF(__pyx_v_item);
-  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_item);
-  __Pyx_GIVEREF(__pyx_v_item);
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __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_2); __pyx_t_2 = 0;
-  __pyx_r = __pyx_t_3;
-  __pyx_t_3 = 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_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("ctabix.GTFProxy.__getitem__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":624
- *         return self.__getattr__( item )
- * 
- *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         if self.data != NULL:
- *             free(self.data)
- */
-
-static void __pyx_pf_6ctabix_8GTFProxy___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_6ctabix_8GTFProxy___dealloc__(PyObject *__pyx_v_self) {
-  int __pyx_t_1;
-  __Pyx_RefNannySetupContext("__dealloc__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":625
- * 
- *     def __dealloc__(self):
- *         if self.data != NULL:             # <<<<<<<<<<<<<<
- *             free(self.data)
- *         if self.hasOwnAttributes:
- */
-  __pyx_t_1 = (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->data != NULL);
-  if (__pyx_t_1) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":626
- *     def __dealloc__(self):
- *         if self.data != NULL:
- *             free(self.data)             # <<<<<<<<<<<<<<
- *         if self.hasOwnAttributes:
- *             free(self.attributes)
- */
-    free(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->data);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":627
- *         if self.data != NULL:
- *             free(self.data)
- *         if self.hasOwnAttributes:             # <<<<<<<<<<<<<<
- *             free(self.attributes)
- * 
- */
-  if (((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->hasOwnAttributes) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":628
- *             free(self.data)
- *         if self.hasOwnAttributes:
- *             free(self.attributes)             # <<<<<<<<<<<<<<
- * 
- *     def __getattr__(self, item ):
- */
-    free(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes);
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  __Pyx_RefNannyFinishContext();
-}
-
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":630
- *             free(self.attributes)
- * 
- *     def __getattr__(self, item ):             # <<<<<<<<<<<<<<
- *         """Generic lookup of attribute from GFF/GTF attributes
- *         Only called if there *isn't* an attribute with this name
- */
 
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy___getattr__[] = "Generic lookup of attribute from GFF/GTF attributes \n        Only called if there *isn't* an attribute with this name\n        ";
-struct wrapperbase __pyx_wrapperbase_6ctabix_8GTFProxy___getattr__;
-static PyObject *__pyx_pf_6ctabix_8GTFProxy___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
-  char *__pyx_v_start;
-  char *__pyx_v_query;
-  char *__pyx_v_cpy;
-  char *__pyx_v_end;
-  int __pyx_v_l;
-  char *__pyx_v_result;
-  PyObject *__pyx_r = NULL;
-  char *__pyx_t_1;
-  int __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  int __pyx_t_5;
-  int __pyx_t_6;
-  __Pyx_RefNannySetupContext("__getattr__");
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":639
- *         cdef char * end
- *         cdef int l
- *         query = item             # <<<<<<<<<<<<<<
- * 
- *         start = strstr( self.attributes, query)
- */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_item); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_query = __pyx_t_1;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":641
- *         query = item
- * 
- *         start = strstr( self.attributes, query)             # <<<<<<<<<<<<<<
- *         if start == NULL:
- *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
- */
-  __pyx_v_start = strstr(((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_v_self)->attributes, __pyx_v_query);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":642
- * 
- *         start = strstr( self.attributes, query)
- *         if start == NULL:             # <<<<<<<<<<<<<<
- *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
- * 
- */
-  __pyx_t_2 = (__pyx_v_start == NULL);
-  if (__pyx_t_2) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":643
- *         start = strstr( self.attributes, query)
- *         if start == NULL:
- *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )             # <<<<<<<<<<<<<<
- * 
- *         start += strlen(query) + 1
- */
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_v_item); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __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_AttributeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_Raise(__pyx_t_3, 0, 0);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":645
- *             raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
- * 
- *         start += strlen(query) + 1             # <<<<<<<<<<<<<<
- *         # skip gaps before
- *         while start[0] == " ": start += 1
- */
-  __pyx_v_start += (strlen(__pyx_v_query) + 1);
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":647
- *         start += strlen(query) + 1
- *         # skip gaps before
- *         while start[0] == " ": start += 1             # <<<<<<<<<<<<<<
- *         if start[0] == '"':
- *             start += 1
- */
-  while (1) {
-    __pyx_t_2 = ((__pyx_v_start[0]) == ' ');
-    if (!__pyx_t_2) break;
-    __pyx_v_start += 1;
-  }
-
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":648
- *         # skip gaps before
- *         while start[0] == " ": start += 1
- *         if start[0] == '"':             # <<<<<<<<<<<<<<
- *             start += 1
- *             end = start
- */
-  __pyx_t_2 = ((__pyx_v_start[0]) == '"');
-  if (__pyx_t_2) {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":649
- *         while start[0] == " ": start += 1
- *         if start[0] == '"':
- *             start += 1             # <<<<<<<<<<<<<<
- *             end = start
- *             while end[0] != '\0' and end[0] != '"': end += 1
- */
-    __pyx_v_start += 1;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":650
- *         if start[0] == '"':
- *             start += 1
- *             end = start             # <<<<<<<<<<<<<<
- *             while end[0] != '\0' and end[0] != '"': end += 1
- *             l = end - start + 1
- */
-    __pyx_v_end = __pyx_v_start;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":651
- *             start += 1
- *             end = start
- *             while end[0] != '\0' and end[0] != '"': end += 1             # <<<<<<<<<<<<<<
- *             l = end - start + 1
- *             cpy = <char*>calloc( l, sizeof(char ) )
- */
-    while (1) {
-      __pyx_t_2 = ((__pyx_v_end[0]) != '\x00');
-      if (__pyx_t_2) {
-        __pyx_t_5 = ((__pyx_v_end[0]) != '"');
-        __pyx_t_6 = __pyx_t_5;
-      } else {
-        __pyx_t_6 = __pyx_t_2;
-      }
-      if (!__pyx_t_6) break;
-      __pyx_v_end += 1;
-    }
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":652
- *             end = start
- *             while end[0] != '\0' and end[0] != '"': end += 1
- *             l = end - start + 1             # <<<<<<<<<<<<<<
- *             cpy = <char*>calloc( l, sizeof(char ) )
- *             memcpy( cpy, start, l )
- */
-    __pyx_v_l = ((__pyx_v_end - __pyx_v_start) + 1);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":653
- *             while end[0] != '\0' and end[0] != '"': end += 1
- *             l = end - start + 1
- *             cpy = <char*>calloc( l, sizeof(char ) )             # <<<<<<<<<<<<<<
- *             memcpy( cpy, start, l )
- *             cpy[l-1] = '\0'
- */
-    __pyx_v_cpy = ((char *)calloc(__pyx_v_l, (sizeof(char))));
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":654
- *             l = end - start + 1
- *             cpy = <char*>calloc( l, sizeof(char ) )
- *             memcpy( cpy, start, l )             # <<<<<<<<<<<<<<
- *             cpy[l-1] = '\0'
- *             result = cpy
- */
-    memcpy(__pyx_v_cpy, __pyx_v_start, __pyx_v_l);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":655
- *             cpy = <char*>calloc( l, sizeof(char ) )
- *             memcpy( cpy, start, l )
- *             cpy[l-1] = '\0'             # <<<<<<<<<<<<<<
- *             result = cpy
- *             free(cpy)
- */
-    (__pyx_v_cpy[(__pyx_v_l - 1)]) = '\x00';
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":656
- *             memcpy( cpy, start, l )
- *             cpy[l-1] = '\0'
- *             result = cpy             # <<<<<<<<<<<<<<
- *             free(cpy)
- *             return result
- */
-    __pyx_v_result = __pyx_v_cpy;
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":657
- *             cpy[l-1] = '\0'
- *             result = cpy
- *             free(cpy)             # <<<<<<<<<<<<<<
- *             return result
- *         else:
- */
-    free(__pyx_v_cpy);
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":658
- *             result = cpy
- *             free(cpy)
- *             return result             # <<<<<<<<<<<<<<
- *         else:
- *             return start
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_r = ((PyObject *)__pyx_t_3);
-    __pyx_t_3 = 0;
-    goto __pyx_L0;
-    goto __pyx_L8;
-  }
-  /*else*/ {
-
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":660
- *             return result
- *         else:
- *             return start             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":275
+ *         # persistence issues with "present"
+ *         r.copy( buffer, len )
+ *         return r             # <<<<<<<<<<<<<<
  * 
- *     def setAttribute( self, name, value ):
+ * cdef class asGTF(Parser):
  */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_r = ((PyObject *)__pyx_t_3);
-    __pyx_t_3 = 0;
-    goto __pyx_L0;
-  }
-  __pyx_L8:;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_r));
+  __pyx_r = ((PyObject *)__pyx_v_r);
+  goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_AddTraceback("ctabix.GTFProxy.__getattr__");
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("ctabix.asTuple.__call__");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_r);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":662
- *             return start
- * 
- *     def setAttribute( self, name, value ):             # <<<<<<<<<<<<<<
- *         '''convenience method to set an attribute.'''
- *         r = self.asDict()
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":279
+ * cdef class asGTF(Parser):
+ *     '''converts a :term:`tabix row` into a GTF record.'''
+ *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
+ *         cdef TabProxies.GTFProxy r
+ *         r = TabProxies.GTFProxy()
  */
 
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_setAttribute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_6ctabix_8GTFProxy_setAttribute[] = "GTFProxy.setAttribute(self, name, value)\nconvenience method to set an attribute.";
-static PyObject *__pyx_pf_6ctabix_8GTFProxy_setAttribute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_name = 0;
-  PyObject *__pyx_v_value = 0;
-  PyObject *__pyx_v_r;
+static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  char *__pyx_v_buffer;
+  int __pyx_v_len;
+  struct __pyx_obj_10TabProxies_GTFProxy *__pyx_v_r;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__value,0};
-  __Pyx_RefNannySetupContext("setAttribute");
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
+  __Pyx_RefNannySetupContext("__call__");
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -7243,110 +3595,99 @@ static PyObject *__pyx_pf_6ctabix_8GTFProxy_setAttribute(PyObject *__pyx_v_self,
     }
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
       if (likely(values[0])) kw_args--;
       else goto __pyx_L5_argtuple_error;
       case  1:
-      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setAttribute", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setAttribute") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_name = values[0];
-    __pyx_v_value = values[1];
+    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 0);
-    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setAttribute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("ctabix.GTFProxy.setAttribute");
+  __Pyx_AddTraceback("ctabix.asGTF.__call__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":664
- *     def setAttribute( self, name, value ):
- *         '''convenience method to set an attribute.'''
- *         r = self.asDict()             # <<<<<<<<<<<<<<
- *         r[name] = value
- *         self.fromDict( r )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":281
+ *     def __call__(self, char * buffer, int len):
+ *         cdef TabProxies.GTFProxy r
+ *         r = TabProxies.GTFProxy()             # <<<<<<<<<<<<<<
+ *         r.copy( buffer, len )
+ *         return r
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__asDict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_GTFProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __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 = 664; __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_r);
-  __pyx_v_r = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_v_r));
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_t_1);
+  __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":665
- *         '''convenience method to set an attribute.'''
- *         r = self.asDict()
- *         r[name] = value             # <<<<<<<<<<<<<<
- *         self.fromDict( r )
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":282
+ *         cdef TabProxies.GTFProxy r
+ *         r = TabProxies.GTFProxy()
+ *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
+ *         return r
  * 
  */
-  if (PyObject_SetItem(__pyx_v_r, __pyx_v_name, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_GTFProxy *)__pyx_v_r->__pyx_base.__pyx_vtab)->__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":666
- *         r = self.asDict()
- *         r[name] = value
- *         self.fromDict( r )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":283
+ *         r = TabProxies.GTFProxy()
+ *         r.copy( buffer, len )
+ *         return r             # <<<<<<<<<<<<<<
  * 
- * cdef class Parser:
+ * cdef class asBed( Parser ):
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__fromDict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __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 = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_INCREF(__pyx_v_r);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_r);
-  __Pyx_GIVEREF(__pyx_v_r);
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __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_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_r));
+  __pyx_r = ((PyObject *)__pyx_v_r);
+  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_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("ctabix.GTFProxy.setAttribute");
+  __Pyx_AddTraceback("ctabix.asGTF.__call__");
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_r);
+  __Pyx_DECREF((PyObject *)__pyx_v_r);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":673
- * cdef class asTuple(Parser):
- *     '''converts a :term:`tabix row` into a python tuple.'''
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":287
+ * cdef class asBed( Parser ):
+ *     '''converts a :term:`tabix row` into a GTF record.'''
  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
- *         cdef TupleProxy r
- *         r = TupleProxy()
+ *         cdef TabProxies.BedProxy r
+ *         r = TabProxies.BedProxy()
  */
 
-static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_6ctabix_5asBed___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_6ctabix_5asBed___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   char *__pyx_v_buffer;
   int __pyx_v_len;
-  struct __pyx_obj_6ctabix_TupleProxy *__pyx_v_r;
+  struct __pyx_obj_10TabProxies_BedProxy *__pyx_v_r;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
@@ -7369,60 +3710,60 @@ static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyOb
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("ctabix.asTuple.__call__");
+  __Pyx_AddTraceback("ctabix.asBed.__call__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_r = ((struct __pyx_obj_6ctabix_TupleProxy *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":675
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":289
  *     def __call__(self, char * buffer, int len):
- *         cdef TupleProxy r
- *         r = TupleProxy()             # <<<<<<<<<<<<<<
- *         # need to copy - there were some
- *         # persistence issues with "present"
+ *         cdef TabProxies.BedProxy r
+ *         r = TabProxies.BedProxy()             # <<<<<<<<<<<<<<
+ *         r.copy( buffer, len )
+ *         return r
  */
-  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TupleProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_BedProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_v_r));
-  __pyx_v_r = ((struct __pyx_obj_6ctabix_TupleProxy *)__pyx_t_1);
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":678
- *         # need to copy - there were some
- *         # persistence issues with "present"
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":290
+ *         cdef TabProxies.BedProxy r
+ *         r = TabProxies.BedProxy()
  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
  *         return r
  * 
  */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_TupleProxy *)__pyx_v_r->__pyx_vtab)->copy(__pyx_v_r, __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_BedProxy *)__pyx_v_r->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":679
- *         # persistence issues with "present"
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":291
+ *         r = TabProxies.BedProxy()
  *         r.copy( buffer, len )
  *         return r             # <<<<<<<<<<<<<<
  * 
- * cdef class asGTF(Parser):
+ * cdef class asVCF( Parser ):
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_r));
@@ -7433,7 +3774,7 @@ static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyOb
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.asTuple.__call__");
+  __Pyx_AddTraceback("ctabix.asBed.__call__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_DECREF((PyObject *)__pyx_v_r);
@@ -7442,19 +3783,19 @@ static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":683
- * cdef class asGTF(Parser):
- *     '''converts a :term:`tabix row` into a GTF record.'''
- *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
- *         cdef GTFProxy r
- *         r = GTFProxy()
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":295
+ * cdef class asVCF( Parser ):
+ *     '''converts a :term:`tabix row` into a VCF record.'''
+ *     def __call__(self, char * buffer, int len ):             # <<<<<<<<<<<<<<
+ *         cdef TabProxies.VCFProxy r
+ *         r = TabProxies.VCFProxy()
  */
 
-static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_6ctabix_5asVCF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_6ctabix_5asVCF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   char *__pyx_v_buffer;
   int __pyx_v_len;
-  struct __pyx_obj_6ctabix_GTFProxy *__pyx_v_r;
+  struct __pyx_obj_10TabProxies_VCFProxy *__pyx_v_r;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
@@ -7477,60 +3818,60 @@ static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObje
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("ctabix.asGTF.__call__");
+  __Pyx_AddTraceback("ctabix.asVCF.__call__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_r = ((struct __pyx_obj_6ctabix_GTFProxy *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":685
- *     def __call__(self, char * buffer, int len):
- *         cdef GTFProxy r
- *         r = GTFProxy()             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":297
+ *     def __call__(self, char * buffer, int len ):
+ *         cdef TabProxies.VCFProxy r
+ *         r = TabProxies.VCFProxy()             # <<<<<<<<<<<<<<
  *         r.copy( buffer, len )
  *         return r
  */
-  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_GTFProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_VCFProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_v_r));
-  __pyx_v_r = ((struct __pyx_obj_6ctabix_GTFProxy *)__pyx_t_1);
+  __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":686
- *         cdef GTFProxy r
- *         r = GTFProxy()
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":298
+ *         cdef TabProxies.VCFProxy r
+ *         r = TabProxies.VCFProxy()
  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
  *         return r
  * 
  */
-  __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_GTFProxy *)__pyx_v_r->__pyx_vtab)->copy(__pyx_v_r, __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_VCFProxy *)__pyx_v_r->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":687
- *         r = GTFProxy()
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":299
+ *         r = TabProxies.VCFProxy()
  *         r.copy( buffer, len )
  *         return r             # <<<<<<<<<<<<<<
  * 
- * cdef class TabixIteratorParsed:
+ * #########################################################
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_r));
@@ -7541,7 +3882,7 @@ static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObje
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("ctabix.asGTF.__call__");
+  __Pyx_AddTraceback("ctabix.asVCF.__call__");
   __pyx_r = NULL;
   __pyx_L0:;
   __Pyx_DECREF((PyObject *)__pyx_v_r);
@@ -7550,7 +3891,7 @@ static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObje
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":697
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":314
  *     cdef Parser parser
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -7592,56 +3933,56 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  3:
       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
       if (likely(values[3])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  4:
       values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser);
       if (likely(values[4])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)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 = 699; __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 = 700; __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 = 701; __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 = 316; __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 = 317; __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 = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)values[4]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
     goto __pyx_L5_argtuple_error;
   } else {
     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
-    __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)PyTuple_GET_ITEM(__pyx_args, 4));
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_6ctabix_Parser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_6ctabix_Parser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":704
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":321
  *                   Parser parser ):
  * 
  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
@@ -7649,20 +3990,20 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
  * 
  */
   #ifndef PYREX_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __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 = 704; __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 = 321; __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 = 704; __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 = 321; __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 = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":705
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":322
  * 
  *         assert tabixfile._isOpen()
  *         self.parser = parser             # <<<<<<<<<<<<<<
@@ -7675,7 +4016,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser));
   ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser = __pyx_v_parser;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":709
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":326
  *         # makes sure that samfile stays alive as long as the
  *         # iterator is alive.
  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
@@ -7684,7 +4025,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
  */
   ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":711
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":328
  *         self.tabixfile = tabixfile.tabixfile
  * 
  *         if tid < 0:             # <<<<<<<<<<<<<<
@@ -7694,7 +4035,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   __pyx_t_3 = (__pyx_v_tid < 0);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":714
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":331
  *             # seek to start of file to ensure iteration is over
  *             # all entries.
  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
@@ -7703,7 +4044,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
  */
     bgzf_seek(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile->fp, 0, 0);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":715
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":332
  *             # all entries.
  *             bgzf_seek( self.tabixfile.fp, 0, 0)
  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
@@ -7715,7 +4056,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":717
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":334
  *             self.iterator = ti_iter_first()
  *         else:
  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
@@ -7726,7 +4067,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":719
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":336
  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
  * 
  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
@@ -7736,24 +4077,24 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) == NULL);
   if (__pyx_t_3) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":720
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":337
  * 
  *         if <void*>self.iterator == NULL:
  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
  * 
  *     def __iter__(self):
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __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 = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_12));
     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
@@ -7770,7 +4111,7 @@ static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":722
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":339
  *             raise ValueError("malformatted query or wrong sequence name.\n")
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -7783,7 +4124,7 @@ static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx
   PyObject *__pyx_r = NULL;
   __Pyx_RefNannySetupContext("__iter__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":723
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":340
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -7802,7 +4143,7 @@ static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":725
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":342
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -7823,43 +4164,69 @@ static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx
   PyObject *__pyx_t_4 = NULL;
   __Pyx_RefNannySetupContext("__next__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":733
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":350
  *         cdef char * s
  *         cdef int len
- *         s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
- *         if s == NULL: raise StopIteration
- *         return self.parser(s, len)
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             s = ti_read(self.tabixfile, self.iterator, &len)
+ *             if s == NULL: raise StopIteration
  */
-  __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator, (&__pyx_v_len));
+  while (1) {
+    if (!1) break;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":734
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":351
  *         cdef int len
- *         s = ti_read(self.tabixfile, self.iterator, &len)
- *         if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
- *         return self.parser(s, len)
+ *         while 1:
+ *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
+ *             if s == NULL: raise StopIteration
+ *             # todo: read metachar from configuration
+ */
+    __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator, (&__pyx_v_len));
+
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":352
+ *         while 1:
+ *             s = ti_read(self.tabixfile, self.iterator, &len)
+ *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
+ *             # todo: read metachar from configuration
+ *             if s[0] != '#': break
+ */
+    __pyx_t_1 = (__pyx_v_s == NULL);
+    if (__pyx_t_1) {
+      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":354
+ *             if s == NULL: raise StopIteration
+ *             # todo: read metachar from configuration
+ *             if s[0] != '#': break             # <<<<<<<<<<<<<<
  * 
+ *         return self.parser(s, len)
  */
-  __pyx_t_1 = (__pyx_v_s == NULL);
-  if (__pyx_t_1) {
-    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
+    __pyx_t_1 = ((__pyx_v_s[0]) != '#');
+    if (__pyx_t_1) {
+      goto __pyx_L6_break;
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
   }
-  __pyx_L5:;
+  __pyx_L6_break:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":735
- *         s = ti_read(self.tabixfile, self.iterator, &len)
- *         if s == NULL: raise StopIteration
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":356
+ *             if s[0] != '#': break
+ * 
  *         return self.parser(s, len)             # <<<<<<<<<<<<<<
  * 
  *     def __dealloc__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __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 = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
@@ -7867,7 +4234,7 @@ static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __pyx_r = __pyx_t_3;
@@ -7888,7 +4255,7 @@ static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":737
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":358
  *         return self.parser(s, len)
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -7901,7 +4268,7 @@ static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("__dealloc__");
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":738
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":359
  * 
  *     def __dealloc__(self):
  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
@@ -7911,7 +4278,7 @@ static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v
   __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) != NULL);
   if (__pyx_t_1) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":739
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":360
  *     def __dealloc__(self):
  *         if <void*>self.iterator != NULL:
  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
@@ -7926,7 +4293,7 @@ static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v
   __Pyx_RefNannyFinishContext();
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":741
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":362
  *             ti_iter_destroy(self.iterator)
  * 
  * def tabix_compress( filename_in,             # <<<<<<<<<<<<<<
@@ -7962,7 +4329,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
-    values[2] = __pyx_k_28;
+    values[2] = __pyx_k_14;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
@@ -7979,7 +4346,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename_out);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       if (kw_args > 0) {
@@ -7988,13 +4355,13 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_compress") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_compress") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_filename_in = values[0];
     __pyx_v_filename_out = values[1];
     __pyx_v_force = values[2];
   } else {
-    __pyx_v_force = __pyx_k_28;
+    __pyx_v_force = __pyx_k_14;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  3:
       __pyx_v_force = PyTuple_GET_ITEM(__pyx_args, 2);
@@ -8007,41 +4374,41 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.tabix_compress");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":751
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":372
  *     '''
  * 
  *     if not force and os.path.exists(filename_out ):             # <<<<<<<<<<<<<<
  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)
  * 
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_2 = (!__pyx_t_1);
   if (__pyx_t_2) {
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__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 = 751; __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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_INCREF(__pyx_v_filename_out);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename_out);
     __Pyx_GIVEREF(__pyx_v_filename_out);
-    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, 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_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_6 = __pyx_t_1;
   } else {
@@ -8049,47 +4416,47 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   }
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":752
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":373
  * 
  *     if not force and os.path.exists(filename_out ):
  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)             # <<<<<<<<<<<<<<
  * 
  *     cdef int WINDOW_SIZE
  */
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), __pyx_v_filename_out); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), __pyx_v_filename_out); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __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 = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
     __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":761
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":382
  * 
  *     cdef int O_RDONLY
  *     O_RDONLY = os.O_RDONLY             # <<<<<<<<<<<<<<
  * 
  *     WINDOW_SIZE = 64 * 1024
  */
-  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__O_RDONLY); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__O_RDONLY); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __pyx_v_O_RDONLY = __pyx_t_7;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":763
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":384
  *     O_RDONLY = os.O_RDONLY
  * 
  *     WINDOW_SIZE = 64 * 1024             # <<<<<<<<<<<<<<
@@ -8098,17 +4465,17 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
   __pyx_v_WINDOW_SIZE = 65536;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":765
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":386
  *     WINDOW_SIZE = 64 * 1024
  * 
  *     fp = bgzf_open( filename_out, "w")             # <<<<<<<<<<<<<<
  *     if fp == NULL:
  *         raise IOError( "could not open '%s' for writing" )
  */
-  __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_out); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_out); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_fp = bgzf_open(__pyx_t_8, __pyx_k__w);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":766
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":387
  * 
  *     fp = bgzf_open( filename_out, "w")
  *     if fp == NULL:             # <<<<<<<<<<<<<<
@@ -8118,39 +4485,39 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   __pyx_t_6 = (__pyx_v_fp == NULL);
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":767
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":388
  *     fp = bgzf_open( filename_out, "w")
  *     if fp == NULL:
  *         raise IOError( "could not open '%s' for writing" )             # <<<<<<<<<<<<<<
  * 
  *     fd_src = open(filename_in, O_RDONLY)
  */
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
-    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_30));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_16));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":769
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":390
  *         raise IOError( "could not open '%s' for writing" )
  * 
  *     fd_src = open(filename_in, O_RDONLY)             # <<<<<<<<<<<<<<
  *     if fd_src == 0:
  *         raise IOError( "could not open '%s' for reading" )
  */
-  __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_in); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_in); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_fd_src = open(__pyx_t_8, __pyx_v_O_RDONLY);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":770
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":391
  * 
  *     fd_src = open(filename_in, O_RDONLY)
  *     if fd_src == 0:             # <<<<<<<<<<<<<<
@@ -8160,29 +4527,29 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   __pyx_t_6 = (__pyx_v_fd_src == 0);
   if (__pyx_t_6) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":771
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":392
  *     fd_src = open(filename_in, O_RDONLY)
  *     if fd_src == 0:
  *         raise IOError( "could not open '%s' for reading" )             # <<<<<<<<<<<<<<
  * 
  *     buffer = malloc(WINDOW_SIZE)
  */
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __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 = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_17));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L8;
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":773
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":394
  *         raise IOError( "could not open '%s' for reading" )
  * 
  *     buffer = malloc(WINDOW_SIZE)             # <<<<<<<<<<<<<<
@@ -8191,7 +4558,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
   __pyx_v_buffer = malloc(__pyx_v_WINDOW_SIZE);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":775
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":396
  *     buffer = malloc(WINDOW_SIZE)
  * 
  *     while c > 0:             # <<<<<<<<<<<<<<
@@ -8202,7 +4569,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
     __pyx_t_6 = (__pyx_v_c > 0);
     if (!__pyx_t_6) break;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":776
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":397
  * 
  *     while c > 0:
  *         c = read(fd_src, buffer, WINDOW_SIZE)             # <<<<<<<<<<<<<<
@@ -8211,7 +4578,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
     __pyx_v_c = read(__pyx_v_fd_src, __pyx_v_buffer, __pyx_v_WINDOW_SIZE);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":777
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":398
  *     while c > 0:
  *         c = read(fd_src, buffer, WINDOW_SIZE)
  *         r = bgzf_write(fp, buffer, c)             # <<<<<<<<<<<<<<
@@ -8220,7 +4587,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
     __pyx_v_r = bgzf_write(__pyx_v_fp, __pyx_v_buffer, __pyx_v_c);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":778
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":399
  *         c = read(fd_src, buffer, WINDOW_SIZE)
  *         r = bgzf_write(fp, buffer, c)
  *         if r < 0:             # <<<<<<<<<<<<<<
@@ -8230,7 +4597,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
     __pyx_t_6 = (__pyx_v_r < 0);
     if (__pyx_t_6) {
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":779
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":400
  *         r = bgzf_write(fp, buffer, c)
  *         if r < 0:
  *             free( buffer )             # <<<<<<<<<<<<<<
@@ -8239,30 +4606,30 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
       free(__pyx_v_buffer);
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":780
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":401
  *         if r < 0:
  *             free( buffer )
  *             raise OSError("writing failed")             # <<<<<<<<<<<<<<
  * 
  *     free( buffer )
  */
-      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __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 = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
-      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_32));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_18));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L11;
     }
     __pyx_L11:;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":782
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":403
  *             raise OSError("writing failed")
  * 
  *     free( buffer )             # <<<<<<<<<<<<<<
@@ -8271,7 +4638,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
   free(__pyx_v_buffer);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":783
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":404
  * 
  *     free( buffer )
  *     r = bgzf_close(fp)             # <<<<<<<<<<<<<<
@@ -8280,7 +4647,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
   __pyx_v_r = bgzf_close(__pyx_v_fp);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":784
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":405
  *     free( buffer )
  *     r = bgzf_close(fp)
  *     if r < 0: raise OSError("writing failed")             # <<<<<<<<<<<<<<
@@ -8289,17 +4656,17 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
  */
   __pyx_t_6 = (__pyx_v_r < 0);
   if (__pyx_t_6) {
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __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 = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_18));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L12;
   }
   __pyx_L12:;
@@ -8318,7 +4685,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject
   return __pyx_r;
 }
 
-/* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":786
+/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":407
  *     if r < 0: raise OSError("writing failed")
  * 
  * def tabix_index( filename,             # <<<<<<<<<<<<<<
@@ -8365,9 +4732,9 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[8] = {0,0,0,0,0,0,0,0};
-    values[1] = __pyx_k_33;
+    values[1] = __pyx_k_19;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":788
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409
  * def tabix_index( filename,
  *                  force = False,
  *                  seq_col = None,             # <<<<<<<<<<<<<<
@@ -8376,7 +4743,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":789
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410
  *                  force = False,
  *                  seq_col = None,
  *                  start_col = None,             # <<<<<<<<<<<<<<
@@ -8385,7 +4752,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":790
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411
  *                  seq_col = None,
  *                  start_col = None,
  *                  end_col = None,             # <<<<<<<<<<<<<<
@@ -8394,7 +4761,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     values[4] = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":791
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412
  *                  start_col = None,
  *                  end_col = None,
  *                  preset = None,             # <<<<<<<<<<<<<<
@@ -8402,8 +4769,8 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  *                  zerobased = False,
  */
     values[5] = ((PyObject *)Py_None);
-    values[6] = ((PyObject *)__pyx_kp_s_34);
-    values[7] = __pyx_k_35;
+    values[6] = ((PyObject *)__pyx_kp_s_20);
+    values[7] = __pyx_k_21;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
       case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
@@ -8458,7 +4825,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_filename = values[0];
     __pyx_v_force = values[1];
@@ -8469,9 +4836,9 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     __pyx_v_meta_char = values[6];
     __pyx_v_zerobased = values[7];
   } else {
-    __pyx_v_force = __pyx_k_33;
+    __pyx_v_force = __pyx_k_19;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":788
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409
  * def tabix_index( filename,
  *                  force = False,
  *                  seq_col = None,             # <<<<<<<<<<<<<<
@@ -8480,7 +4847,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     __pyx_v_seq_col = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":789
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410
  *                  force = False,
  *                  seq_col = None,
  *                  start_col = None,             # <<<<<<<<<<<<<<
@@ -8489,7 +4856,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     __pyx_v_start_col = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":790
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411
  *                  seq_col = None,
  *                  start_col = None,
  *                  end_col = None,             # <<<<<<<<<<<<<<
@@ -8498,7 +4865,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  */
     __pyx_v_end_col = ((PyObject *)Py_None);
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":791
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412
  *                  start_col = None,
  *                  end_col = None,
  *                  preset = None,             # <<<<<<<<<<<<<<
@@ -8506,8 +4873,8 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
  *                  zerobased = False,
  */
     __pyx_v_preset = ((PyObject *)Py_None);
-    __pyx_v_meta_char = ((PyObject *)__pyx_kp_s_34);
-    __pyx_v_zerobased = __pyx_k_35;
+    __pyx_v_meta_char = ((PyObject *)__pyx_kp_s_20);
+    __pyx_v_zerobased = __pyx_k_21;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  8: __pyx_v_zerobased = PyTuple_GET_ITEM(__pyx_args, 7);
       case  7: __pyx_v_meta_char = PyTuple_GET_ITEM(__pyx_args, 6);
@@ -8523,7 +4890,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("tabix_index", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("tabix_index", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("ctabix.tabix_index");
   __Pyx_RefNannyFinishContext();
@@ -8535,86 +4902,86 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   __pyx_v_preset2conf = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_conf_data = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":828
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":449
  *     '''
  * 
  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)             # <<<<<<<<<<<<<<
  * 
  *     if not filename.endswith(".gz"):
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __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 = 449; __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 = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __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 = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __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 = 828; __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 = 449; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __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_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 = 828; __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 = 449; __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) {
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __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 = 828; __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 = 449; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":830
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":451
  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)
  * 
  *     if not filename.endswith(".gz"):             # <<<<<<<<<<<<<<
  * 
  *         tabix_compress( filename, filename + ".gz", force = force )
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__endswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__endswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __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 = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_37));
-  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_37));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_37));
-  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_23));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __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_2); __pyx_t_2 = 0;
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __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 = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_4 = (!__pyx_t_5);
   if (__pyx_t_4) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":832
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":453
  *     if not filename.endswith(".gz"):
  * 
  *         tabix_compress( filename, filename + ".gz", force = force )             # <<<<<<<<<<<<<<
  *         os.unlink( filename )
  *         filename += ".gz"
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_37)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_23)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __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 = 832; __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 = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_filename);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filename);
@@ -8622,47 +4989,47 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     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 = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__force), __pyx_v_force) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__force), __pyx_v_force) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":833
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":454
  * 
  *         tabix_compress( filename, filename + ".gz", force = force )
  *         os.unlink( filename )             # <<<<<<<<<<<<<<
  *         filename += ".gz"
  * 
  */
-    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unlink); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unlink); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__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 = 833; __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 = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_INCREF(__pyx_v_filename);
     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_filename);
     __Pyx_GIVEREF(__pyx_v_filename);
-    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __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_6); __pyx_t_6 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":834
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":455
  *         tabix_compress( filename, filename + ".gz", force = force )
  *         os.unlink( filename )
  *         filename += ".gz"             # <<<<<<<<<<<<<<
  * 
  *     if not force and os.path.exists(filename + ".tbi" ):
  */
-    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_filename, ((PyObject *)__pyx_kp_s_37)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_filename, ((PyObject *)__pyx_kp_s_23)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_v_filename);
     __pyx_v_filename = __pyx_t_3;
@@ -8671,36 +5038,36 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   }
   __pyx_L7:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":836
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":457
  *         filename += ".gz"
  * 
  *     if not force and os.path.exists(filename + ".tbi" ):             # <<<<<<<<<<<<<<
  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )
  * 
  */
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_5 = (!__pyx_t_4);
   if (__pyx_t_5) {
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __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 = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_6 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __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 = 457; __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_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = __pyx_t_4;
   } else {
@@ -8708,54 +5075,54 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   }
   if (__pyx_t_7) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":837
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":458
  * 
  *     if not force and os.path.exists(filename + ".tbi" ):
  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )             # <<<<<<<<<<<<<<
  * 
  *     # columns (1-based)
  */
-    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __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 = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
-    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_38));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
+    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_24));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L8;
   }
   __pyx_L8:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":842
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":463
  *     # preset-code, contig, start, end, metachar for commends, lines to ignore at beginning
  *     # 0 is a missing column
  *     preset2conf = {             # <<<<<<<<<<<<<<
  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":843
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":464
  *     # 0 is a missing column
  *     preset2conf = {
  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __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 = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_0);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
@@ -8775,25 +5142,25 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__gff), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__gff), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":844
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":465
  *     preset2conf = {
  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __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 = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_0x10000);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0x10000);
@@ -8813,25 +5180,25 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__bed), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__bed), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":845
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":466
  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __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 = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_0x10000);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0x10000);
@@ -8851,25 +5218,25 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__psltbl), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__psltbl), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":846
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":467
  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __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 = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_1);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
@@ -8889,25 +5256,25 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sam), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sam), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":847
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":468
  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
  *         }
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __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 = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_2);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
@@ -8927,25 +5294,25 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vcf), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vcf), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":848
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":469
  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
  *         }
  * 
  */
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __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 = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
-  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_34));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_int_3);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
@@ -8965,23 +5332,23 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__pileup), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__pileup), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_v_preset2conf));
   __pyx_v_preset2conf = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":851
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":472
  *         }
  * 
  *     if preset:             # <<<<<<<<<<<<<<
  *         try:
  *             conf_data = preset2conf[preset]
  */
-  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_preset); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_preset); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_7) {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":852
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":473
  * 
  *     if preset:
  *         try:             # <<<<<<<<<<<<<<
@@ -8996,14 +5363,14 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
       __Pyx_XGOTREF(__pyx_save_exc_tb);
       /*try:*/ {
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":853
+        /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":474
  *     if preset:
  *         try:
  *             conf_data = preset2conf[preset]             # <<<<<<<<<<<<<<
  *         except KeyError:
  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
  */
-        __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_preset2conf), __pyx_v_preset); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_preset2conf), __pyx_v_preset); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_2);
         __Pyx_DECREF(__pyx_v_conf_data);
         __pyx_v_conf_data = __pyx_t_2;
@@ -9019,7 +5386,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-      /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":854
+      /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":475
  *         try:
  *             conf_data = preset2conf[preset]
  *         except KeyError:             # <<<<<<<<<<<<<<
@@ -9029,32 +5396,32 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
       __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
       if (__pyx_t_8) {
         __Pyx_AddTraceback("ctabix.tabix_index");
-        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_2);
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_GOTREF(__pyx_t_3);
 
-        /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":855
+        /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":476
  *             conf_data = preset2conf[preset]
  *         except KeyError:
  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))             # <<<<<<<<<<<<<<
  *     else:
  *         if end_col == None: end_col = -1
  */
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_40), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_26), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_9 = PyDict_Keys(((PyObject *)__pyx_v_preset2conf)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_9 = PyDict_Keys(((PyObject *)__pyx_v_preset2conf)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_10);
         PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
         __Pyx_GIVEREF(__pyx_t_9);
         __pyx_t_9 = 0;
-        __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_10);
         __Pyx_INCREF(__pyx_v_preset);
         PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_preset);
@@ -9062,20 +5429,20 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
         PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
         __Pyx_GIVEREF(__pyx_t_9);
         __pyx_t_9 = 0;
-        __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_39), __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_9));
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_10);
         PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
         __pyx_t_9 = 0;
-        __pyx_t_9 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_9 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
         __Pyx_Raise(__pyx_t_9, 0, 0);
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -9098,16 +5465,16 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   }
   /*else*/ {
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":857
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":478
  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
  *     else:
  *         if end_col == None: end_col = -1             # <<<<<<<<<<<<<<
  *         preset = 0
  * 
  */
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_end_col, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_end_col, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     if (__pyx_t_7) {
       __Pyx_INCREF(__pyx_int_neg_1);
@@ -9117,7 +5484,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     }
     __pyx_L20:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":858
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":479
  *     else:
  *         if end_col == None: end_col = -1
  *         preset = 0             # <<<<<<<<<<<<<<
@@ -9128,16 +5495,16 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     __Pyx_DECREF(__pyx_v_preset);
     __pyx_v_preset = __pyx_int_0;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":865
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":486
  *         # -1 is subtracted from the start coordinate. To avoid doing this, set
  *         # the TI_FLAG_UCSC=0x10000 flag:
  *         if zerobased: preset = preset | 0x10000             # <<<<<<<<<<<<<<
  * 
  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)
  */
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_zerobased); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_zerobased); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_7) {
-      __pyx_t_3 = PyNumber_Or(__pyx_v_preset, __pyx_int_0x10000); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyNumber_Or(__pyx_v_preset, __pyx_int_0x10000); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_v_preset);
       __pyx_v_preset = __pyx_t_3;
@@ -9146,28 +5513,28 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     }
     __pyx_L21:;
 
-    /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":867
+    /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":488
  *         if zerobased: preset = preset | 0x10000
  * 
  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)             # <<<<<<<<<<<<<<
  * 
  *     cdef ti_conf_t conf
  */
-    __pyx_t_3 = PyNumber_Add(__pyx_v_seq_col, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Add(__pyx_v_seq_col, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = PyNumber_Add(__pyx_v_start_col, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Add(__pyx_v_start_col, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_2 = PyNumber_Add(__pyx_v_end_col, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Add(__pyx_v_end_col, __pyx_int_1); 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_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __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 = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_INCREF(__pyx_v_meta_char);
     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_meta_char);
     __Pyx_GIVEREF(__pyx_v_meta_char);
-    __pyx_t_10 = PyObject_Call(__pyx_builtin_ord, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyObject_Call(__pyx_builtin_ord, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    __pyx_t_9 = PyTuple_New(6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_INCREF(__pyx_v_preset);
     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_preset);
@@ -9193,7 +5560,7 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   }
   __pyx_L9:;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":870
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":491
  * 
  *     cdef ti_conf_t conf
  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data             # <<<<<<<<<<<<<<
@@ -9203,22 +5570,22 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
   if (PyTuple_CheckExact(__pyx_v_conf_data) && likely(PyTuple_GET_SIZE(__pyx_v_conf_data) == 6)) {
     PyObject* tuple = __pyx_v_conf_data;
     __pyx_t_9 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_9);
-    __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
     __pyx_t_10 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_10);
-    __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_3 = PyTuple_GET_ITEM(tuple, 4); __Pyx_INCREF(__pyx_t_3);
-    __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 5); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_conf.preset = __pyx_t_11;
     __pyx_v_conf.sc = __pyx_t_12;
@@ -9227,33 +5594,33 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     __pyx_v_conf.meta_char = __pyx_t_15;
     __pyx_v_conf.line_skip = __pyx_t_16;
   } else {
-    __pyx_t_17 = PyObject_GetIter(__pyx_v_conf_data); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_17 = PyObject_GetIter(__pyx_v_conf_data); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_17);
-    __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_17, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_17, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
-    __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_17, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_17, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
-    __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_17, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_17, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_17, 3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_17, 3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_17, 4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_17, 4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_17, 5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_17, 5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_17, 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_17, 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
     __pyx_v_conf.preset = __pyx_t_16;
     __pyx_v_conf.sc = __pyx_t_15;
@@ -9263,82 +5630,255 @@ static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__
     __pyx_v_conf.line_skip = __pyx_t_11;
   }
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":872
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":493
  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data
  * 
  *     ti_index_build( filename, &conf)             # <<<<<<<<<<<<<<
  * 
  *     return filename
  */
-  __pyx_t_18 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_18) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_18 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_18) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ti_index_build(__pyx_t_18, (&__pyx_v_conf));
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":874
- *     ti_index_build( filename, &conf)
- * 
- *     return filename             # <<<<<<<<<<<<<<
- * 
- * __all__ = ["tabix_index",
- */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(__pyx_v_filename);
-  __pyx_r = __pyx_v_filename;
-  goto __pyx_L0;
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":495
+ *     ti_index_build( filename, &conf)
+ * 
+ *     return filename             # <<<<<<<<<<<<<<
+ * 
+ * __all__ = ["tabix_index",
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_filename);
+  __pyx_r = __pyx_v_filename;
+  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_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_17);
+  __Pyx_AddTraceback("ctabix.tabix_index");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_preset2conf);
+  __Pyx_DECREF(__pyx_v_conf_data);
+  __Pyx_DECREF(__pyx_v_filename);
+  __Pyx_DECREF(__pyx_v_end_col);
+  __Pyx_DECREF(__pyx_v_preset);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_6ctabix_Tabixfile(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  if (__pyx_pf_6ctabix_9Tabixfile___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_6ctabix_Tabixfile(PyObject *o) {
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_6ctabix_9Tabixfile_header(PyObject *o, void *x) {
+  return __pyx_pf_6ctabix_9Tabixfile_6header___get__(o);
+}
+
+static PyObject *__pyx_getprop_6ctabix_9Tabixfile_contigs(PyObject *o, void *x) {
+  return __pyx_pf_6ctabix_9Tabixfile_7contigs___get__(o);
+}
+
+static PyMethodDef __pyx_methods_6ctabix_Tabixfile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__isOpen)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__open)},
+  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__parseRegion)},
+  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_fetch)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_6ctabix_Tabixfile[] = {
+  {(char *)"header", __pyx_getprop_6ctabix_9Tabixfile_header, 0, 0, 0},
+  {(char *)"contigs", __pyx_getprop_6ctabix_9Tabixfile_contigs, 0, __Pyx_DOCSTR(__pyx_k_27), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Tabixfile = {
+  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_Tabixfile = {
+  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_Tabixfile = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
 
-  __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_XDECREF(__pyx_t_6);
-  __Pyx_XDECREF(__pyx_t_9);
-  __Pyx_XDECREF(__pyx_t_10);
-  __Pyx_XDECREF(__pyx_t_17);
-  __Pyx_AddTraceback("ctabix.tabix_index");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_preset2conf);
-  __Pyx_DECREF(__pyx_v_conf_data);
-  __Pyx_DECREF(__pyx_v_filename);
-  __Pyx_DECREF(__pyx_v_end_col);
-  __Pyx_DECREF(__pyx_v_preset);
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
+static PyBufferProcs __pyx_tp_as_buffer_Tabixfile = {
+  #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 PyObject *__pyx_tp_new_6ctabix_Tabixfile(PyTypeObject *t, PyObject *a, PyObject *k) {
+PyTypeObject __pyx_type_6ctabix_Tabixfile = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("ctabix.Tabixfile"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_Tabixfile), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_6ctabix_Tabixfile, /*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_Tabixfile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Tabixfile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Tabixfile, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Tabixfile, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("*(filename, mode='r')*\n\n    opens a :term:`tabix file` for reading. A missing\n    index (*filename* + \".tbi\") will raise an exception.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_6ctabix_Tabixfile, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_6ctabix_Tabixfile, /*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_6ctabix_Tabixfile, /*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_6ctabix_Parser(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  if (__pyx_pf_6ctabix_9Tabixfile___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
   return o;
 }
 
-static void __pyx_tp_dealloc_6ctabix_Tabixfile(PyObject *o) {
+static void __pyx_tp_dealloc_6ctabix_Parser(PyObject *o) {
   (*Py_TYPE(o)->tp_free)(o);
 }
 
-static PyObject *__pyx_getprop_6ctabix_9Tabixfile_contigs(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_9Tabixfile_7contigs___get__(o);
-}
-
-static PyMethodDef __pyx_methods_6ctabix_Tabixfile[] = {
-  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__isOpen)},
-  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__open)},
-  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__parseRegion)},
-  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_fetch)},
+static PyMethodDef __pyx_methods_6ctabix_Parser[] = {
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_6ctabix_Tabixfile[] = {
-  {(char *)"contigs", __pyx_getprop_6ctabix_9Tabixfile_contigs, 0, __Pyx_DOCSTR(__pyx_k_41), 0},
-  {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_Tabixfile = {
+static PyNumberMethods __pyx_tp_as_number_Parser = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -9396,7 +5936,7 @@ static PyNumberMethods __pyx_tp_as_number_Tabixfile = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_Tabixfile = {
+static PySequenceMethods __pyx_tp_as_sequence_Parser = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -9409,13 +5949,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Tabixfile = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_Tabixfile = {
+static PyMappingMethods __pyx_tp_as_mapping_Parser = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_Tabixfile = {
+static PyBufferProcs __pyx_tp_as_buffer_Parser = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -9436,12 +5976,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Tabixfile = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_Tabixfile = {
+PyTypeObject __pyx_type_6ctabix_Parser = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.Tabixfile"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_Tabixfile), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.Parser"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_Parser), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_6ctabix_Tabixfile, /*tp_dealloc*/
+  __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -9451,26 +5991,26 @@ PyTypeObject __pyx_type_6ctabix_Tabixfile = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_Tabixfile, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Tabixfile, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Tabixfile, /*tp_as_mapping*/
+  &__pyx_tp_as_number_Parser, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Parser, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Parser, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_Tabixfile, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_Parser, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("*(filename, mode='r')*\n\n    opens a :term:`tabix file` for reading. A missing\n    index (*filename* + \".tbi\") will raise an exception.\n    "), /*tp_doc*/
+  0, /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_6ctabix_Tabixfile, /*tp_methods*/
+  __pyx_methods_6ctabix_Parser, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_6ctabix_Tabixfile, /*tp_getset*/
+  0, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -9478,7 +6018,7 @@ PyTypeObject __pyx_type_6ctabix_Tabixfile = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_Tabixfile, /*tp_new*/
+  __pyx_tp_new_6ctabix_Parser, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -9672,46 +6212,35 @@ PyTypeObject __pyx_type_6ctabix_TabixIterator = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_6ctabix_TupleProxy __pyx_vtable_6ctabix_TupleProxy;
 
-static PyObject *__pyx_tp_new_6ctabix_TupleProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_6ctabix_TupleProxy *p;
+static PyObject *__pyx_tp_new_6ctabix_TabixHeaderIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  p = ((struct __pyx_obj_6ctabix_TupleProxy *)o);
-  p->__pyx_vtab = __pyx_vtabptr_6ctabix_TupleProxy;
-  if (__pyx_pf_6ctabix_10TupleProxy___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+  if (__pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static void __pyx_tp_dealloc_6ctabix_TupleProxy(PyObject *o) {
+static void __pyx_tp_dealloc_6ctabix_TabixHeaderIterator(PyObject *o) {
   {
     PyObject *etype, *eval, *etb;
     PyErr_Fetch(&etype, &eval, &etb);
     ++Py_REFCNT(o);
-    __pyx_pf_6ctabix_10TupleProxy___dealloc__(o);
+    __pyx_pf_6ctabix_19TabixHeaderIterator___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_sq_item_6ctabix_TupleProxy(PyObject *o, Py_ssize_t i) {
-  PyObject *r;
-  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
-  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
-  Py_DECREF(x);
-  return r;
-}
 
-static PyMethodDef __pyx_methods_6ctabix_TupleProxy[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_10TupleProxy___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_10TupleProxy___next__)},
+static PyMethodDef __pyx_methods_6ctabix_TabixHeaderIterator[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_19TabixHeaderIterator___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixHeaderIterator___next__)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_TupleProxy = {
+static PyNumberMethods __pyx_tp_as_number_TabixHeaderIterator = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -9769,11 +6298,11 @@ static PyNumberMethods __pyx_tp_as_number_TupleProxy = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_TupleProxy = {
-  __pyx_pf_6ctabix_10TupleProxy___len__, /*sq_length*/
+static PySequenceMethods __pyx_tp_as_sequence_TabixHeaderIterator = {
+  0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
-  __pyx_sq_item_6ctabix_TupleProxy, /*sq_item*/
+  0, /*sq_item*/
   0, /*sq_slice*/
   0, /*sq_ass_item*/
   0, /*sq_ass_slice*/
@@ -9782,13 +6311,13 @@ static PySequenceMethods __pyx_tp_as_sequence_TupleProxy = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_TupleProxy = {
-  __pyx_pf_6ctabix_10TupleProxy___len__, /*mp_length*/
-  __pyx_pf_6ctabix_10TupleProxy___getitem__, /*mp_subscript*/
+static PyMappingMethods __pyx_tp_as_mapping_TabixHeaderIterator = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_TupleProxy = {
+static PyBufferProcs __pyx_tp_as_buffer_TabixHeaderIterator = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -9809,12 +6338,12 @@ static PyBufferProcs __pyx_tp_as_buffer_TupleProxy = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_TupleProxy = {
+PyTypeObject __pyx_type_6ctabix_TabixHeaderIterator = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.TupleProxy"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_TupleProxy), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.TabixHeaderIterator"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_TabixHeaderIterator), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_6ctabix_TupleProxy, /*tp_dealloc*/
+  __pyx_tp_dealloc_6ctabix_TabixHeaderIterator, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -9824,24 +6353,24 @@ PyTypeObject __pyx_type_6ctabix_TupleProxy = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_TupleProxy, /*tp_as_number*/
-  &__pyx_tp_as_sequence_TupleProxy, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_TupleProxy, /*tp_as_mapping*/
+  &__pyx_tp_as_number_TabixHeaderIterator, /*tp_as_number*/
+  &__pyx_tp_as_sequence_TabixHeaderIterator, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_TabixHeaderIterator, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_TupleProxy, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_TabixHeaderIterator, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("Proxy class for access to parsed row as a tuple.\n\n    This class represents a table row for fast read-access.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("return header lines.\n    "), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_6ctabix_10TupleProxy___iter__, /*tp_iter*/
-  __pyx_pf_6ctabix_10TupleProxy___next__, /*tp_iternext*/
-  __pyx_methods_6ctabix_TupleProxy, /*tp_methods*/
+  __pyx_pf_6ctabix_19TabixHeaderIterator___iter__, /*tp_iter*/
+  __pyx_pf_6ctabix_19TabixHeaderIterator___next__, /*tp_iternext*/
+  __pyx_methods_6ctabix_TabixHeaderIterator, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -9851,7 +6380,7 @@ PyTypeObject __pyx_type_6ctabix_TupleProxy = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_TupleProxy, /*tp_new*/
+  __pyx_tp_new_6ctabix_TabixHeaderIterator, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -9864,199 +6393,18 @@ PyTypeObject __pyx_type_6ctabix_TupleProxy = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_6ctabix_GTFProxy __pyx_vtable_6ctabix_GTFProxy;
-
-static PyObject *__pyx_tp_new_6ctabix_GTFProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_6ctabix_GTFProxy *p;
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  p = ((struct __pyx_obj_6ctabix_GTFProxy *)o);
-  p->__pyx_vtab = __pyx_vtabptr_6ctabix_GTFProxy;
-  if (__pyx_pf_6ctabix_8GTFProxy___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
-    Py_DECREF(o); o = 0;
-  }
-  return o;
-}
-
-static void __pyx_tp_dealloc_6ctabix_GTFProxy(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_6ctabix_8GTFProxy___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_sq_item_6ctabix_GTFProxy(PyObject *o, Py_ssize_t i) {
-  PyObject *r;
-  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
-  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
-  Py_DECREF(x);
-  return r;
-}
 
-static PyObject *__pyx_tp_getattro_6ctabix_GTFProxy(PyObject *o, PyObject *n) {
-  PyObject *v = PyObject_GenericGetAttr(o, n);
-  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
-    PyErr_Clear();
-    v = __pyx_pf_6ctabix_8GTFProxy___getattr__(o, n);
-  }
-  return v;
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_contig(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_6contig___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_contig(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_6contig___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_feature(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_7feature___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_feature(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_7feature___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_source(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_6source___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_source(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_6source___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_start(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_5start___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_start(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_5start___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_end(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_3end___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_end(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_3end___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_score(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_5score___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_score(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_5score___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_strand(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_6strand___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_strand(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_6strand___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_frame(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_5frame___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_frame(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_5frame___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_6ctabix_8GTFProxy_attributes(PyObject *o, void *x) {
-  return __pyx_pf_6ctabix_8GTFProxy_10attributes___get__(o);
-}
-
-static int __pyx_setprop_6ctabix_8GTFProxy_attributes(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_6ctabix_8GTFProxy_10attributes___set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
+static PyObject *__pyx_tp_new_6ctabix_asTuple(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
+  if (!o) return 0;
+  return o;
 }
 
-static PyMethodDef __pyx_methods_6ctabix_GTFProxy[] = {
-  {__Pyx_NAMESTR("asDict"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy_asDict, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy_asDict)},
-  {__Pyx_NAMESTR("fromDict"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy_fromDict, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy_fromDict)},
-  {__Pyx_NAMESTR("invert"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy_invert, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy_invert)},
-  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy_keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy_keys)},
-  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy___getattr__, METH_O|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy___getattr__)},
-  {__Pyx_NAMESTR("setAttribute"), (PyCFunction)__pyx_pf_6ctabix_8GTFProxy_setAttribute, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_8GTFProxy_setAttribute)},
+static PyMethodDef __pyx_methods_6ctabix_asTuple[] = {
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_6ctabix_GTFProxy[] = {
-  {(char *)"contig", __pyx_getprop_6ctabix_8GTFProxy_contig, __pyx_setprop_6ctabix_8GTFProxy_contig, __Pyx_DOCSTR(__pyx_k_42), 0},
-  {(char *)"feature", __pyx_getprop_6ctabix_8GTFProxy_feature, __pyx_setprop_6ctabix_8GTFProxy_feature, __Pyx_DOCSTR(__pyx_k_43), 0},
-  {(char *)"source", __pyx_getprop_6ctabix_8GTFProxy_source, __pyx_setprop_6ctabix_8GTFProxy_source, __Pyx_DOCSTR(__pyx_k_44), 0},
-  {(char *)"start", __pyx_getprop_6ctabix_8GTFProxy_start, __pyx_setprop_6ctabix_8GTFProxy_start, __Pyx_DOCSTR(__pyx_k_45), 0},
-  {(char *)"end", __pyx_getprop_6ctabix_8GTFProxy_end, __pyx_setprop_6ctabix_8GTFProxy_end, __Pyx_DOCSTR(__pyx_k_46), 0},
-  {(char *)"score", __pyx_getprop_6ctabix_8GTFProxy_score, __pyx_setprop_6ctabix_8GTFProxy_score, __Pyx_DOCSTR(__pyx_k_47), 0},
-  {(char *)"strand", __pyx_getprop_6ctabix_8GTFProxy_strand, __pyx_setprop_6ctabix_8GTFProxy_strand, __Pyx_DOCSTR(__pyx_k_48), 0},
-  {(char *)"frame", __pyx_getprop_6ctabix_8GTFProxy_frame, __pyx_setprop_6ctabix_8GTFProxy_frame, __Pyx_DOCSTR(__pyx_k_49), 0},
-  {(char *)"attributes", __pyx_getprop_6ctabix_8GTFProxy_attributes, __pyx_setprop_6ctabix_8GTFProxy_attributes, __Pyx_DOCSTR(__pyx_k_50), 0},
-  {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_GTFProxy = {
+static PyNumberMethods __pyx_tp_as_number_asTuple = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -10114,11 +6462,11 @@ static PyNumberMethods __pyx_tp_as_number_GTFProxy = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_GTFProxy = {
+static PySequenceMethods __pyx_tp_as_sequence_asTuple = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
-  __pyx_sq_item_6ctabix_GTFProxy, /*sq_item*/
+  0, /*sq_item*/
   0, /*sq_slice*/
   0, /*sq_ass_item*/
   0, /*sq_ass_slice*/
@@ -10127,13 +6475,13 @@ static PySequenceMethods __pyx_tp_as_sequence_GTFProxy = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_GTFProxy = {
+static PyMappingMethods __pyx_tp_as_mapping_asTuple = {
   0, /*mp_length*/
-  __pyx_pf_6ctabix_8GTFProxy___getitem__, /*mp_subscript*/
+  0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_GTFProxy = {
+static PyBufferProcs __pyx_tp_as_buffer_asTuple = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -10154,12 +6502,12 @@ static PyBufferProcs __pyx_tp_as_buffer_GTFProxy = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_GTFProxy = {
+PyTypeObject __pyx_type_6ctabix_asTuple = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.GTFProxy"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_GTFProxy), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.asTuple"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_asTuple), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_6ctabix_GTFProxy, /*tp_dealloc*/
+  __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -10169,26 +6517,26 @@ PyTypeObject __pyx_type_6ctabix_GTFProxy = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_GTFProxy, /*tp_as_number*/
-  &__pyx_tp_as_sequence_GTFProxy, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_GTFProxy, /*tp_as_mapping*/
+  &__pyx_tp_as_number_asTuple, /*tp_as_number*/
+  &__pyx_tp_as_sequence_asTuple, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_asTuple, /*tp_as_mapping*/
   0, /*tp_hash*/
-  0, /*tp_call*/
-  __pyx_pf_6ctabix_8GTFProxy___str__, /*tp_str*/
-  __pyx_tp_getattro_6ctabix_GTFProxy, /*tp_getattro*/
+  __pyx_pf_6ctabix_7asTuple___call__, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_GTFProxy, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_asTuple, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("Proxy class for access to GTF fields.\n\n    This class represents a GTF entry for fast read-access.\n    Write-access has been added as well, though some care must\n    be taken. If any of the string fields (contig, source, ...)\n    are set, the new value is tied to the lifetime of the\n    argument that was supplied.\n\n    The only exception is the attributes field when set from\n    a dictionary - this field will manage its own memory.\n\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("converts a :term:`tabix row` into a python tuple."), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_6ctabix_GTFProxy, /*tp_methods*/
+  __pyx_methods_6ctabix_asTuple, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_6ctabix_GTFProxy, /*tp_getset*/
+  0, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -10196,7 +6544,7 @@ PyTypeObject __pyx_type_6ctabix_GTFProxy = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_GTFProxy, /*tp_new*/
+  __pyx_tp_new_6ctabix_asTuple, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -10210,21 +6558,17 @@ PyTypeObject __pyx_type_6ctabix_GTFProxy = {
   #endif
 };
 
-static PyObject *__pyx_tp_new_6ctabix_Parser(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = (*t->tp_alloc)(t, 0);
+static PyObject *__pyx_tp_new_6ctabix_asGTF(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
   if (!o) return 0;
   return o;
 }
 
-static void __pyx_tp_dealloc_6ctabix_Parser(PyObject *o) {
-  (*Py_TYPE(o)->tp_free)(o);
-}
-
-static PyMethodDef __pyx_methods_6ctabix_Parser[] = {
+static PyMethodDef __pyx_methods_6ctabix_asGTF[] = {
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_Parser = {
+static PyNumberMethods __pyx_tp_as_number_asGTF = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -10282,7 +6626,7 @@ static PyNumberMethods __pyx_tp_as_number_Parser = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_Parser = {
+static PySequenceMethods __pyx_tp_as_sequence_asGTF = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -10295,13 +6639,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Parser = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_Parser = {
+static PyMappingMethods __pyx_tp_as_mapping_asGTF = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_Parser = {
+static PyBufferProcs __pyx_tp_as_buffer_asGTF = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -10322,10 +6666,10 @@ static PyBufferProcs __pyx_tp_as_buffer_Parser = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_Parser = {
+PyTypeObject __pyx_type_6ctabix_asGTF = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.Parser"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_Parser), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.asGTF"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_asGTF), /*tp_basicsize*/
   0, /*tp_itemsize*/
   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
   0, /*tp_print*/
@@ -10337,24 +6681,24 @@ PyTypeObject __pyx_type_6ctabix_Parser = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_Parser, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Parser, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Parser, /*tp_as_mapping*/
+  &__pyx_tp_as_number_asGTF, /*tp_as_number*/
+  &__pyx_tp_as_sequence_asGTF, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_asGTF, /*tp_as_mapping*/
   0, /*tp_hash*/
-  0, /*tp_call*/
+  __pyx_pf_6ctabix_5asGTF___call__, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_Parser, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_asGTF, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  0, /*tp_doc*/
+  __Pyx_DOCSTR("converts a :term:`tabix row` into a GTF record."), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_6ctabix_Parser, /*tp_methods*/
+  __pyx_methods_6ctabix_asGTF, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -10364,7 +6708,7 @@ PyTypeObject __pyx_type_6ctabix_Parser = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_Parser, /*tp_new*/
+  __pyx_tp_new_6ctabix_asGTF, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -10378,17 +6722,17 @@ PyTypeObject __pyx_type_6ctabix_Parser = {
   #endif
 };
 
-static PyObject *__pyx_tp_new_6ctabix_asTuple(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_6ctabix_asBed(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
   if (!o) return 0;
   return o;
 }
 
-static PyMethodDef __pyx_methods_6ctabix_asTuple[] = {
+static PyMethodDef __pyx_methods_6ctabix_asBed[] = {
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_asTuple = {
+static PyNumberMethods __pyx_tp_as_number_asBed = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -10446,7 +6790,7 @@ static PyNumberMethods __pyx_tp_as_number_asTuple = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_asTuple = {
+static PySequenceMethods __pyx_tp_as_sequence_asBed = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -10459,13 +6803,13 @@ static PySequenceMethods __pyx_tp_as_sequence_asTuple = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_asTuple = {
+static PyMappingMethods __pyx_tp_as_mapping_asBed = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_asTuple = {
+static PyBufferProcs __pyx_tp_as_buffer_asBed = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -10486,10 +6830,10 @@ static PyBufferProcs __pyx_tp_as_buffer_asTuple = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_asTuple = {
+PyTypeObject __pyx_type_6ctabix_asBed = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.asTuple"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_asTuple), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.asBed"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_asBed), /*tp_basicsize*/
   0, /*tp_itemsize*/
   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
   0, /*tp_print*/
@@ -10501,24 +6845,24 @@ PyTypeObject __pyx_type_6ctabix_asTuple = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_asTuple, /*tp_as_number*/
-  &__pyx_tp_as_sequence_asTuple, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_asTuple, /*tp_as_mapping*/
+  &__pyx_tp_as_number_asBed, /*tp_as_number*/
+  &__pyx_tp_as_sequence_asBed, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_asBed, /*tp_as_mapping*/
   0, /*tp_hash*/
-  __pyx_pf_6ctabix_7asTuple___call__, /*tp_call*/
+  __pyx_pf_6ctabix_5asBed___call__, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_asTuple, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_asBed, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("converts a :term:`tabix row` into a python tuple."), /*tp_doc*/
+  __Pyx_DOCSTR("converts a :term:`tabix row` into a GTF record."), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_6ctabix_asTuple, /*tp_methods*/
+  __pyx_methods_6ctabix_asBed, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -10528,7 +6872,7 @@ PyTypeObject __pyx_type_6ctabix_asTuple = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_asTuple, /*tp_new*/
+  __pyx_tp_new_6ctabix_asBed, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -10542,17 +6886,17 @@ PyTypeObject __pyx_type_6ctabix_asTuple = {
   #endif
 };
 
-static PyObject *__pyx_tp_new_6ctabix_asGTF(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_6ctabix_asVCF(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
   if (!o) return 0;
   return o;
 }
 
-static PyMethodDef __pyx_methods_6ctabix_asGTF[] = {
+static PyMethodDef __pyx_methods_6ctabix_asVCF[] = {
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_asGTF = {
+static PyNumberMethods __pyx_tp_as_number_asVCF = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -10610,7 +6954,7 @@ static PyNumberMethods __pyx_tp_as_number_asGTF = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_asGTF = {
+static PySequenceMethods __pyx_tp_as_sequence_asVCF = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -10623,13 +6967,13 @@ static PySequenceMethods __pyx_tp_as_sequence_asGTF = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_asGTF = {
+static PyMappingMethods __pyx_tp_as_mapping_asVCF = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_asGTF = {
+static PyBufferProcs __pyx_tp_as_buffer_asVCF = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -10650,10 +6994,10 @@ static PyBufferProcs __pyx_tp_as_buffer_asGTF = {
   #endif
 };
 
-PyTypeObject __pyx_type_6ctabix_asGTF = {
+PyTypeObject __pyx_type_6ctabix_asVCF = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("ctabix.asGTF"), /*tp_name*/
-  sizeof(struct __pyx_obj_6ctabix_asGTF), /*tp_basicsize*/
+  __Pyx_NAMESTR("ctabix.asVCF"), /*tp_name*/
+  sizeof(struct __pyx_obj_6ctabix_asVCF), /*tp_basicsize*/
   0, /*tp_itemsize*/
   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
   0, /*tp_print*/
@@ -10665,24 +7009,24 @@ PyTypeObject __pyx_type_6ctabix_asGTF = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_asGTF, /*tp_as_number*/
-  &__pyx_tp_as_sequence_asGTF, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_asGTF, /*tp_as_mapping*/
+  &__pyx_tp_as_number_asVCF, /*tp_as_number*/
+  &__pyx_tp_as_sequence_asVCF, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_asVCF, /*tp_as_mapping*/
   0, /*tp_hash*/
-  __pyx_pf_6ctabix_5asGTF___call__, /*tp_call*/
+  __pyx_pf_6ctabix_5asVCF___call__, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_asGTF, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_asVCF, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
-  __Pyx_DOCSTR("converts a :term:`tabix row` into a GTF record."), /*tp_doc*/
+  __Pyx_DOCSTR("converts a :term:`tabix row` into a VCF record."), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_6ctabix_asGTF, /*tp_methods*/
+  __pyx_methods_6ctabix_asVCF, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -10692,7 +7036,7 @@ PyTypeObject __pyx_type_6ctabix_asGTF = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_6ctabix_asGTF, /*tp_new*/
+  __pyx_tp_new_6ctabix_asVCF, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -10879,7 +7223,7 @@ PyTypeObject __pyx_type_6ctabix_TabixIteratorParsed = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_TabixIteratorParsed, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over mapped reads in a region.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("iterates over mapped reads in a region.\n\n    Returns parsed data.\n    "), /*tp_doc*/
   __pyx_tp_traverse_6ctabix_TabixIteratorParsed, /*tp_traverse*/
   __pyx_tp_clear_6ctabix_TabixIteratorParsed, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -10911,8 +7255,6 @@ PyTypeObject __pyx_type_6ctabix_TabixIteratorParsed = {
 };
 
 static PyMethodDef __pyx_methods[] = {
-  {__Pyx_NAMESTR("toDot"), (PyCFunction)__pyx_pf_6ctabix_toDot, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_toDot)},
-  {__Pyx_NAMESTR("quote"), (PyCFunction)__pyx_pf_6ctabix_quote, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_quote)},
   {__Pyx_NAMESTR("tabix_compress"), (PyCFunction)__pyx_pf_6ctabix_tabix_compress, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_tabix_compress)},
   {__Pyx_NAMESTR("tabix_index"), (PyCFunction)__pyx_pf_6ctabix_tabix_index, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_tabix_index)},
   {0, 0, 0, 0}
@@ -10938,113 +7280,77 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
   {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
-  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
   {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
   {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
-  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
   {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
-  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
   {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
   {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
   {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
-  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
-  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
+  {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0},
+  {&__pyx_kp_u_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0, 0},
   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
-  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
-  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
-  {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
-  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
-  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 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_u_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0, 0},
+  {&__pyx_kp_u_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 1, 0, 0},
+  {&__pyx_kp_u_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0, 0},
+  {&__pyx_kp_u_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 1, 0, 0},
+  {&__pyx_kp_u_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 1, 0, 0},
+  {&__pyx_kp_u_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 1, 0, 0},
+  {&__pyx_kp_u_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 1, 0, 0},
+  {&__pyx_kp_u_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 1, 0, 0},
   {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
-  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
-  {&__pyx_kp_u_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 1, 0, 0},
-  {&__pyx_kp_u_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 1, 0, 0},
-  {&__pyx_kp_u_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 1, 0, 0},
-  {&__pyx_kp_u_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 1, 0, 0},
-  {&__pyx_kp_u_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 1, 0, 0},
-  {&__pyx_kp_u_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 1, 0, 0},
-  {&__pyx_kp_u_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 1, 0, 0},
-  {&__pyx_kp_u_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 1, 0, 0},
-  {&__pyx_kp_u_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 1, 0, 0},
   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
-  {&__pyx_kp_u_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 1, 0, 0},
-  {&__pyx_kp_u_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 1, 0, 0},
-  {&__pyx_kp_u_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 1, 0, 0},
-  {&__pyx_kp_u_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 1, 0, 0},
-  {&__pyx_kp_u_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 1, 0, 0},
-  {&__pyx_kp_u_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 1, 0, 0},
-  {&__pyx_kp_u_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 1, 0, 0},
-  {&__pyx_kp_u_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 1, 0, 0},
   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
   {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
-  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
-  {&__pyx_n_s__GTFProxy, __pyx_k__GTFProxy, sizeof(__pyx_k__GTFProxy), 0, 0, 1, 1},
   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
-  {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
   {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
   {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
   {&__pyx_n_s__O_RDONLY, __pyx_k__O_RDONLY, sizeof(__pyx_k__O_RDONLY), 0, 0, 1, 1},
   {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
-  {&__pyx_n_s__StringType, __pyx_k__StringType, sizeof(__pyx_k__StringType), 0, 0, 1, 1},
-  {&__pyx_n_s__StringTypes, __pyx_k__StringTypes, sizeof(__pyx_k__StringTypes), 0, 0, 1, 1},
+  {&__pyx_n_s__TabixHeaderIterator, __pyx_k__TabixHeaderIterator, sizeof(__pyx_k__TabixHeaderIterator), 0, 0, 1, 1},
   {&__pyx_n_s__TabixIterator, __pyx_k__TabixIterator, sizeof(__pyx_k__TabixIterator), 0, 0, 1, 1},
   {&__pyx_n_s__TabixIteratorParsed, __pyx_k__TabixIteratorParsed, sizeof(__pyx_k__TabixIteratorParsed), 0, 0, 1, 1},
   {&__pyx_n_s__Tabixfile, __pyx_k__Tabixfile, sizeof(__pyx_k__Tabixfile), 0, 0, 1, 1},
-  {&__pyx_n_s__TupleProxy, __pyx_k__TupleProxy, sizeof(__pyx_k__TupleProxy), 0, 0, 1, 1},
-  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
   {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
-  {&__pyx_n_s____getattr__, __pyx_k____getattr__, sizeof(__pyx_k____getattr__), 0, 0, 1, 1},
+  {&__pyx_n_s____get__, __pyx_k____get__, sizeof(__pyx_k____get__), 0, 0, 1, 1},
   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
   {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
   {&__pyx_n_s___isOpen, __pyx_k___isOpen, sizeof(__pyx_k___isOpen), 0, 0, 1, 1},
   {&__pyx_n_s___open, __pyx_k___open, sizeof(__pyx_k___open), 0, 0, 1, 1},
   {&__pyx_n_s___parseRegion, __pyx_k___parseRegion, sizeof(__pyx_k___parseRegion), 0, 0, 1, 1},
-  {&__pyx_n_s__asDict, __pyx_k__asDict, sizeof(__pyx_k__asDict), 0, 0, 1, 1},
+  {&__pyx_n_s__asBed, __pyx_k__asBed, sizeof(__pyx_k__asBed), 0, 0, 1, 1},
   {&__pyx_n_s__asGTF, __pyx_k__asGTF, sizeof(__pyx_k__asGTF), 0, 0, 1, 1},
   {&__pyx_n_s__asTuple, __pyx_k__asTuple, sizeof(__pyx_k__asTuple), 0, 0, 1, 1},
-  {&__pyx_n_s__attributes, __pyx_k__attributes, sizeof(__pyx_k__attributes), 0, 0, 1, 1},
+  {&__pyx_n_s__asVCF, __pyx_k__asVCF, sizeof(__pyx_k__asVCF), 0, 0, 1, 1},
   {&__pyx_n_s__bc, __pyx_k__bc, sizeof(__pyx_k__bc), 0, 0, 1, 1},
   {&__pyx_n_s__bed, __pyx_k__bed, sizeof(__pyx_k__bed), 0, 0, 1, 1},
   {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
   {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
-  {&__pyx_n_s__contig, __pyx_k__contig, sizeof(__pyx_k__contig), 0, 0, 1, 1},
   {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
-  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
   {&__pyx_n_s__ec, __pyx_k__ec, sizeof(__pyx_k__ec), 0, 0, 1, 1},
   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
   {&__pyx_n_s__end_col, __pyx_k__end_col, sizeof(__pyx_k__end_col), 0, 0, 1, 1},
   {&__pyx_n_s__endswith, __pyx_k__endswith, sizeof(__pyx_k__endswith), 0, 0, 1, 1},
   {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
-  {&__pyx_n_s__feature, __pyx_k__feature, sizeof(__pyx_k__feature), 0, 0, 1, 1},
   {&__pyx_n_s__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 0, 0, 1, 1},
-  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
   {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
   {&__pyx_n_s__filename_in, __pyx_k__filename_in, sizeof(__pyx_k__filename_in), 0, 0, 1, 1},
   {&__pyx_n_s__filename_out, __pyx_k__filename_out, sizeof(__pyx_k__filename_out), 0, 0, 1, 1},
   {&__pyx_n_s__force, __pyx_k__force, sizeof(__pyx_k__force), 0, 0, 1, 1},
   {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1},
-  {&__pyx_n_s__frame, __pyx_k__frame, sizeof(__pyx_k__frame), 0, 0, 1, 1},
-  {&__pyx_n_s__fromDict, __pyx_k__fromDict, sizeof(__pyx_k__fromDict), 0, 0, 1, 1},
   {&__pyx_n_s__gff, __pyx_k__gff, sizeof(__pyx_k__gff), 0, 0, 1, 1},
-  {&__pyx_n_s__hasOwnAttributes, __pyx_k__hasOwnAttributes, sizeof(__pyx_k__hasOwnAttributes), 0, 0, 1, 1},
+  {&__pyx_n_s__gzip, __pyx_k__gzip, sizeof(__pyx_k__gzip), 0, 0, 1, 1},
+  {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1},
   {&__pyx_n_s__idx, __pyx_k__idx, sizeof(__pyx_k__idx), 0, 0, 1, 1},
-  {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
-  {&__pyx_n_s__invert, __pyx_k__invert, sizeof(__pyx_k__invert), 0, 0, 1, 1},
-  {&__pyx_n_s__isModified, __pyx_k__isModified, sizeof(__pyx_k__isModified), 0, 0, 1, 1},
-  {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
   {&__pyx_n_s__iterator, __pyx_k__iterator, sizeof(__pyx_k__iterator), 0, 0, 1, 1},
   {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
@@ -11053,9 +7359,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__line_skip, __pyx_k__line_skip, sizeof(__pyx_k__line_skip), 0, 0, 1, 1},
   {&__pyx_n_s__meta_char, __pyx_k__meta_char, sizeof(__pyx_k__meta_char), 0, 0, 1, 1},
   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
-  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
-  {&__pyx_n_s__nbytes, __pyx_k__nbytes, sizeof(__pyx_k__nbytes), 0, 0, 1, 1},
-  {&__pyx_n_s__nfields, __pyx_k__nfields, sizeof(__pyx_k__nfields), 0, 0, 1, 1},
   {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
   {&__pyx_n_s__parser, __pyx_k__parser, sizeof(__pyx_k__parser), 0, 0, 1, 1},
@@ -11063,21 +7366,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
   {&__pyx_n_s__preset, __pyx_k__preset, sizeof(__pyx_k__preset), 0, 0, 1, 1},
   {&__pyx_n_s__psltbl, __pyx_k__psltbl, sizeof(__pyx_k__psltbl), 0, 0, 1, 1},
-  {&__pyx_n_s__quote, __pyx_k__quote, sizeof(__pyx_k__quote), 0, 0, 1, 1},
   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
   {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
   {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
   {&__pyx_n_s__sam, __pyx_k__sam, sizeof(__pyx_k__sam), 0, 0, 1, 1},
   {&__pyx_n_s__sc, __pyx_k__sc, sizeof(__pyx_k__sc), 0, 0, 1, 1},
-  {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
   {&__pyx_n_s__seq_col, __pyx_k__seq_col, sizeof(__pyx_k__seq_col), 0, 0, 1, 1},
-  {&__pyx_n_s__setAttribute, __pyx_k__setAttribute, sizeof(__pyx_k__setAttribute), 0, 0, 1, 1},
-  {&__pyx_n_s__source, __pyx_k__source, sizeof(__pyx_k__source), 0, 0, 1, 1},
-  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
   {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
   {&__pyx_n_s__start_col, __pyx_k__start_col, sizeof(__pyx_k__start_col), 0, 0, 1, 1},
-  {&__pyx_n_s__strand, __pyx_k__strand, sizeof(__pyx_k__strand), 0, 0, 1, 1},
-  {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
   {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
   {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
   {&__pyx_n_s__tabix_compress, __pyx_k__tabix_compress, sizeof(__pyx_k__tabix_compress), 0, 0, 1, 1},
@@ -11085,26 +7381,20 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__tabixfile, __pyx_k__tabixfile, sizeof(__pyx_k__tabixfile), 0, 0, 1, 1},
   {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1},
   {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1},
-  {&__pyx_n_s__toDot, __pyx_k__toDot, sizeof(__pyx_k__toDot), 0, 0, 1, 1},
   {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
   {&__pyx_n_s__unlink, __pyx_k__unlink, sizeof(__pyx_k__unlink), 0, 0, 1, 1},
-  {&__pyx_n_s__update, __pyx_k__update, sizeof(__pyx_k__update), 0, 0, 1, 1},
-  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
   {&__pyx_n_s__vcf, __pyx_k__vcf, sizeof(__pyx_k__vcf), 0, 0, 1, 1},
   {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
   {&__pyx_n_s__zerobased, __pyx_k__zerobased, sizeof(__pyx_k__zerobased), 0, 0, 1, 1},
   {0, 0, 0, 0, 0, 0, 0}
 };
 static int __Pyx_InitCachedBuiltins(void) {
-  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 98; __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 = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __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 = 549; __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 = 643; __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 = 780; __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 = 843; __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 = 854; __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 = 46; __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 = 95; __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 = 207; __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 = 401; __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 = 464; __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 = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   return 0;
   __pyx_L1_error:;
   return -1;
@@ -11185,100 +7475,82 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   /*--- Global init code ---*/
   /*--- Function export code ---*/
   /*--- Type init code ---*/
-  if (PyType_Ready(&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Tabixfile", (PyObject *)&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Tabixfile", (PyObject *)&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_6ctabix_Tabixfile = &__pyx_type_6ctabix_Tabixfile;
-  if (PyType_Ready(&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Parser", (PyObject *)&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_6ctabix_Parser = &__pyx_type_6ctabix_Parser;
+  if (PyType_Ready(&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_6ctabix_13TabixIterator___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_6ctabix_13TabixIterator___next__.doc = __pyx_doc_6ctabix_13TabixIterator___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_13TabixIterator___next__;
     }
   }
-  if (__Pyx_SetAttrString(__pyx_m, "TabixIterator", (PyObject *)&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "TabixIterator", (PyObject *)&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_6ctabix_TabixIterator = &__pyx_type_6ctabix_TabixIterator;
-  __pyx_vtabptr_6ctabix_TupleProxy = &__pyx_vtable_6ctabix_TupleProxy;
-  #if PY_MAJOR_VERSION >= 3
-  __pyx_vtable_6ctabix_TupleProxy.take = (PyObject *(*)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t))__pyx_f_6ctabix_10TupleProxy_take;
-  __pyx_vtable_6ctabix_TupleProxy.present = (PyObject *(*)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t))__pyx_f_6ctabix_10TupleProxy_present;
-  __pyx_vtable_6ctabix_TupleProxy.copy = (PyObject *(*)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t))__pyx_f_6ctabix_10TupleProxy_copy;
-  __pyx_vtable_6ctabix_TupleProxy.update = (PyObject *(*)(struct __pyx_obj_6ctabix_TupleProxy *, char *, size_t))__pyx_f_6ctabix_10TupleProxy_update;
-  #else
-  *(void(**)(void))&__pyx_vtable_6ctabix_TupleProxy.take = (void(*)(void))__pyx_f_6ctabix_10TupleProxy_take;
-  *(void(**)(void))&__pyx_vtable_6ctabix_TupleProxy.present = (void(*)(void))__pyx_f_6ctabix_10TupleProxy_present;
-  *(void(**)(void))&__pyx_vtable_6ctabix_TupleProxy.copy = (void(*)(void))__pyx_f_6ctabix_10TupleProxy_copy;
-  *(void(**)(void))&__pyx_vtable_6ctabix_TupleProxy.update = (void(*)(void))__pyx_f_6ctabix_10TupleProxy_update;
-  #endif
-  if (PyType_Ready(&__pyx_type_6ctabix_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TupleProxy, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_6ctabix_10TupleProxy___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_6ctabix_10TupleProxy___next__.doc = __pyx_doc_6ctabix_10TupleProxy___next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_10TupleProxy___next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_6ctabix_TupleProxy.tp_dict, __pyx_vtabptr_6ctabix_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "TupleProxy", (PyObject *)&__pyx_type_6ctabix_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_6ctabix_TupleProxy = &__pyx_type_6ctabix_TupleProxy;
-  __pyx_vtabptr_6ctabix_GTFProxy = &__pyx_vtable_6ctabix_GTFProxy;
-  #if PY_MAJOR_VERSION >= 3
-  __pyx_vtable_6ctabix_GTFProxy.take = (PyObject *(*)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t))__pyx_f_6ctabix_8GTFProxy_take;
-  __pyx_vtable_6ctabix_GTFProxy.present = (PyObject *(*)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t))__pyx_f_6ctabix_8GTFProxy_present;
-  __pyx_vtable_6ctabix_GTFProxy.copy = (PyObject *(*)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t))__pyx_f_6ctabix_8GTFProxy_copy;
-  __pyx_vtable_6ctabix_GTFProxy.update = (PyObject *(*)(struct __pyx_obj_6ctabix_GTFProxy *, char *, size_t))__pyx_f_6ctabix_8GTFProxy_update;
-  #else
-  *(void(**)(void))&__pyx_vtable_6ctabix_GTFProxy.take = (void(*)(void))__pyx_f_6ctabix_8GTFProxy_take;
-  *(void(**)(void))&__pyx_vtable_6ctabix_GTFProxy.present = (void(*)(void))__pyx_f_6ctabix_8GTFProxy_present;
-  *(void(**)(void))&__pyx_vtable_6ctabix_GTFProxy.copy = (void(*)(void))__pyx_f_6ctabix_8GTFProxy_copy;
-  *(void(**)(void))&__pyx_vtable_6ctabix_GTFProxy.update = (void(*)(void))__pyx_f_6ctabix_8GTFProxy_update;
-  #endif
-  if (PyType_Ready(&__pyx_type_6ctabix_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_GTFProxy, "__getattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_6ctabix_8GTFProxy___getattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_6ctabix_8GTFProxy___getattr__.doc = __pyx_doc_6ctabix_8GTFProxy___getattr__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_8GTFProxy___getattr__;
+      __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__.doc = __pyx_doc_6ctabix_19TabixHeaderIterator___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__;
     }
   }
-  if (__Pyx_SetVtable(__pyx_type_6ctabix_GTFProxy.tp_dict, __pyx_vtabptr_6ctabix_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "GTFProxy", (PyObject *)&__pyx_type_6ctabix_GTFProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_6ctabix_GTFProxy = &__pyx_type_6ctabix_GTFProxy;
-  if (PyType_Ready(&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Parser", (PyObject *)&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_6ctabix_Parser = &__pyx_type_6ctabix_Parser;
+  if (__Pyx_SetAttrString(__pyx_m, "TabixHeaderIterator", (PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_6ctabix_TabixHeaderIterator = &__pyx_type_6ctabix_TabixHeaderIterator;
   __pyx_type_6ctabix_asTuple.tp_base = __pyx_ptype_6ctabix_Parser;
-  if (PyType_Ready(&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "asTuple", (PyObject *)&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "asTuple", (PyObject *)&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_6ctabix_asTuple = &__pyx_type_6ctabix_asTuple;
   __pyx_type_6ctabix_asGTF.tp_base = __pyx_ptype_6ctabix_Parser;
-  if (PyType_Ready(&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "asGTF", (PyObject *)&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "asGTF", (PyObject *)&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_6ctabix_asGTF = &__pyx_type_6ctabix_asGTF;
-  if (PyType_Ready(&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_type_6ctabix_asBed.tp_base = __pyx_ptype_6ctabix_Parser;
+  if (PyType_Ready(&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "asBed", (PyObject *)&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_6ctabix_asBed = &__pyx_type_6ctabix_asBed;
+  __pyx_type_6ctabix_asVCF.tp_base = __pyx_ptype_6ctabix_Parser;
+  if (PyType_Ready(&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "asVCF", (PyObject *)&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_6ctabix_asVCF = &__pyx_type_6ctabix_asVCF;
+  if (PyType_Ready(&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__.doc = __pyx_doc_6ctabix_19TabixIteratorParsed___next__;
       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__;
     }
   }
-  if (__Pyx_SetAttrString(__pyx_m, "TabixIteratorParsed", (PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "TabixIteratorParsed", (PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_6ctabix_TabixIteratorParsed = &__pyx_type_6ctabix_TabixIteratorParsed;
   /*--- Type import code ---*/
+  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_TupleProxy = __Pyx_ImportType("TabProxies", "TupleProxy", sizeof(struct __pyx_obj_10TabProxies_TupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_TupleProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_TupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_GTFProxy = __Pyx_ImportType("TabProxies", "GTFProxy", sizeof(struct __pyx_obj_10TabProxies_GTFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_GTFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_GTFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_NamedTupleProxy = __Pyx_ImportType("TabProxies", "NamedTupleProxy", sizeof(struct __pyx_obj_10TabProxies_NamedTupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_NamedTupleProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_NamedTupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_BedProxy = __Pyx_ImportType("TabProxies", "BedProxy", sizeof(struct __pyx_obj_10TabProxies_BedProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_BedProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_BedProxy->tp_dict, &__pyx_vtabptr_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_VCFProxy = __Pyx_ImportType("TabProxies", "VCFProxy", sizeof(struct __pyx_obj_10TabProxies_VCFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_VCFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_VCFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   /*--- Function import code ---*/
   /*--- Execution code ---*/
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":4
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":4
  * # adds doc-strings for sphinx
  * 
- * import tempfile, os, sys, types, itertools, struct, ctypes             # <<<<<<<<<<<<<<
- * 
- * cdef class Tabixfile:
+ * import tempfile, os, sys, types, itertools, struct, ctypes, gzip             # <<<<<<<<<<<<<<
+ * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+ * cimport TabProxies
  */
   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__tempfile), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
@@ -11308,54 +7580,58 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __Pyx_GOTREF(__pyx_t_1);
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__gzip), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gzip, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":743
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":364
  * def tabix_compress( filename_in,
  *               filename_out,
  *               force = False ):             # <<<<<<<<<<<<<<
  * 
  *     '''
  */
-  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_k_28 = __pyx_t_1;
+  __pyx_k_14 = __pyx_t_1;
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":787
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":408
  * 
  * def tabix_index( filename,
  *                  force = False,             # <<<<<<<<<<<<<<
  *                  seq_col = None,
  *                  start_col = None,
  */
-  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_k_33 = __pyx_t_1;
+  __pyx_k_19 = __pyx_t_1;
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":793
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":414
  *                  preset = None,
  *                  meta_char = "#",
  *                  zerobased = False,             # <<<<<<<<<<<<<<
  *                 ):
  *     '''
  */
-  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_k_35 = __pyx_t_1;
+  __pyx_k_21 = __pyx_t_1;
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":876
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":497
  *     return filename
  * 
  * __all__ = ["tabix_index",             # <<<<<<<<<<<<<<
  *            "tabix_compress",
  *            "Tabixfile",
  */
-  __pyx_t_1 = PyList_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_index));
   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tabix_index));
@@ -11372,10 +7648,16 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __Pyx_INCREF(((PyObject *)__pyx_n_s__asGTF));
   PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__asGTF));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asGTF));
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__asVCF));
+  PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__asVCF));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asVCF));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__asBed));
+  PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__asBed));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asBed));
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/net/cpp-compute/backup/andreas/projects/pysam/pysam/pysam/ctabix.pyx":1
+  /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":1
  * # cython: embedsignature=True             # <<<<<<<<<<<<<<
  * # adds doc-strings for sphinx
  * 
@@ -11390,7 +7672,7 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_51), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_28), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
@@ -11400,7 +7682,7 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_52), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_29), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
@@ -11410,7 +7692,7 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_53), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_30), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
@@ -11420,134 +7702,73 @@ PyMODINIT_FUNC PyInit_ctabix(void)
   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_54), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_31), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIterator); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____get__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_55), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__toDot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_56), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__quote); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_57), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TupleProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_32), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_58), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__asDict); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIterator); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_59), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fromDict); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_33), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_60), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__invert); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixHeaderIterator); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_61), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_34), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_62), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIteratorParsed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_63), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__GTFProxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setAttribute); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_35), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_64), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIteratorParsed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____next__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_65), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_36), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_66), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_37), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_67), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/ctabix.pxd":2
+  /* "/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/Cython-0.13-py2.7-linux-x86_64.egg/Cython/Includes/cpython/type.pxd":2
+ * 
+ * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
+ *     # The C structure of the objects used to describe built-in types.
  * 
- * cdef extern from "string.h":             # <<<<<<<<<<<<<<
- *   ctypedef int size_t
- *   void *memcpy(void *dst,void *src,size_t len)
  */
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -11798,33 +8019,6 @@ static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed
     return 0;
 }
 
-static double __Pyx__PyObject_AsDouble(PyObject* obj) {
-    PyObject* float_value;
-    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
-        return PyFloat_AsDouble(obj);
-    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
-#if PY_MAJOR_VERSION >= 3
-        float_value = PyFloat_FromString(obj);
-#else
-        float_value = PyFloat_FromString(obj, 0);
-#endif
-    } else {
-        PyObject* args = PyTuple_New(1);
-        if (unlikely(!args)) goto bad;
-        PyTuple_SET_ITEM(args, 0, obj);
-        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
-        PyTuple_SET_ITEM(args, 0, 0);
-        Py_DECREF(args);
-    }
-    if (likely(float_value)) {
-        double value = PyFloat_AS_DOUBLE(float_value);
-        Py_DECREF(float_value);
-        return value;
-    }
-bad:
-    return (double)-1;
-}
-
 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
     PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
 }
@@ -12069,83 +8263,6 @@ bad:
 }
 #endif
 
-static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
-    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
-    const int is_unsigned = const_zero < neg_one;
-    if ((sizeof(uint32_t) == sizeof(char))  ||
-        (sizeof(uint32_t) == sizeof(short))) {
-        return PyInt_FromLong((long)val);
-    } else if ((sizeof(uint32_t) == sizeof(int)) ||
-               (sizeof(uint32_t) == sizeof(long))) {
-        if (is_unsigned)
-            return PyLong_FromUnsignedLong((unsigned long)val);
-        else
-            return PyInt_FromLong((long)val);
-    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
-        if (is_unsigned)
-            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
-        else
-            return PyLong_FromLongLong((PY_LONG_LONG)val);
-    } else {
-        int one = 1; int little = (int)*(unsigned char *)&one;
-        unsigned char *bytes = (unsigned char *)&val;
-        return _PyLong_FromByteArray(bytes, sizeof(uint32_t), 
-                                     little, !is_unsigned);
-    }
-}
-
-static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject* x) {
-    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
-    const int is_unsigned = const_zero < neg_one;
-    if (sizeof(uint32_t) == sizeof(char)) {
-        if (is_unsigned)
-            return (uint32_t)__Pyx_PyInt_AsUnsignedChar(x);
-        else
-            return (uint32_t)__Pyx_PyInt_AsSignedChar(x);
-    } else if (sizeof(uint32_t) == sizeof(short)) {
-        if (is_unsigned)
-            return (uint32_t)__Pyx_PyInt_AsUnsignedShort(x);
-        else
-            return (uint32_t)__Pyx_PyInt_AsSignedShort(x);
-    } else if (sizeof(uint32_t) == sizeof(int)) {
-        if (is_unsigned)
-            return (uint32_t)__Pyx_PyInt_AsUnsignedInt(x);
-        else
-            return (uint32_t)__Pyx_PyInt_AsSignedInt(x);
-    } else if (sizeof(uint32_t) == sizeof(long)) {
-        if (is_unsigned)
-            return (uint32_t)__Pyx_PyInt_AsUnsignedLong(x);
-        else
-            return (uint32_t)__Pyx_PyInt_AsSignedLong(x);
-    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
-        if (is_unsigned)
-            return (uint32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
-        else
-            return (uint32_t)__Pyx_PyInt_AsSignedLongLong(x);
-    }  else {
-        uint32_t val;
-        PyObject *v = __Pyx_PyNumber_Int(x);
-        #if PY_VERSION_HEX < 0x03000000
-        if (likely(v) && !PyLong_Check(v)) {
-            PyObject *tmp = v;
-            v = PyNumber_Long(tmp);
-            Py_DECREF(tmp);
-        }
-        #endif
-        if (likely(v)) {
-            int one = 1; int is_little = (int)*(unsigned char *)&one;
-            unsigned char *bytes = (unsigned char *)&val;
-            int ret = _PyLong_AsByteArray((PyLongObject *)v,
-                                          bytes, sizeof(val),
-                                          is_little, !is_unsigned);
-            Py_DECREF(v);
-            if (likely(!ret))
-                return val;
-        }
-        return (uint32_t)-1;
-    }
-}
-
 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
     const int is_unsigned = const_zero < neg_one;
@@ -12598,15 +8715,95 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
     }
 }
 
-static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
-    PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
-    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+    long size, int strict)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+    char warning[200];
+
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(class_name);
+    #else
+    py_name = PyUnicode_FromString(class_name);
+    #endif
+    if (!py_name)
+        goto bad;
+    result = PyObject_GetAttr(py_module, py_name);
+    Py_DECREF(py_name);
+    py_name = 0;
+    Py_DECREF(py_module);
+    py_module = 0;
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError, 
+            "%s.%s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
+        PyOS_snprintf(warning, sizeof(warning), 
+            "%s.%s size changed, may indicate binary incompatibility",
+            module_name, class_name);
+        #if PY_VERSION_HEX < 0x02050000
+        PyErr_Warn(NULL, warning);
+        #else
+        PyErr_WarnEx(NULL, warning, 0);
+        #endif
+    }
+    else if (((PyTypeObject *)result)->tp_basicsize != size) {
+        PyErr_Format(PyExc_ValueError, 
+            "%s.%s has the wrong size, try recompiling",
+            module_name, class_name);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_module);
+    Py_XDECREF(result);
+    return 0;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(name);
+    #else
+    py_name = PyUnicode_FromString(name);
+    #endif
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
 #endif
+
+static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
+    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
     if (!ob)
         goto bad;
-    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+    *(void **)vtabptr = PyCapsule_GetPointer(ob, 0);
+#else
+    *(void **)vtabptr = PyCObject_AsVoidPtr(ob);
+#endif
+    if (!*(void **)vtabptr)
         goto bad;
     Py_DECREF(ob);
     return 0;
index ef735b64f9230f8851b1ab147a77fcad2835ce1b..950e28e6252b9d741b71d26fc13e03ee5e0a427a 100644 (file)
@@ -101,9 +101,14 @@ cdef extern from "bgzf.h":
 # tabix support
 cdef extern from "tabix.h":
 
-  ctypedef struct ti_index_t:
-    pass
+  ctypedef struct ti_conf_t:
+    int32_t preset
+    int32_t sc, bc, ec
+    int32_t meta_char, line_skip
 
+  ctypedef struct ti_index_t:
+     pass
+      
   ctypedef struct tabix_t: 
     BGZF *fp
     ti_index_t *idx
@@ -113,11 +118,6 @@ cdef extern from "tabix.h":
   ctypedef struct ti_iter_t:
     pass
 
-  ctypedef struct ti_conf_t:
-    int32_t preset
-    int32_t sc, bc, ec
-    int32_t meta_char, line_skip
-
   tabix_t *ti_open(char *fn, char *fnidx)
 
   int ti_lazy_index_load(tabix_t *t)
@@ -135,7 +135,6 @@ cdef extern from "tabix.h":
   #    pointer should be freed by a single free() call by the routine
   #    calling this function. The number of sequences is returned at *n
   char **ti_seqname(ti_index_t *idx, int *n)
-
   
   # Destroy the iterator
   void ti_iter_destroy(ti_iter_t iter)
@@ -169,3 +168,12 @@ cdef extern from "tabix.h":
 
   #  /* Get the data line pointed by the iterator and iterate to the next record. */
   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
+
+cdef class Tabixfile:
+    cdef char * filename
+
+    # pointer to tabixfile
+    cdef tabix_t * tabixfile
+     
+cdef class Parser:
+     pass
index 8715e5d4cf8f4c2e9ff275d001c4697ed7eb206b..25c1a1ee732df3e383a29e80c1ea2ae533b7925e 100644 (file)
@@ -1,7 +1,9 @@
 # cython: embedsignature=True
 # adds doc-strings for sphinx
 
-import tempfile, os, sys, types, itertools, struct, ctypes
+import tempfile, os, sys, types, itertools, struct, ctypes, gzip
+from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+cimport TabProxies
 
 cdef class Tabixfile:
     '''*(filename, mode='r')*
@@ -10,11 +12,6 @@ cdef class Tabixfile:
     index (*filename* + ".tbi") will raise an exception.
     '''
 
-    cdef char * filename
-
-    # pointer to tabixfile
-    cdef tabix_t * tabixfile
-
     def __cinit__(self, *args, **kwargs ):
         self.tabixfile = NULL
         self._open( *args, **kwargs )
@@ -139,19 +136,27 @@ cdef class Tabixfile:
             else:
                 return TabixIteratorParsed( self, -1, 0, 0, parser )
 
+    property header:
+        def __get__( self ):
+            '''return header lines as an iterator.
+
+            Note that the header lines do not contain the newline '\n' character.
+            '''
+            return TabixHeaderIterator( self )
+
     property contigs:
-       '''chromosome names'''
-       def __get__(self):
-           cdef char ** sequences
-           cdef int nsequences
+        '''chromosome names'''
+        def __get__(self):
+            cdef char ** sequences
+            cdef int nsequences
            
-           ti_lazy_index_load( self.tabixfile )
-           sequences = ti_seqname( self.tabixfile.idx, &nsequences ) 
-           cdef int x
-           result = []
-           for x from 0 <= x < nsequences:
-               result.append( sequences[x] )
-           return result
+            ti_lazy_index_load( self.tabixfile )
+            sequences = ti_seqname( self.tabixfile.idx, &nsequences ) 
+            cdef int x
+            result = []
+            for x from 0 <= x < nsequences:
+                result.append( sequences[x] )
+            return result
             
 cdef class TabixIterator:
     """iterates over rows in *tabixfile* in region
@@ -192,487 +197,78 @@ cdef class TabixIterator:
     
         cdef char * s
         cdef int len
-        s = ti_read(self.tabixfile, self.iterator, &len)
-        if s == NULL: raise StopIteration
+        # metachar filtering does not work within tabix 
+        # though it should. Getting the metachar is a pain
+        # as ti_index_t is incomplete type.
+
+        # simply use '#' for now.
+        while 1:
+            s = ti_read(self.tabixfile, self.iterator, &len)
+            if s == NULL: raise StopIteration
+            if s[0] != '#': break
+
         return s
 
     def __dealloc__(self):
         if <void*>self.iterator != NULL:
             ti_iter_destroy(self.iterator)
 
-def toDot( v ):
-    '''convert value to '.' if None'''
-    if v == None: return "." 
-    else: return str(v)
-
-def quote( v ):
-    '''return a quoted attribute.'''
-    if type(v) in types.StringTypes:
-        return '"%s"' % v
-    else: 
-        return str(v)
-
-cdef class TupleProxy:
-    '''Proxy class for access to parsed row as a tuple.
-
-    This class represents a table row for fast read-access.
-    '''
-
-    cdef:
-        char * data
-        char ** fields
-        int nfields
-        int index
-
-    def __cinit__(self ): 
-
-        self.data = NULL
-        self.fields = NULL
-        self.index = 0
-
-    cdef take( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
-
-        Take ownership of the pointer.
-        '''
-        self.data = buffer
-        self.update( buffer, nbytes )
-
-    cdef present( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
-
-        Do not take ownership of the pointer.
-        '''
-        self.update( buffer, nbytes )
-
-    cdef copy( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
+cdef class TabixHeaderIterator:
+    """return header lines.
+    """
+    
+    cdef ti_iter_t iterator
+    cdef tabix_t * tabixfile
 
-        Take a copy of buffer.
-        '''
-        cdef int s
-        # +1 for '\0'
-        s = sizeof(char) *  (nbytes + 1)
-        self.data = <char*>malloc( s ) 
-        memcpy( <char*>self.data, buffer, s )
-        self.update( self.data, nbytes )
-
-    cdef update( self, char * buffer, size_t nbytes ):
-        '''update internal data.'''
-        cdef char * pos
-        cdef char * old_pos
-        cdef int field
-        cdef int max_fields
-        field = 0
-
-        if buffer[nbytes] != 0:
-            raise ValueError( "incomplete line at %s" % buffer )
+    def __cinit__(self, Tabixfile tabixfile ):
         
-        if self.fields != NULL:
-            free(self.fields)
-        
-        max_fields = nbytes / 4
-        self.fields = <char **>calloc( max_fields, sizeof(char *) ) 
-        
-        pos = buffer
-        self.fields[0] = pos
-        field += 1
-        old_pos = pos
+        assert tabixfile._isOpen()
         
-        while 1:
-
-            pos = <char*>memchr( pos, '\t', nbytes )
-            if pos == NULL: break
-            pos[0] = '\0'
-            pos += 1
-            self.fields[field] = pos
-            field += 1
-            if field >= max_fields:
-                raise ValueError("row too large - more than %i fields" % max_fields )
-            nbytes -= pos - old_pos
-            if nbytes < 0: break
-            old_pos = pos
-
-        self.nfields = field
-
-    def __getitem__( self, key ):
-
-        cdef int i
-        i = key
-        if i < 0: i += self.nfields
-        if i >= self.nfields or i < 0:
-            raise IndexError( "list index out of range" )
-        return self.fields[i]
+        # makes sure that samfile stays alive as long as the
+        # iterator is alive.
+        self.tabixfile = tabixfile.tabixfile
 
-    def __len__(self):
-        return self.nfields
+        self.iterator = ti_query(self.tabixfile, NULL, 0, 0) 
 
-    def __dealloc__(self):
-        if self.data != NULL:
-            free(self.data)
+        if <void*>self.iterator == NULL:
+            raise ValueError("can't open header.\n")
 
     def __iter__(self):
-        self.index = 0
-        return self
+        return self 
 
     def __next__(self): 
         """python version of next().
-        """
-        if self.index >= self.nfields:
-            raise StopIteration
-        self.index += 1
-        return self.fields[self.index-1]
 
-cdef class GTFProxy:
-    '''Proxy class for access to GTF fields.
-
-    This class represents a GTF entry for fast read-access.
-    Write-access has been added as well, though some care must
-    be taken. If any of the string fields (contig, source, ...)
-    are set, the new value is tied to the lifetime of the
-    argument that was supplied.
-
-    The only exception is the attributes field when set from
-    a dictionary - this field will manage its own memory.
-
-    '''
-
-    cdef:
-        char * contig
-        char * source
-        char * feature
-        uint32_t start
-        uint32_t end
-        char * score
-        char * strand
-        char * frame
-        char * attributes
-        int nbytes
-        char * data
-        cdef bint isModified
-        cdef bint hasOwnAttributes
-
-    def __cinit__(self ): 
-        self.data = NULL
-        self.isModified = False
-        self.hasOwnAttributes = False
-
-    cdef take( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
-
-        Take ownership of the pointer.
-        '''
-        self.data = buffer
-        self.update( buffer, nbytes )
-        self.isModified = False
-
-    cdef present( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
-
-        Do not take ownership of the pointer.
-        '''
-        self.update( buffer, nbytes )
-        self.isModified = False
-
-    cdef copy( self, char * buffer, size_t nbytes ):
-        '''start presenting buffer.
-
-        Take a copy of buffer.
-        '''
-        cdef int s
-        # +1 for '\0'
-        s = sizeof(char) *  (nbytes + 1)
-        self.data = <char*>malloc( s ) 
-        memcpy( <char*>self.data, buffer, s )
-        self.update( self.data, nbytes )
-        self.isModified = False
-
-    cdef update( self, char * buffer, size_t nbytes ):
-        '''update internal data.
-
-        nbytes does not include the terminal '\0'.
-        '''
-        cdef int end
-        cdef char * cstart, * cend, * cscore
-        self.contig = buffer
-        self.nbytes = nbytes
-        cdef char * pos
-
-        if buffer[nbytes] != 0:
-            raise ValueError( "incomplete line at %s" % buffer )
-        
-        pos = strchr( buffer, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.source = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.feature = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        cstart = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        cend = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.score = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.strand = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.frame = pos
-
-        pos = strchr( pos, '\t' )
-        if pos == NULL: raise ValueError( "malformatted entry at %s" % buffer )
-        pos[0] = '\0'
-        pos += 1
-        self.attributes = pos
-        self.start = atoi( cstart ) - 1
-        self.end = atoi( cend )
-                      
-    property contig:
-       '''contig of feature.'''
-       def __get__( self ): return self.contig
-       def __set__( self, value ): 
-           self.isModified = True
-           self.contig = value
-
-    property feature:
-       '''feature name.'''
-       def __get__( self ): return self.feature
-       def __set__( self, value ): 
-           self.isModified = True
-           self.feature = value
-
-    property source:
-       '''feature source.'''
-       def __get__( self ): return self.source
-       def __set__( self, value ): 
-           self.isModified = True
-           self.source = value
-
-    property start:
-       '''feature start (in 0-based open/closed coordinates).'''
-       def __get__( self ): return self.start
-       def __set__( self, value ): 
-           self.isModified = True
-           self.start = value
-
-    property end:
-       '''feature end (in 0-based open/closed coordinates).'''
-       def __get__( self ): return self.end
-       def __set__( self, value ): 
-           self.isModified = True
-           self.end = value
-
-    property score:
-       '''feature score.'''
-       def __get__( self ): 
-           if self.score[0] == '.' and self.score[1] == '\0' :
-               return None
-           else:
-               return atof(self.score)
-       def __set__( self, value ): 
-           self.isModified = True
-           self.score = value
-
-    property strand:
-       '''feature strand.'''
-       def __get__( self ): return self.strand
-       def __set__( self, value ): 
-           self.isModified = True
-           self.strand = value
-
-    property frame:
-       '''feature frame.'''
-       def __get__( self ): return self.frame
-       def __set__( self, value ): 
-           self.isModified = True
-           self.frame = value
-
-    property attributes:
-       '''feature attributes (as a string).'''
-       def __get__( self ): return self.attributes
-       def __set__( self, value ): 
-           self.isModified = True
-           self.attributes = value
-
-    def asDict( self ):
-        """parse attributes - return as dict
+        pyrex uses this non-standard name instead of next()
         """
-
-        # remove comments
-        attributes = self.attributes
-
-        # separate into fields
-        fields = [ x.strip() for x in attributes.split(";")[:-1]]
-        
-        result = {}
-
-        for f in fields:
-            
-            d = [ x.strip() for x in f.split(" ")]
-            
-            n,v = d[0], d[1]
-            if len(d) > 2: v = d[1:]
-
-            if v[0] == '"' and v[-1] == '"':
-                v = v[1:-1]
-            else:
-                ## try to convert to a value
-                try:
-                    v = float( v )
-                    v = int( v )
-                except ValueError:
-                    pass
-                except TypeError:
-                    pass
-
-            result[n] = v
-        
-        return result
     
-    def fromDict( self, d ):
-        '''set attributes from a dictionary.'''
-        cdef char * p
-        cdef int l
-
-        # clean up if this field is set twice
-        if self.hasOwnAttributes:
-            free(self.attributes)
-
-        aa = []
-        for k,v in d.items():
-            if type(v) == types.StringType:
-                aa.append( '%s "%s"' % (k,v) )
-            else:
-                aa.append( '%s %s' % (k,str(v)) )
-
-        a = "; ".join( aa ) + ";"
-        p = a
-        l = len(a)
-        self.attributes = <char *>calloc( l + 1, sizeof(char) )
-        memcpy( self.attributes, p, l )
-
-        self.hasOwnAttributes = True
-        self.isModified = True
-
-    def __str__(self):
-        cdef char * cpy
-        cdef int x
-
-        if self.isModified:
-            return "\t".join( 
-                (self.contig, 
-                 self.source, 
-                 self.feature, 
-                 str(self.start+1),
-                 str(self.end),
-                 toDot(self.score),
-                 self.strand,
-                 self.frame,
-                 self.attributes ) )
-        else: 
-            cpy = <char*>calloc( sizeof(char), self.nbytes+1 )
-            memcpy( cpy, self.data, self.nbytes+1)
-            for x from 0 <= x < self.nbytes:
-                if cpy[x] == '\0': cpy[x] = '\t'
-            result = cpy
-            free(cpy)
-            return result
-
-    def invert( self, int lcontig ):
-        '''invert coordinates to negative strand coordinates
-        
-        This method will only act if the feature is on the
-        negative strand.'''
-
-        if self.strand[0] == '-':
-            start = min(self.start, self.end)
-            end = max(self.start, self.end)
-            self.start, self.end = lcontig - end, lcontig - start
+        cdef char * s
+        cdef int len
 
-    def keys( self ):
-        '''return a list of attributes defined in this entry.'''
-        r = self.attributes
-        return [ x.strip().split(" ")[0] for x in r.split(";") if x.strip() != '' ]
+        # Getting the metachar is a pain as ti_index_t is incomplete type.
+        # simply use '#' for now.
+        s = ti_read(self.tabixfile, self.iterator, &len)
+        if s == NULL: raise StopIteration
+        # stop at first non-header line
+        if s[0] != '#': raise StopIteration
 
-    def __getitem__(self, item):
-        return self.__getattr__( item )
+        return s
 
     def __dealloc__(self):
-        if self.data != NULL:
-            free(self.data)
-        if self.hasOwnAttributes:
-            free(self.attributes)
-
-    def __getattr__(self, item ):
-        """Generic lookup of attribute from GFF/GTF attributes 
-        Only called if there *isn't* an attribute with this name
-        """
-        cdef char * start
-        cdef char * query 
-        cdef char * cpy
-        cdef char * end
-        cdef int l
-        query = item
-        
-        start = strstr( self.attributes, query)
-        if start == NULL:
-            raise AttributeError("'GTFProxy' has no attribute '%s'" % item )
-
-        start += strlen(query) + 1
-        # skip gaps before
-        while start[0] == " ": start += 1
-        if start[0] == '"':
-            start += 1
-            end = start
-            while end[0] != '\0' and end[0] != '"': end += 1
-            l = end - start + 1
-            cpy = <char*>calloc( l, sizeof(char ) )
-            memcpy( cpy, start, l )
-            cpy[l-1] = '\0'
-            result = cpy
-            free(cpy)
-            return result
-        else:
-            return start
-
-    def setAttribute( self, name, value ):
-        '''convenience method to set an attribute.'''
-        r = self.asDict()
-        r[name] = value
-        self.fromDict( r )
+        if <void*>self.iterator != NULL:
+            ti_iter_destroy(self.iterator)
 
+#########################################################
+#########################################################
+#########################################################
 cdef class Parser:
     pass
 
 cdef class asTuple(Parser):
     '''converts a :term:`tabix row` into a python tuple.''' 
     def __call__(self, char * buffer, int len):
-        cdef TupleProxy r
-        r = TupleProxy()
+        cdef TabProxies.TupleProxy r
+        r = TabProxies.TupleProxy()
         # need to copy - there were some
         # persistence issues with "present"
         r.copy( buffer, len )
@@ -681,15 +277,36 @@ cdef class asTuple(Parser):
 cdef class asGTF(Parser):
     '''converts a :term:`tabix row` into a GTF record.''' 
     def __call__(self, char * buffer, int len):
-        cdef GTFProxy r
-        r = GTFProxy()
+        cdef TabProxies.GTFProxy r
+        r = TabProxies.GTFProxy()
         r.copy( buffer, len )
         return r
 
+cdef class asBed( Parser ):
+    '''converts a :term:`tabix row` into a GTF record.''' 
+    def __call__(self, char * buffer, int len):
+        cdef TabProxies.BedProxy r
+        r = TabProxies.BedProxy()
+        r.copy( buffer, len )
+        return r
+
+cdef class asVCF( Parser ): 
+    '''converts a :term:`tabix row` into a VCF record.'''
+    def __call__(self, char * buffer, int len ):
+        cdef TabProxies.VCFProxy r
+        r = TabProxies.VCFProxy()
+        r.copy( buffer, len )
+        return r
+    
+#########################################################
+#########################################################
+#########################################################
 cdef class TabixIteratorParsed:
     """iterates over mapped reads in a region.
+
+    Returns parsed data.
     """
-    
+
     cdef ti_iter_t iterator
     cdef tabix_t * tabixfile
     cdef Parser parser
@@ -730,8 +347,12 @@ cdef class TabixIteratorParsed:
     
         cdef char * s
         cdef int len
-        s = ti_read(self.tabixfile, self.iterator, &len)
-        if s == NULL: raise StopIteration
+        while 1:
+            s = ti_read(self.tabixfile, self.iterator, &len)
+            if s == NULL: raise StopIteration
+            # todo: read metachar from configuration
+            if s[0] != '#': break
+            
         return self.parser(s, len)
 
     def __dealloc__(self):
@@ -878,4 +499,6 @@ __all__ = ["tabix_index",
            "Tabixfile", 
            "asTuple",
            "asGTF",
+           "asVCF",
+           "asBed",
            ]
diff --git a/pysam/cvcf.c b/pysam/cvcf.c
new file mode 100644 (file)
index 0000000..82eae7d
--- /dev/null
@@ -0,0 +1,26340 @@
+/* Generated by Cython 0.13 on Thu May  5 15:40:49 2011 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#else
+
+#include <stddef.h> /* For offsetof */
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
+  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
+  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
+#endif
+
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+     void *buf;
+     PyObject *obj;
+     Py_ssize_t len;
+     Py_ssize_t itemsize;
+     int readonly;
+     int ndim;
+     char *format;
+     Py_ssize_t *shape;
+     Py_ssize_t *strides;
+     Py_ssize_t *suboffsets;
+     void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+
+#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+
+#if PY_VERSION_HEX < 0x02060000
+  #define PyBytesObject                PyStringObject
+  #define PyBytes_Type                 PyString_Type
+  #define PyBytes_Check                PyString_Check
+  #define PyBytes_CheckExact           PyString_CheckExact
+  #define PyBytes_FromString           PyString_FromString
+  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
+  #define PyBytes_FromFormat           PyString_FromFormat
+  #define PyBytes_DecodeEscape         PyString_DecodeEscape
+  #define PyBytes_AsString             PyString_AsString
+  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
+  #define PyBytes_Size                 PyString_Size
+  #define PyBytes_AS_STRING            PyString_AS_STRING
+  #define PyBytes_GET_SIZE             PyString_GET_SIZE
+  #define PyBytes_Repr                 PyString_Repr
+  #define PyBytes_Concat               PyString_Concat
+  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
+  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
+  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
+#endif
+
+#ifndef PySet_CheckExact
+#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject PyLongObject
+#endif
+
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
+#endif
+
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#define __PYX_HAVE_API__cvcf
+#include "stdlib.h"
+#include "string.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "ctype.h"
+#include "sys/types.h"
+#include "sys/stat.h"
+#include "fcntl.h"
+#include "unistd.h"
+#include "bgzf.h"
+#include "tabix.h"
+
+/* inline attribute */
+#ifndef CYTHON_INLINE
+  #if defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE 
+  #endif
+#endif
+
+/* unused attribute */
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__)) 
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || defined(__INTEL_COMPILER)
+#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
+# else
+#   define CYTHON_UNUSED 
+# endif
+#endif
+
+typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
+
+
+/* Type Conversion Predeclarations */
+
+#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
+#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+
+#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "cvcf.pyx",
+  "ctabix.pxd",
+  "TabProxies.pxd",
+};
+
+/* Type declarations */
+
+/* "pysam/TabProxies.pxd":42
+ *   ctypedef int uint64_t
+ * 
+ * cdef class TupleProxy:             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_TupleProxy {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtab;
+  char *data;
+  char **fields;
+  int nfields;
+  int index;
+  int nbytes;
+  int offset;
+  int is_modified;
+};
+
+/* "pysam/TabProxies.pxd":77
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+
+struct __pyx_obj_10TabProxies_NamedTupleProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+};
+
+/* "pysam/TabProxies.pxd":80
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_BedProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t start;
+  uint32_t end;
+  int bedfields;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":94
+ * ###########################################################################################################
+ * 
+ * cdef class VCFRecord( TabProxies.TupleProxy):             # <<<<<<<<<<<<<<
+ *     '''vcf record.
+ * 
+ */
+
+struct __pyx_obj_4cvcf_VCFRecord {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+  PyObject *vcf;
+  char *contig;
+  uint32_t pos;
+};
+
+/* "pysam/TabProxies.pxd":91
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_VCFProxy {
+  struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t pos;
+};
+
+/* "pysam/ctabix.pxd":178
+ *     cdef tabix_t * tabixfile
+ * 
+ * cdef class Parser:             # <<<<<<<<<<<<<<
+ *      pass
+ */
+
+struct __pyx_obj_6ctabix_Parser {
+  PyObject_HEAD
+};
+
+/* "pysam/TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_obj_10TabProxies_GTFProxy {
+  struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
+  char *contig;
+  char *source;
+  char *feature;
+  uint32_t start;
+  uint32_t end;
+  char *score;
+  char *strand;
+  char *frame;
+  char *attributes;
+  int hasOwnAttributes;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":221
+ * 
+ * 
+ * cdef class asVCFRecord( ctabix.Parser ):             # <<<<<<<<<<<<<<
+ *     '''converts a :term:`tabix row` into a VCF record.'''
+ *     cdef vcffile
+ */
+
+struct __pyx_obj_4cvcf_asVCFRecord {
+  struct __pyx_obj_6ctabix_Parser __pyx_base;
+  PyObject *vcffile;
+};
+
+/* "pysam/ctabix.pxd":172
+ *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
+ * 
+ * cdef class Tabixfile:             # <<<<<<<<<<<<<<
+ *     cdef char * filename
+ * 
+ */
+
+struct __pyx_obj_6ctabix_Tabixfile {
+  PyObject_HEAD
+  char *filename;
+  tabix_t *tabixfile;
+};
+
+
+/* "pysam/TabProxies.pxd":42
+ *   ctypedef int uint64_t
+ * 
+ * cdef class TupleProxy:             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_TupleProxy {
+  int (*getMaxFields)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t);
+  PyObject *(*take)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*present)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*copy)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+  PyObject *(*update)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
+};
+static struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtabptr_10TabProxies_TupleProxy;
+
+
+/* "pysam/TabProxies.pxd":77
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+
+struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
+
+
+/* "pysam/TabProxies.pxd":91
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_VCFProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_VCFProxy *__pyx_vtabptr_10TabProxies_VCFProxy;
+
+
+/* "pysam/TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_GTFProxy {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_GTFProxy *__pyx_vtabptr_10TabProxies_GTFProxy;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":94
+ * ###########################################################################################################
+ * 
+ * cdef class VCFRecord( TabProxies.TupleProxy):             # <<<<<<<<<<<<<<
+ *     '''vcf record.
+ * 
+ */
+
+struct __pyx_vtabstruct_4cvcf_VCFRecord {
+  struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_4cvcf_VCFRecord *__pyx_vtabptr_4cvcf_VCFRecord;
+
+
+/* "pysam/TabProxies.pxd":80
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+
+struct __pyx_vtabstruct_10TabProxies_BedProxy {
+  struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
+};
+static struct __pyx_vtabstruct_10TabProxies_BedProxy *__pyx_vtabptr_10TabProxies_BedProxy;
+
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+  end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+  }
+  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
+#else
+  #define __Pyx_RefNannySetupContext(name)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
+#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name, PyObject* kw_name); /*proto*/
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
+
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+
+
+#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+            PyObject *r = PyList_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+
+#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Fast(o, i) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
+        r = PySequence_GetItem(o, i);
+    }
+    else {
+        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+    }
+    return r;
+}
+
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
+static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
+
+#define __Pyx_PyObject_AsDouble(obj) \
+    ((likely(PyFloat_CheckExact(obj))) ? \
+     PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
+
+static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
+
+
+#if PY_MAJOR_VERSION >= 3
+static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
+    PyObject *value;
+    if (unlikely(d == Py_None)) {
+        __Pyx_RaiseNoneIndexingError();
+        return NULL;
+    }
+    value = PyDict_GetItemWithError(d, key);
+    if (unlikely(!value)) {
+        if (!PyErr_Occurred())
+            PyErr_SetObject(PyExc_KeyError, key);
+        return NULL;
+    }
+    Py_INCREF(value);
+    return value;
+}
+#else
+    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
+#endif
+
+static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
+static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
+    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
+static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
+static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
+
+static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); /* proto */
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
+    if (likely(PyList_CheckExact(L))) {
+        if (PyList_Append(L, x) < 0) return NULL;
+        Py_INCREF(Py_None);
+        return Py_None; /* this is just to have an accurate signature */
+    }
+    else {
+        PyObject *r, *m;
+        m = __Pyx_GetAttrString(L, "append");
+        if (!m) return NULL;
+        r = PyObject_CallFunctionObjArgs(m, x, NULL);
+        Py_DECREF(m);
+        return r;
+    }
+}
+
+#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
+                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
+
+static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
+    int r;
+    if (!j) return -1;
+    r = PyObject_SetItem(o, j, v);
+    Py_DECREF(j);
+    return r;
+}
+
+static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        Py_INCREF(v);
+        Py_DECREF(PyList_GET_ITEM(o, i));
+        PyList_SET_ITEM(o, i, v);
+        return 1;
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
+        return PySequence_SetItem(o, i, v);
+    else {
+        PyObject *j = PyInt_FromSsize_t(i);
+        return __Pyx_SetItemInt_Generic(o, j, v);
+    }
+}
+
+#if PY_VERSION_HEX < 0x02050000
+#ifndef PyAnySet_CheckExact
+
+#define PyAnySet_CheckExact(ob) \
+    ((ob)->ob_type == &PySet_Type || \
+     (ob)->ob_type == &PyFrozenSet_Type)
+
+#define PySet_New(iterable) \
+    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
+
+#define Pyx_PyFrozenSet_New(iterable) \
+    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
+
+#define PySet_Size(anyset) \
+    PyObject_Size((anyset))
+
+#define PySet_Contains(anyset, key) \
+    PySequence_Contains((anyset), (key))
+
+#define PySet_Pop(set) \
+    PyObject_CallMethod(set, (char *)"pop", NULL)
+
+static CYTHON_INLINE int PySet_Clear(PyObject *set) {
+    PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
+    if (!ret) return -1;
+    Py_DECREF(ret); return 0;
+}
+
+static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
+    PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
+    if (!ret) return -1;
+    Py_DECREF(ret); return 0;
+}
+
+static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
+    PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
+    if (!ret) return -1;
+    Py_DECREF(ret); return 0;
+}
+
+#endif /* PyAnySet_CheckExact (<= Py2.4) */
+
+#if PY_VERSION_HEX < 0x02040000
+#ifndef Py_SETOBJECT_H
+#define Py_SETOBJECT_H
+
+static PyTypeObject *__Pyx_PySet_Type = NULL;
+static PyTypeObject *__Pyx_PyFrozenSet_Type = NULL;
+
+#define PySet_Type (*__Pyx_PySet_Type)
+#define PyFrozenSet_Type (*__Pyx_PyFrozenSet_Type)
+
+#define PyAnySet_Check(ob) \
+    (PyAnySet_CheckExact(ob) || \
+     PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
+     PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))
+
+#define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)
+
+static int __Pyx_Py23SetsImport(void) {
+    PyObject *sets=0, *Set=0, *ImmutableSet=0;
+
+    sets = PyImport_ImportModule((char *)"sets");
+    if (!sets) goto bad;
+    Set = PyObject_GetAttrString(sets, (char *)"Set");
+    if (!Set) goto bad;
+    ImmutableSet = PyObject_GetAttrString(sets, (char *)"ImmutableSet");
+    if (!ImmutableSet) goto bad;
+    Py_DECREF(sets);
+
+    __Pyx_PySet_Type       = (PyTypeObject*) Set;
+    __Pyx_PyFrozenSet_Type = (PyTypeObject*) ImmutableSet;
+
+    return 0;
+
+ bad:
+    Py_XDECREF(sets);
+    Py_XDECREF(Set);
+    Py_XDECREF(ImmutableSet);
+    return -1;
+}
+
+#else
+static int __Pyx_Py23SetsImport(void) { return 0; }
+#endif /* !Py_SETOBJECT_H */
+#endif /* < Py2.4  */
+#endif /* < Py2.5  */
+
+static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
+static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);
+
+static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
+
+static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
+
+static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
+
+static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
+
+static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
+
+static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
+
+static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
+
+static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
+
+static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
+
+static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
+
+static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
+
+static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
+
+static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
+
+static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
+
+static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
+
+static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
+
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
+
+static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+/* Module declarations from ctabix */
+
+static PyTypeObject *__pyx_ptype_6ctabix_Tabixfile = 0;
+static PyTypeObject *__pyx_ptype_6ctabix_Parser = 0;
+/* Module declarations from TabProxies */
+
+static PyTypeObject *__pyx_ptype_10TabProxies_TupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_GTFProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_NamedTupleProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_BedProxy = 0;
+static PyTypeObject *__pyx_ptype_10TabProxies_VCFProxy = 0;
+/* Module declarations from cvcf */
+
+static PyTypeObject *__pyx_ptype_4cvcf_VCFRecord = 0;
+static PyTypeObject *__pyx_ptype_4cvcf_asVCFRecord = 0;
+#define __Pyx_MODULE_NAME "cvcf"
+int __pyx_module_is_main_cvcf = 0;
+
+/* Implementation of cvcf */
+static PyObject *__pyx_builtin_object;
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_builtin_enumerate;
+static PyObject *__pyx_builtin_map;
+static PyObject *__pyx_builtin_min;
+static PyObject *__pyx_builtin_len;
+static PyObject *__pyx_builtin_zip;
+static PyObject *__pyx_builtin_StopIteration;
+static PyObject *__pyx_builtin_KeyError;
+static PyObject *__pyx_builtin_NotImplementedError;
+static char __pyx_k_1[] = "";
+static char __pyx_k_2[] = ",";
+static char __pyx_k_3[] = ":";
+static char __pyx_k_4[] = "-";
+static char __pyx_k_5[] = "Don't understand region string '%s'";
+static char __pyx_k_6[] = ".";
+static char __pyx_k_7[] = ";";
+static char __pyx_k_8[] = "=";
+static char __pyx_k_9[] = "BAD_NUMBER_OF_VALUES";
+static char __pyx_k_10[] = "(found %s values in element %s; expected %s)";
+static char __pyx_k_11[] = "BAD_NUMBER_OF_PARAMETERS";
+static char __pyx_k_12[] = "id=%s, expected %s parameters, got %s";
+static char __pyx_k_14[] = "Line %s: '%s'\n%s %s: %s\n";
+static char __pyx_k_16[] = "<";
+static char __pyx_k_17[] = "V40_MISSING_ANGLE_BRACKETS";
+static char __pyx_k_18[] = ">";
+static char __pyx_k_19[] = "\"";
+static char __pyx_k_20[] = "V40_FORMAT_MUST_HAVE_NAMED_FIELDS";
+static char __pyx_k_21[] = "BADLY_FORMATTED_FORMAT_STRING";
+static char __pyx_k_22[] = "ID=";
+static char __pyx_k_23[] = "Number=";
+static char __pyx_k_24[] = "Type=";
+static char __pyx_k_25[] = "Description=";
+static char __pyx_k_26[] = "FORMAT_MISSING_QUOTES";
+static char __pyx_k_27[] = "<none>";
+static char __pyx_k_28[] = "#alleles";
+static char __pyx_k_29[] = "#nonref_alleles";
+static char __pyx_k_30[] = "#genotypes";
+static char __pyx_k_31[] = "#phased_genotypes";
+static char __pyx_k_33[] = "Unknown number type encountered: %s";
+static char __pyx_k_34[] = "%s=%s";
+static char __pyx_k_35[] = "(Undefined tag)";
+static char __pyx_k_38[] = "(output)";
+static char __pyx_k_39[] = "Genotype Quality";
+static char __pyx_k_40[] = "Read depth at this position for this sample";
+static char __pyx_k_41[] = "Haplotype Quality";
+static char __pyx_k_42[] = "Sample Genotype Filter";
+static char __pyx_k_43[] = "##";
+static char __pyx_k_44[] = "VCFv3.3";
+static char __pyx_k_45[] = "VCFv4.0";
+static char __pyx_k_46[] = "VCFv4.1";
+static char __pyx_k_47[] = "UNKNOWN_FORMAT_STRING";
+static char __pyx_k_48[] = "##fileformat=VCFv%s.%s\n";
+static char __pyx_k_49[] = "##%s=%s\n";
+static char __pyx_k_50[] = "#";
+static char __pyx_k_51[] = "\t";
+static char __pyx_k_52[] = "HEADING_NOT_SEPARATED_BY_TABS";
+static char __pyx_k_53[] = "(%sth entry not found)";
+static char __pyx_k_54[] = "(found %s, expected %s)";
+static char __pyx_k_55[] = "BADLY_FORMATTED_HEADING";
+static char __pyx_k_56[] = "\n";
+static char __pyx_k_57[] = "|";
+static char __pyx_k_58[] = "ERROR_FLAG_HAS_VALUE";
+static char __pyx_k_59[] = "ERROR_FORMAT_NOT_NUMERICAL";
+static char __pyx_k_60[] = "ERROR_FORMAT_NOT_CHAR";
+static char __pyx_k_62[] = "BAD_NUMBER_OF_COLUMNS";
+static char __pyx_k_63[] = "expected %s for %s samples (%s), got %s";
+static char __pyx_k_64[] = "(reference is %s, VCF says %s)";
+static char __pyx_k_65[] = "V33_UNMATCHED_DELETION";
+static char __pyx_k_66[] = "(deletion is %s, reference is %s)";
+static char __pyx_k_67[] = "MISSING_INDEL_ALLELE_REF_BASE";
+static char __pyx_k_68[] = "Required key %s not found in data";
+static char __pyx_k_69[] = "enter_default_format";
+static char __pyx_k_70[] = "Can only handle v3.3 and v4.0 VCF files";
+static char __pyx_k_71[] = "Invalid error string: %s";
+static char __pyx_k_72[] = "needs to be checked";
+static char __pyx_k_73[] = "[|/\\\\]";
+static char __pyx_k_74[] = "^[ACGTN]+$";
+static char __pyx_k_75[] = "id numbertype number type description missingvalue";
+static char __pyx_k_76[] = "UNKNOWN_FORMAT_STRING:Unknown file format identifier";
+static char __pyx_k_77[] = "BADLY_FORMATTED_FORMAT_STRING:Formatting error in the format string";
+static char __pyx_k_78[] = "BADLY_FORMATTED_HEADING:Did not find 9 required headings (CHROM, POS, ..., FORMAT) %s";
+static char __pyx_k_79[] = "BAD_NUMBER_OF_COLUMNS:Wrong number of columns found (%s)";
+static char __pyx_k_80[] = "POS_NOT_NUMERICAL:Position column is not numerical";
+static char __pyx_k_81[] = "UNKNOWN_CHAR_IN_REF:Unknown character in reference field";
+static char __pyx_k_82[] = "V33_BAD_REF:Reference should be single-character in v3.3 VCF";
+static char __pyx_k_83[] = "V33_BAD_ALLELE:Cannot interpret allele for v3.3 VCF";
+static char __pyx_k_84[] = "POS_NOT_POSITIVE:Position field must be >0";
+static char __pyx_k_85[] = "QUAL_NOT_NUMERICAL:Quality field must be numerical, or '.'";
+static char __pyx_k_86[] = "ERROR_INFO_STRING:Error while parsing info field";
+static char __pyx_k_87[] = "ERROR_UNKNOWN_KEY:Unknown key (%s) found in formatted field (info; format; or filter)";
+static char __pyx_k_88[] = "ERROR_FORMAT_NOT_NUMERICAL:Expected integer or float in formatted field; got %s";
+static char __pyx_k_89[] = "ERROR_FORMAT_NOT_CHAR:Eexpected character in formatted field; got string";
+static char __pyx_k_90[] = "FILTER_NOT_DEFINED:Identifier (%s) in filter found which was not defined in header";
+static char __pyx_k_91[] = "FORMAT_NOT_DEFINED:Identifier (%s) in format found which was not defined in header";
+static char __pyx_k_92[] = "BAD_NUMBER_OF_VALUES:Found too many of values in sample column (%s)";
+static char __pyx_k_93[] = "BAD_NUMBER_OF_PARAMETERS:Found unexpected number of parameters (%s)";
+static char __pyx_k_94[] = "BAD_GENOTYPE:Cannot parse genotype (%s)";
+static char __pyx_k_95[] = "V40_BAD_ALLELE:Bad allele found for v4.0 VCF (%s)";
+static char __pyx_k_96[] = "MISSING_REF:Reference allele missing";
+static char __pyx_k_97[] = "V33_UNMATCHED_DELETION:Deleted sequence does not match reference (%s)";
+static char __pyx_k_98[] = "V40_MISSING_ANGLE_BRACKETS:Format definition is not deliminted by angular brackets";
+static char __pyx_k_99[] = "FORMAT_MISSING_QUOTES:Description field in format definition is not surrounded by quotes";
+static char __pyx_k__0[] = "0";
+static char __pyx_k__D[] = "D";
+static char __pyx_k__I[] = "I";
+static char __pyx_k__N[] = "N";
+static char __pyx_k_100[] = "V40_FORMAT_MUST_HAVE_NAMED_FIELDS:Fields in v4.0 VCF format definition must have named fields";
+static char __pyx_k_101[] = "HEADING_NOT_SEPARATED_BY_TABS:Heading line appears separated by spaces, not tabs";
+static char __pyx_k_102[] = "WRONG_REF:Wrong reference %s";
+static char __pyx_k_103[] = "ERROR_TRAILING_DATA:Numerical field ('%s') has semicolon-separated trailing data";
+static char __pyx_k_104[] = "BAD_CHR_TAG:Error calculating chr tag for %s";
+static char __pyx_k_105[] = "ZERO_LENGTH_ALLELE:Found zero-length allele";
+static char __pyx_k_106[] = "MISSING_INDEL_ALLELE_REF_BASE:Indel alleles must begin with single reference base";
+static char __pyx_k_107[] = "VCF.getsamples (line 880)";
+static char __pyx_k_108[] = "VCF.setsamples (line 884)";
+static char __pyx_k_109[] = "VCF.getheader (line 888)";
+static char __pyx_k_110[] = "VCF.setheader (line 892)";
+static char __pyx_k_111[] = "VCF.getinfo (line 896)";
+static char __pyx_k_112[] = "VCF.setinfo (line 900)";
+static char __pyx_k_113[] = "VCF.getformat (line 904)";
+static char __pyx_k_114[] = "VCF.setformat (line 908)";
+static char __pyx_k_115[] = "VCF.getfilter (line 912)";
+static char __pyx_k_116[] = "VCF.setfilter (line 916)";
+static char __pyx_k_117[] = "VCF.setreference (line 927)";
+static char __pyx_k_118[] = "VCF.parse (line 939)";
+static char __pyx_k_119[] = "VCF.write (line 946)";
+static char __pyx_k_120[] = "VCF.writeheader (line 952)";
+static char __pyx_k_121[] = "VCF.compare_calls (line 957)";
+static char __pyx_k_122[] = "VCF.connect (line 979)";
+static char __pyx_k_123[] = "VCF.fetch (line 984)";
+static char __pyx_k_124[] = "VCF.validate (line 993)";
+static char __pyx_k__DP[] = "DP";
+static char __pyx_k__FT[] = "FT";
+static char __pyx_k__GQ[] = "GQ";
+static char __pyx_k__GT[] = "GT";
+static char __pyx_k__HQ[] = "HQ";
+static char __pyx_k__ID[] = "ID";
+static char __pyx_k__fa[] = "fa";
+static char __pyx_k__id[] = "id";
+static char __pyx_k__re[] = "re";
+static char __pyx_k__ALT[] = "ALT";
+static char __pyx_k__POS[] = "POS";
+static char __pyx_k__REF[] = "REF";
+static char __pyx_k__VCF[] = "VCF";
+static char __pyx_k__add[] = "add";
+static char __pyx_k__alt[] = "alt";
+static char __pyx_k__end[] = "end";
+static char __pyx_k__fmt[] = "fmt";
+static char __pyx_k__get[] = "get";
+static char __pyx_k__key[] = "key";
+static char __pyx_k__len[] = "len";
+static char __pyx_k__map[] = "map";
+static char __pyx_k__min[] = "min";
+static char __pyx_k__opt[] = "opt";
+static char __pyx_k__pos[] = "pos";
+static char __pyx_k__ref[] = "ref";
+static char __pyx_k__sys[] = "sys";
+static char __pyx_k__vcf[] = "vcf";
+static char __pyx_k__zip[] = "zip";
+static char __pyx_k__Flag[] = "Flag";
+static char __pyx_k__INFO[] = "INFO";
+static char __pyx_k__PASS[] = "PASS";
+static char __pyx_k__QUAL[] = "QUAL";
+static char __pyx_k__Type[] = "Type";
+static char __pyx_k__alt1[] = "alt1";
+static char __pyx_k__alt2[] = "alt2";
+static char __pyx_k__copy[] = "copy";
+static char __pyx_k__data[] = "data";
+static char __pyx_k__find[] = "find";
+static char __pyx_k__info[] = "info";
+static char __pyx_k__join[] = "join";
+static char __pyx_k__keys[] = "keys";
+static char __pyx_k__line[] = "line";
+static char __pyx_k__pos1[] = "pos1";
+static char __pyx_k__pos2[] = "pos2";
+static char __pyx_k__qual[] = "qual";
+static char __pyx_k__ref1[] = "ref1";
+static char __pyx_k__ref2[] = "ref2";
+static char __pyx_k__self[] = "self";
+static char __pyx_k__type[] = "type";
+static char __pyx_k__ACGTN[] = "ACGTN";
+static char __pyx_k__CHROM[] = "CHROM";
+static char __pyx_k__Error[] = "Error";
+static char __pyx_k__Float[] = "Float";
+static char __pyx_k___copy[] = "_copy";
+static char __pyx_k___info[] = "_info";
+static char __pyx_k___line[] = "_line";
+static char __pyx_k__chrom[] = "chrom";
+static char __pyx_k__descr[] = "descr";
+static char __pyx_k__error[] = "error";
+static char __pyx_k__fetch[] = "fetch";
+static char __pyx_k__lines[] = "lines";
+static char __pyx_k__match[] = "match";
+static char __pyx_k__parse[] = "parse";
+static char __pyx_k__pysam[] = "pysam";
+static char __pyx_k__range[] = "range";
+static char __pyx_k__split[] = "split";
+static char __pyx_k__start[] = "start";
+static char __pyx_k__strip[] = "strip";
+static char __pyx_k__upper[] = "upper";
+static char __pyx_k__value[] = "value";
+static char __pyx_k__write[] = "write";
+static char __pyx_k__FILTER[] = "FILTER";
+static char __pyx_k__FORMAT[] = "FORMAT";
+static char __pyx_k__GTdata[] = "GTdata";
+static char __pyx_k__Number[] = "Number";
+static char __pyx_k__String[] = "String";
+static char __pyx_k___lines[] = "_lines";
+static char __pyx_k___parse[] = "_parse";
+static char __pyx_k__bisect[] = "bisect";
+static char __pyx_k__buffer[] = "buffer";
+static char __pyx_k__contig[] = "contig";
+static char __pyx_k__fields[] = "fields";
+static char __pyx_k__filter[] = "filter";
+static char __pyx_k__format[] = "format";
+static char __pyx_k__header[] = "header";
+static char __pyx_k__number[] = "number";
+static char __pyx_k__object[] = "object";
+static char __pyx_k__offset[] = "offset";
+static char __pyx_k__parser[] = "parser";
+static char __pyx_k__record[] = "record";
+static char __pyx_k__region[] = "region";
+static char __pyx_k__stderr[] = "stderr";
+static char __pyx_k__stream[] = "stream";
+static char __pyx_k__Integer[] = "Integer";
+static char __pyx_k__Warning[] = "Warning";
+static char __pyx_k____all__[] = "__all__";
+static char __pyx_k___errors[] = "_errors";
+static char __pyx_k___filter[] = "_filter";
+static char __pyx_k___format[] = "_format";
+static char __pyx_k___header[] = "_header";
+static char __pyx_k___lineno[] = "_lineno";
+static char __pyx_k__compile[] = "compile";
+static char __pyx_k__connect[] = "connect";
+static char __pyx_k__getinfo[] = "getinfo";
+static char __pyx_k__missing[] = "missing";
+static char __pyx_k__nfields[] = "nfields";
+static char __pyx_k__regions[] = "regions";
+static char __pyx_k__replace[] = "replace";
+static char __pyx_k__samples[] = "samples";
+static char __pyx_k__setinfo[] = "setinfo";
+static char __pyx_k__vcffile[] = "vcffile";
+static char __pyx_k__version[] = "version";
+static char __pyx_k__GTstring[] = "GTstring";
+static char __pyx_k__Genotype[] = "Genotype";
+static char __pyx_k__KeyError[] = "KeyError";
+static char __pyx_k____dict__[] = "__dict__";
+static char __pyx_k____init__[] = "__init__";
+static char __pyx_k____main__[] = "__main__";
+static char __pyx_k____test__[] = "__test__";
+static char __pyx_k___regions[] = "_regions";
+static char __pyx_k___samples[] = "_samples";
+static char __pyx_k___version[] = "_version";
+static char __pyx_k__deepcopy[] = "deepcopy";
+static char __pyx_k__endswith[] = "endswith";
+static char __pyx_k__filename[] = "filename";
+static char __pyx_k__gtsRegEx[] = "gtsRegEx";
+static char __pyx_k__inregion[] = "inregion";
+static char __pyx_k__operator[] = "operator";
+static char __pyx_k__validate[] = "validate";
+static char __pyx_k__Character[] = "Character";
+static char __pyx_k__NT_NUMBER[] = "NT_NUMBER";
+static char __pyx_k__Tabixfile[] = "Tabixfile";
+static char __pyx_k__VCFRecord[] = "VCFRecord";
+static char __pyx_k__WRONG_REF[] = "WRONG_REF";
+static char __pyx_k___required[] = "_required";
+static char __pyx_k__convertGT[] = "convertGT";
+static char __pyx_k__enumerate[] = "enumerate";
+static char __pyx_k__getfilter[] = "getfilter";
+static char __pyx_k__getformat[] = "getformat";
+static char __pyx_k__getheader[] = "getheader";
+static char __pyx_k__leftalign[] = "leftalign";
+static char __pyx_k__lineparse[] = "lineparse";
+static char __pyx_k__reference[] = "reference";
+static char __pyx_k__separator[] = "separator";
+static char __pyx_k__setfilter[] = "setfilter";
+static char __pyx_k__setformat[] = "setformat";
+static char __pyx_k__setheader[] = "setheader";
+static char __pyx_k__tabixfile[] = "tabixfile";
+static char __pyx_k__warnerror[] = "warnerror";
+static char __pyx_k__NT_ALLELES[] = "NT_ALLELES";
+static char __pyx_k__NT_UNKNOWN[] = "NT_UNKNOWN";
+static char __pyx_k__ValueError[] = "ValueError";
+static char __pyx_k___leftalign[] = "_leftalign";
+static char __pyx_k___reference[] = "_reference";
+static char __pyx_k__fileformat[] = "fileformat";
+static char __pyx_k__formatdict[] = "formatdict";
+static char __pyx_k__getsamples[] = "getsamples";
+static char __pyx_k__itemgetter[] = "itemgetter";
+static char __pyx_k__itervalues[] = "itervalues";
+static char __pyx_k__namedtuple[] = "namedtuple";
+static char __pyx_k__numbertype[] = "numbertype";
+static char __pyx_k__parse_data[] = "parse_data";
+static char __pyx_k__setregions[] = "setregions";
+static char __pyx_k__setsamples[] = "setsamples";
+static char __pyx_k__setversion[] = "setversion";
+static char __pyx_k__startswith[] = "startswith";
+static char __pyx_k__write_data[] = "write_data";
+static char __pyx_k__Description[] = "Description";
+static char __pyx_k__MISSING_REF[] = "MISSING_REF";
+static char __pyx_k__V33_BAD_REF[] = "V33_BAD_REF";
+static char __pyx_k__alleleRegEx[] = "alleleRegEx";
+static char __pyx_k__collections[] = "collections";
+static char __pyx_k__defaultdict[] = "defaultdict";
+static char __pyx_k__description[] = "description";
+static char __pyx_k__errorstring[] = "errorstring";
+static char __pyx_k__ignoreerror[] = "ignoreerror";
+static char __pyx_k__writeheader[] = "writeheader";
+static char __pyx_k__BAD_GENOTYPE[] = "BAD_GENOTYPE";
+static char __pyx_k__NT_GENOTYPES[] = "NT_GENOTYPES";
+static char __pyx_k___warn_errors[] = "_warn_errors";
+static char __pyx_k__get_expected[] = "get_expected";
+static char __pyx_k__get_sequence[] = "get_sequence";
+static char __pyx_k__missingvalue[] = "missingvalue";
+static char __pyx_k__parse_format[] = "parse_format";
+static char __pyx_k__parse_header[] = "parse_header";
+static char __pyx_k__setreference[] = "setreference";
+static char __pyx_k__write_header[] = "write_header";
+static char __pyx_k__NT_NR_ALLELES[] = "NT_NR_ALLELES";
+static char __pyx_k__StopIteration[] = "StopIteration";
+static char __pyx_k___parse_header[] = "_parse_header";
+static char __pyx_k__compare_calls[] = "compare_calls";
+static char __pyx_k__convertGTback[] = "convertGTback";
+static char __pyx_k__datagenerator[] = "datagenerator";
+static char __pyx_k__format_format[] = "format_format";
+static char __pyx_k__parse_heading[] = "parse_heading";
+static char __pyx_k__write_heading[] = "write_heading";
+static char __pyx_k__V33_BAD_ALLELE[] = "V33_BAD_ALLELE";
+static char __pyx_k__V40_BAD_ALLELE[] = "V40_BAD_ALLELE";
+static char __pyx_k___sample2column[] = "_sample2column";
+static char __pyx_k___add_definition[] = "_add_definition";
+static char __pyx_k___ignored_errors[] = "_ignored_errors";
+static char __pyx_k__POS_NOT_POSITIVE[] = "POS_NOT_POSITIVE";
+static char __pyx_k__parse_formatdata[] = "parse_formatdata";
+static char __pyx_k__ERROR_INFO_STRING[] = "ERROR_INFO_STRING";
+static char __pyx_k__ERROR_UNKNOWN_KEY[] = "ERROR_UNKNOWN_KEY";
+static char __pyx_k__POS_NOT_NUMERICAL[] = "POS_NOT_NUMERICAL";
+static char __pyx_k__format_formatdata[] = "format_formatdata";
+static char __pyx_k__FILTER_NOT_DEFINED[] = "FILTER_NOT_DEFINED";
+static char __pyx_k__FORMAT_NOT_DEFINED[] = "FORMAT_NOT_DEFINED";
+static char __pyx_k__QUAL_NOT_NUMERICAL[] = "QUAL_NOT_NUMERICAL";
+static char __pyx_k__ZERO_LENGTH_ALLELE[] = "ZERO_LENGTH_ALLELE";
+static char __pyx_k__ERROR_TRAILING_DATA[] = "ERROR_TRAILING_DATA";
+static char __pyx_k__NT_PHASED_GENOTYPES[] = "NT_PHASED_GENOTYPES";
+static char __pyx_k__NotImplementedError[] = "NotImplementedError";
+static char __pyx_k__UNKNOWN_CHAR_IN_REF[] = "UNKNOWN_CHAR_IN_REF";
+static PyObject *__pyx_kp_s_1;
+static PyObject *__pyx_kp_s_10;
+static PyObject *__pyx_kp_s_100;
+static PyObject *__pyx_kp_s_101;
+static PyObject *__pyx_kp_s_102;
+static PyObject *__pyx_kp_s_103;
+static PyObject *__pyx_kp_s_104;
+static PyObject *__pyx_kp_s_105;
+static PyObject *__pyx_kp_s_106;
+static PyObject *__pyx_kp_u_107;
+static PyObject *__pyx_kp_u_108;
+static PyObject *__pyx_kp_u_109;
+static PyObject *__pyx_n_s_11;
+static PyObject *__pyx_kp_u_110;
+static PyObject *__pyx_kp_u_111;
+static PyObject *__pyx_kp_u_112;
+static PyObject *__pyx_kp_u_113;
+static PyObject *__pyx_kp_u_114;
+static PyObject *__pyx_kp_u_115;
+static PyObject *__pyx_kp_u_116;
+static PyObject *__pyx_kp_u_117;
+static PyObject *__pyx_kp_u_118;
+static PyObject *__pyx_kp_u_119;
+static PyObject *__pyx_kp_s_12;
+static PyObject *__pyx_kp_u_120;
+static PyObject *__pyx_kp_u_121;
+static PyObject *__pyx_kp_u_122;
+static PyObject *__pyx_kp_u_123;
+static PyObject *__pyx_kp_u_124;
+static PyObject *__pyx_kp_s_14;
+static PyObject *__pyx_kp_s_16;
+static PyObject *__pyx_n_s_17;
+static PyObject *__pyx_kp_s_18;
+static PyObject *__pyx_kp_s_19;
+static PyObject *__pyx_kp_s_2;
+static PyObject *__pyx_n_s_20;
+static PyObject *__pyx_n_s_21;
+static PyObject *__pyx_kp_s_22;
+static PyObject *__pyx_kp_s_23;
+static PyObject *__pyx_kp_s_24;
+static PyObject *__pyx_kp_s_25;
+static PyObject *__pyx_n_s_26;
+static PyObject *__pyx_kp_s_27;
+static PyObject *__pyx_kp_s_28;
+static PyObject *__pyx_kp_s_29;
+static PyObject *__pyx_kp_s_3;
+static PyObject *__pyx_kp_s_30;
+static PyObject *__pyx_kp_s_31;
+static PyObject *__pyx_kp_s_33;
+static PyObject *__pyx_kp_s_34;
+static PyObject *__pyx_kp_s_35;
+static PyObject *__pyx_kp_s_38;
+static PyObject *__pyx_kp_s_39;
+static PyObject *__pyx_kp_s_4;
+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_44;
+static PyObject *__pyx_kp_s_45;
+static PyObject *__pyx_kp_s_46;
+static PyObject *__pyx_n_s_47;
+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_n_s_52;
+static PyObject *__pyx_kp_s_53;
+static PyObject *__pyx_kp_s_54;
+static PyObject *__pyx_n_s_55;
+static PyObject *__pyx_kp_s_56;
+static PyObject *__pyx_kp_s_57;
+static PyObject *__pyx_n_s_58;
+static PyObject *__pyx_n_s_59;
+static PyObject *__pyx_kp_b_6;
+static PyObject *__pyx_kp_s_6;
+static PyObject *__pyx_n_s_60;
+static PyObject *__pyx_n_s_62;
+static PyObject *__pyx_kp_s_63;
+static PyObject *__pyx_kp_s_64;
+static PyObject *__pyx_n_s_65;
+static PyObject *__pyx_kp_s_66;
+static PyObject *__pyx_n_s_67;
+static PyObject *__pyx_kp_s_68;
+static PyObject *__pyx_n_s_69;
+static PyObject *__pyx_kp_s_7;
+static PyObject *__pyx_kp_s_70;
+static PyObject *__pyx_kp_s_71;
+static PyObject *__pyx_kp_s_72;
+static PyObject *__pyx_kp_s_73;
+static PyObject *__pyx_kp_s_74;
+static PyObject *__pyx_kp_s_75;
+static PyObject *__pyx_kp_s_76;
+static PyObject *__pyx_kp_s_77;
+static PyObject *__pyx_kp_s_78;
+static PyObject *__pyx_kp_s_79;
+static PyObject *__pyx_kp_s_8;
+static PyObject *__pyx_kp_s_80;
+static PyObject *__pyx_kp_s_81;
+static PyObject *__pyx_kp_s_82;
+static PyObject *__pyx_kp_s_83;
+static PyObject *__pyx_kp_s_84;
+static PyObject *__pyx_kp_s_85;
+static PyObject *__pyx_kp_s_86;
+static PyObject *__pyx_kp_s_87;
+static PyObject *__pyx_kp_s_88;
+static PyObject *__pyx_kp_s_89;
+static PyObject *__pyx_n_s_9;
+static PyObject *__pyx_kp_s_90;
+static PyObject *__pyx_kp_s_91;
+static PyObject *__pyx_kp_s_92;
+static PyObject *__pyx_kp_s_93;
+static PyObject *__pyx_kp_s_94;
+static PyObject *__pyx_kp_s_95;
+static PyObject *__pyx_kp_s_96;
+static PyObject *__pyx_kp_s_97;
+static PyObject *__pyx_kp_s_98;
+static PyObject *__pyx_kp_s_99;
+static PyObject *__pyx_kp_s__0;
+static PyObject *__pyx_n_s__ACGTN;
+static PyObject *__pyx_n_s__ALT;
+static PyObject *__pyx_n_s__BAD_GENOTYPE;
+static PyObject *__pyx_n_s__CHROM;
+static PyObject *__pyx_n_s__Character;
+static PyObject *__pyx_n_s__D;
+static PyObject *__pyx_n_s__DP;
+static PyObject *__pyx_n_s__Description;
+static PyObject *__pyx_n_s__ERROR_INFO_STRING;
+static PyObject *__pyx_n_s__ERROR_TRAILING_DATA;
+static PyObject *__pyx_n_s__ERROR_UNKNOWN_KEY;
+static PyObject *__pyx_n_s__Error;
+static PyObject *__pyx_n_s__FILTER;
+static PyObject *__pyx_n_s__FILTER_NOT_DEFINED;
+static PyObject *__pyx_n_s__FORMAT;
+static PyObject *__pyx_n_s__FORMAT_NOT_DEFINED;
+static PyObject *__pyx_n_s__FT;
+static PyObject *__pyx_n_s__Flag;
+static PyObject *__pyx_n_s__Float;
+static PyObject *__pyx_n_s__GQ;
+static PyObject *__pyx_n_s__GT;
+static PyObject *__pyx_n_s__GTdata;
+static PyObject *__pyx_n_s__GTstring;
+static PyObject *__pyx_n_s__Genotype;
+static PyObject *__pyx_n_s__HQ;
+static PyObject *__pyx_n_s__I;
+static PyObject *__pyx_n_s__ID;
+static PyObject *__pyx_n_s__INFO;
+static PyObject *__pyx_n_s__Integer;
+static PyObject *__pyx_n_s__KeyError;
+static PyObject *__pyx_n_s__MISSING_REF;
+static PyObject *__pyx_n_s__N;
+static PyObject *__pyx_n_s__NT_ALLELES;
+static PyObject *__pyx_n_s__NT_GENOTYPES;
+static PyObject *__pyx_n_s__NT_NR_ALLELES;
+static PyObject *__pyx_n_s__NT_NUMBER;
+static PyObject *__pyx_n_s__NT_PHASED_GENOTYPES;
+static PyObject *__pyx_n_s__NT_UNKNOWN;
+static PyObject *__pyx_n_s__NotImplementedError;
+static PyObject *__pyx_n_s__Number;
+static PyObject *__pyx_n_s__PASS;
+static PyObject *__pyx_n_s__POS;
+static PyObject *__pyx_n_s__POS_NOT_NUMERICAL;
+static PyObject *__pyx_n_s__POS_NOT_POSITIVE;
+static PyObject *__pyx_n_s__QUAL;
+static PyObject *__pyx_n_s__QUAL_NOT_NUMERICAL;
+static PyObject *__pyx_n_s__REF;
+static PyObject *__pyx_n_s__StopIteration;
+static PyObject *__pyx_n_s__String;
+static PyObject *__pyx_n_s__Tabixfile;
+static PyObject *__pyx_n_s__Type;
+static PyObject *__pyx_n_s__UNKNOWN_CHAR_IN_REF;
+static PyObject *__pyx_n_s__V33_BAD_ALLELE;
+static PyObject *__pyx_n_s__V33_BAD_REF;
+static PyObject *__pyx_n_s__V40_BAD_ALLELE;
+static PyObject *__pyx_n_s__VCF;
+static PyObject *__pyx_n_s__VCFRecord;
+static PyObject *__pyx_n_s__ValueError;
+static PyObject *__pyx_n_s__WRONG_REF;
+static PyObject *__pyx_n_s__Warning;
+static PyObject *__pyx_n_s__ZERO_LENGTH_ALLELE;
+static PyObject *__pyx_n_s____all__;
+static PyObject *__pyx_n_s____dict__;
+static PyObject *__pyx_n_s____init__;
+static PyObject *__pyx_n_s____main__;
+static PyObject *__pyx_n_s____test__;
+static PyObject *__pyx_n_s___add_definition;
+static PyObject *__pyx_n_s___copy;
+static PyObject *__pyx_n_s___errors;
+static PyObject *__pyx_n_s___filter;
+static PyObject *__pyx_n_s___format;
+static PyObject *__pyx_n_s___header;
+static PyObject *__pyx_n_s___ignored_errors;
+static PyObject *__pyx_n_s___info;
+static PyObject *__pyx_n_s___leftalign;
+static PyObject *__pyx_n_s___line;
+static PyObject *__pyx_n_s___lineno;
+static PyObject *__pyx_n_s___lines;
+static PyObject *__pyx_n_s___parse;
+static PyObject *__pyx_n_s___parse_header;
+static PyObject *__pyx_n_s___reference;
+static PyObject *__pyx_n_s___regions;
+static PyObject *__pyx_n_s___required;
+static PyObject *__pyx_n_s___sample2column;
+static PyObject *__pyx_n_s___samples;
+static PyObject *__pyx_n_s___version;
+static PyObject *__pyx_n_s___warn_errors;
+static PyObject *__pyx_n_s__add;
+static PyObject *__pyx_n_s__alleleRegEx;
+static PyObject *__pyx_n_s__alt;
+static PyObject *__pyx_n_s__alt1;
+static PyObject *__pyx_n_s__alt2;
+static PyObject *__pyx_n_s__bisect;
+static PyObject *__pyx_n_s__buffer;
+static PyObject *__pyx_n_s__chrom;
+static PyObject *__pyx_n_s__collections;
+static PyObject *__pyx_n_s__compare_calls;
+static PyObject *__pyx_n_s__compile;
+static PyObject *__pyx_n_s__connect;
+static PyObject *__pyx_n_s__contig;
+static PyObject *__pyx_n_s__convertGT;
+static PyObject *__pyx_n_s__convertGTback;
+static PyObject *__pyx_n_s__copy;
+static PyObject *__pyx_n_s__data;
+static PyObject *__pyx_n_s__datagenerator;
+static PyObject *__pyx_n_s__deepcopy;
+static PyObject *__pyx_n_s__defaultdict;
+static PyObject *__pyx_n_s__descr;
+static PyObject *__pyx_n_s__description;
+static PyObject *__pyx_n_s__end;
+static PyObject *__pyx_n_s__endswith;
+static PyObject *__pyx_n_s__enumerate;
+static PyObject *__pyx_n_s__error;
+static PyObject *__pyx_n_s__errorstring;
+static PyObject *__pyx_n_s__fa;
+static PyObject *__pyx_n_s__fetch;
+static PyObject *__pyx_n_s__fields;
+static PyObject *__pyx_n_s__fileformat;
+static PyObject *__pyx_n_s__filename;
+static PyObject *__pyx_n_s__filter;
+static PyObject *__pyx_n_s__find;
+static PyObject *__pyx_n_s__fmt;
+static PyObject *__pyx_n_s__format;
+static PyObject *__pyx_n_s__format_format;
+static PyObject *__pyx_n_s__format_formatdata;
+static PyObject *__pyx_n_s__formatdict;
+static PyObject *__pyx_n_s__get;
+static PyObject *__pyx_n_s__get_expected;
+static PyObject *__pyx_n_s__get_sequence;
+static PyObject *__pyx_n_s__getfilter;
+static PyObject *__pyx_n_s__getformat;
+static PyObject *__pyx_n_s__getheader;
+static PyObject *__pyx_n_s__getinfo;
+static PyObject *__pyx_n_s__getsamples;
+static PyObject *__pyx_n_s__gtsRegEx;
+static PyObject *__pyx_n_s__header;
+static PyObject *__pyx_n_s__id;
+static PyObject *__pyx_n_s__ignoreerror;
+static PyObject *__pyx_n_s__info;
+static PyObject *__pyx_n_s__inregion;
+static PyObject *__pyx_n_s__itemgetter;
+static PyObject *__pyx_n_s__itervalues;
+static PyObject *__pyx_n_s__join;
+static PyObject *__pyx_n_s__key;
+static PyObject *__pyx_n_s__keys;
+static PyObject *__pyx_n_s__leftalign;
+static PyObject *__pyx_n_s__len;
+static PyObject *__pyx_n_s__line;
+static PyObject *__pyx_n_s__lineparse;
+static PyObject *__pyx_n_s__lines;
+static PyObject *__pyx_n_s__map;
+static PyObject *__pyx_n_s__match;
+static PyObject *__pyx_n_s__min;
+static PyObject *__pyx_n_s__missing;
+static PyObject *__pyx_n_s__missingvalue;
+static PyObject *__pyx_n_s__namedtuple;
+static PyObject *__pyx_n_s__nfields;
+static PyObject *__pyx_n_s__number;
+static PyObject *__pyx_n_s__numbertype;
+static PyObject *__pyx_n_s__object;
+static PyObject *__pyx_n_s__offset;
+static PyObject *__pyx_n_s__operator;
+static PyObject *__pyx_n_s__opt;
+static PyObject *__pyx_n_s__parse;
+static PyObject *__pyx_n_s__parse_data;
+static PyObject *__pyx_n_s__parse_format;
+static PyObject *__pyx_n_s__parse_formatdata;
+static PyObject *__pyx_n_s__parse_header;
+static PyObject *__pyx_n_s__parse_heading;
+static PyObject *__pyx_n_s__parser;
+static PyObject *__pyx_n_s__pos;
+static PyObject *__pyx_n_s__pos1;
+static PyObject *__pyx_n_s__pos2;
+static PyObject *__pyx_n_s__pysam;
+static PyObject *__pyx_n_s__qual;
+static PyObject *__pyx_n_s__range;
+static PyObject *__pyx_n_s__re;
+static PyObject *__pyx_n_s__record;
+static PyObject *__pyx_n_s__ref;
+static PyObject *__pyx_n_s__ref1;
+static PyObject *__pyx_n_s__ref2;
+static PyObject *__pyx_n_s__reference;
+static PyObject *__pyx_n_s__region;
+static PyObject *__pyx_n_s__regions;
+static PyObject *__pyx_n_s__replace;
+static PyObject *__pyx_n_s__samples;
+static PyObject *__pyx_n_s__self;
+static PyObject *__pyx_n_s__separator;
+static PyObject *__pyx_n_s__setfilter;
+static PyObject *__pyx_n_s__setformat;
+static PyObject *__pyx_n_s__setheader;
+static PyObject *__pyx_n_s__setinfo;
+static PyObject *__pyx_n_s__setreference;
+static PyObject *__pyx_n_s__setregions;
+static PyObject *__pyx_n_s__setsamples;
+static PyObject *__pyx_n_s__setversion;
+static PyObject *__pyx_n_s__split;
+static PyObject *__pyx_n_s__start;
+static PyObject *__pyx_n_s__startswith;
+static PyObject *__pyx_n_s__stderr;
+static PyObject *__pyx_n_s__stream;
+static PyObject *__pyx_n_s__strip;
+static PyObject *__pyx_n_s__sys;
+static PyObject *__pyx_n_s__tabixfile;
+static PyObject *__pyx_n_s__type;
+static PyObject *__pyx_n_s__upper;
+static PyObject *__pyx_n_s__validate;
+static PyObject *__pyx_n_s__value;
+static PyObject *__pyx_n_s__vcf;
+static PyObject *__pyx_n_s__vcffile;
+static PyObject *__pyx_n_s__version;
+static PyObject *__pyx_n_s__warnerror;
+static PyObject *__pyx_n_s__write;
+static PyObject *__pyx_n_s__write_data;
+static PyObject *__pyx_n_s__write_header;
+static PyObject *__pyx_n_s__write_heading;
+static PyObject *__pyx_n_s__writeheader;
+static PyObject *__pyx_n_s__zip;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_2;
+static PyObject *__pyx_int_3;
+static PyObject *__pyx_int_4;
+static PyObject *__pyx_int_5;
+static PyObject *__pyx_int_6;
+static PyObject *__pyx_int_7;
+static PyObject *__pyx_int_8;
+static PyObject *__pyx_int_9;
+static PyObject *__pyx_int_neg_1;
+static PyObject *__pyx_int_10;
+static PyObject *__pyx_int_11;
+static PyObject *__pyx_int_12;
+static PyObject *__pyx_int_13;
+static PyObject *__pyx_int_14;
+static PyObject *__pyx_int_15;
+static PyObject *__pyx_int_16;
+static PyObject *__pyx_int_17;
+static PyObject *__pyx_int_18;
+static PyObject *__pyx_int_19;
+static PyObject *__pyx_int_20;
+static PyObject *__pyx_int_21;
+static PyObject *__pyx_int_22;
+static PyObject *__pyx_int_23;
+static PyObject *__pyx_int_24;
+static PyObject *__pyx_int_25;
+static PyObject *__pyx_int_26;
+static PyObject *__pyx_int_27;
+static PyObject *__pyx_int_28;
+static PyObject *__pyx_int_29;
+static PyObject *__pyx_int_30;
+static PyObject *__pyx_int_33;
+static PyObject *__pyx_int_40;
+static PyObject *__pyx_int_100;
+static PyObject *__pyx_int_3000000000;
+static PyObject *__pyx_k_13;
+static PyObject *__pyx_k_15;
+static PyObject *__pyx_k_32;
+static PyObject *__pyx_k_36;
+static PyObject *__pyx_k_37;
+static PyObject *__pyx_k_61;
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":58
+ * 
+ * # Utility function.  Uses 0-based coordinates
+ * def get_sequence(chrom, start, end, fa):             # <<<<<<<<<<<<<<
+ *     # obtain sequence from .fa file, without truncation
+ *     if end<=start: return ""
+ */
+
+static PyObject *__pyx_pf_4cvcf_get_sequence(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_4cvcf_get_sequence(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_chrom = 0;
+  PyObject *__pyx_v_start = 0;
+  PyObject *__pyx_v_end = 0;
+  PyObject *__pyx_v_fa = 0;
+  PyObject *__pyx_v_sequence;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__chrom,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__fa,0};
+  __Pyx_RefNannySetupContext("get_sequence");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[4] = {0,0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chrom);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_sequence", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_sequence", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fa);
+      if (likely(values[3])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_sequence", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_sequence") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_chrom = values[0];
+    __pyx_v_start = values[1];
+    __pyx_v_end = values[2];
+    __pyx_v_fa = values[3];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_chrom = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
+    __pyx_v_fa = PyTuple_GET_ITEM(__pyx_args, 3);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("get_sequence", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.get_sequence");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_sequence = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":60
+ * def get_sequence(chrom, start, end, fa):
+ *     # obtain sequence from .fa file, without truncation
+ *     if end<=start: return ""             # <<<<<<<<<<<<<<
+ *     if not fa: return "N"*(end-start)
+ *     if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, __pyx_v_start, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+    __pyx_r = ((PyObject *)__pyx_kp_s_1);
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":61
+ *     # obtain sequence from .fa file, without truncation
+ *     if end<=start: return ""
+ *     if not fa: return "N"*(end-start)             # <<<<<<<<<<<<<<
+ *     if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+ *     sequence = fa.fetch(chrom, start, end).upper()
+ */
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_fa); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = (!__pyx_t_2);
+  if (__pyx_t_3) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyNumber_Subtract(__pyx_v_end, __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = PyNumber_Multiply(((PyObject *)__pyx_n_s__N), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __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);
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":62
+ *     if end<=start: return ""
+ *     if not fa: return "N"*(end-start)
+ *     if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()             # <<<<<<<<<<<<<<
+ *     sequence = fa.fetch(chrom, start, end).upper()
+ *     if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))
+ */
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_start, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (__pyx_t_3) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = PyNumber_Negative(__pyx_v_start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_n_s__N), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(__pyx_v_chrom);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_chrom);
+    __Pyx_GIVEREF(__pyx_v_chrom);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(__pyx_v_end);
+    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_end);
+    __Pyx_GIVEREF(__pyx_v_end);
+    __Pyx_INCREF(__pyx_v_fa);
+    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_fa);
+    __Pyx_GIVEREF(__pyx_v_fa);
+    __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__upper); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_1), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_r = __pyx_t_5;
+    __pyx_t_5 = 0;
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":63
+ *     if not fa: return "N"*(end-start)
+ *     if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+ *     sequence = fa.fetch(chrom, start, end).upper()             # <<<<<<<<<<<<<<
+ *     if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))
+ *     return sequence
+ */
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_fa, __pyx_n_s__fetch); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __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 = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_INCREF(__pyx_v_chrom);
+  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_chrom);
+  __Pyx_GIVEREF(__pyx_v_chrom);
+  __Pyx_INCREF(__pyx_v_start);
+  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_start);
+  __Pyx_GIVEREF(__pyx_v_start);
+  __Pyx_INCREF(__pyx_v_end);
+  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_end);
+  __Pyx_GIVEREF(__pyx_v_end);
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__upper); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_v_sequence);
+  __pyx_v_sequence = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":64
+ *     if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+ *     sequence = fa.fetch(chrom, start, end).upper()
+ *     if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))             # <<<<<<<<<<<<<<
+ *     return sequence
+ * 
+ */
+  __pyx_t_7 = PyObject_Length(__pyx_v_sequence); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_6 = PyNumber_Subtract(__pyx_v_end, __pyx_v_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  if (__pyx_t_3) {
+    __pyx_t_5 = PyNumber_Subtract(__pyx_v_end, __pyx_v_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_7 = PyObject_Length(__pyx_v_sequence); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyNumber_Subtract(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = PyNumber_Multiply(((PyObject *)__pyx_n_s__N), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_sequence, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_v_sequence);
+    __pyx_v_sequence = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":65
+ *     sequence = fa.fetch(chrom, start, end).upper()
+ *     if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))
+ *     return sequence             # <<<<<<<<<<<<<<
+ * 
+ * # Utility function.  Parses a region string
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_sequence);
+  __pyx_r = __pyx_v_sequence;
+  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_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.get_sequence");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_sequence);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":68
+ * 
+ * # Utility function.  Parses a region string
+ * def parse_regions( string ):             # <<<<<<<<<<<<<<
+ *     result = []
+ *     for r in string.split(','):
+ */
+
+static PyObject *__pyx_pf_4cvcf_parse_regions(PyObject *__pyx_self, PyObject *__pyx_v_string); /*proto*/
+static PyObject *__pyx_pf_4cvcf_parse_regions(PyObject *__pyx_self, PyObject *__pyx_v_string) {
+  PyObject *__pyx_v_result;
+  PyObject *__pyx_v_r;
+  PyObject *__pyx_v_elts;
+  PyObject *__pyx_v_chrom;
+  PyObject *__pyx_v_start;
+  PyObject *__pyx_v_end;
+  PyObject *__pyx_v_ielts;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  Py_ssize_t __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  __Pyx_RefNannySetupContext("parse_regions");
+  __pyx_self = __pyx_self;
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_elts = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_chrom = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_start = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_end = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_ielts = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":69
+ * # Utility function.  Parses a region string
+ * def parse_regions( string ):
+ *     result = []             # <<<<<<<<<<<<<<
+ *     for r in string.split(','):
+ *         elts = r.split(':')
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_result));
+  __pyx_v_result = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":70
+ * def parse_regions( string ):
+ *     result = []
+ *     for r in string.split(','):             # <<<<<<<<<<<<<<
+ *         elts = r.split(':')
+ *         chrom, start, end = elts[0], 0, 3000000000
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_string, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __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 = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_2));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
+    __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+    } else {
+      __pyx_t_4 = PyIter_Next(__pyx_t_3);
+      if (!__pyx_t_4) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_DECREF(__pyx_v_r);
+    __pyx_v_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":71
+ *     result = []
+ *     for r in string.split(','):
+ *         elts = r.split(':')             # <<<<<<<<<<<<<<
+ *         chrom, start, end = elts[0], 0, 3000000000
+ *         if len(elts)==1: pass
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_elts);
+    __pyx_v_elts = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":72
+ *     for r in string.split(','):
+ *         elts = r.split(':')
+ *         chrom, start, end = elts[0], 0, 3000000000             # <<<<<<<<<<<<<<
+ *         if len(elts)==1: pass
+ *         elif len(elts)==2:
+ */
+    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_1 = __pyx_int_0;
+    __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_4 = __pyx_int_3000000000;
+    __Pyx_INCREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_v_chrom);
+    __pyx_v_chrom = __pyx_t_5;
+    __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_v_start);
+    __pyx_v_start = __pyx_t_1;
+    __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_end);
+    __pyx_v_end = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":73
+ *         elts = r.split(':')
+ *         chrom, start, end = elts[0], 0, 3000000000
+ *         if len(elts)==1: pass             # <<<<<<<<<<<<<<
+ *         elif len(elts)==2:
+ *             if len(elts[1])>0:
+ */
+    __pyx_t_6 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = (__pyx_t_6 == 1);
+    if (__pyx_t_7) {
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":74
+ *         chrom, start, end = elts[0], 0, 3000000000
+ *         if len(elts)==1: pass
+ *         elif len(elts)==2:             # <<<<<<<<<<<<<<
+ *             if len(elts[1])>0:
+ *                 ielts = elts[1].split('-')
+ */
+    __pyx_t_6 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = (__pyx_t_6 == 2);
+    if (__pyx_t_7) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":75
+ *         if len(elts)==1: pass
+ *         elif len(elts)==2:
+ *             if len(elts[1])>0:             # <<<<<<<<<<<<<<
+ *                 ielts = elts[1].split('-')
+ *                 if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+ */
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_elts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_6 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_7 = (__pyx_t_6 > 0);
+      if (__pyx_t_7) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":76
+ *         elif len(elts)==2:
+ *             if len(elts[1])>0:
+ *                 ielts = elts[1].split('-')             # <<<<<<<<<<<<<<
+ *                 if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+ *                 try:    start, end = int(ielts[0])-1, int(ielts[1])
+ */
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_elts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __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 = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
+        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_4));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
+        __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_v_ielts);
+        __pyx_v_ielts = __pyx_t_5;
+        __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":77
+ *             if len(elts[1])>0:
+ *                 ielts = elts[1].split('-')
+ *                 if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)             # <<<<<<<<<<<<<<
+ *                 try:    start, end = int(ielts[0])-1, int(ielts[1])
+ *                 except: raise ValueError("Don't understand region string '%s'" % r)
+ */
+        __pyx_t_6 = PyObject_Length(__pyx_v_ielts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = (__pyx_t_6 != 2);
+        if (__pyx_t_7) {
+          __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_r); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+          __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_4);
+          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+          __pyx_t_5 = 0;
+          __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          goto __pyx_L9;
+        }
+        __pyx_L9:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":78
+ *                 ielts = elts[1].split('-')
+ *                 if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+ *                 try:    start, end = int(ielts[0])-1, int(ielts[1])             # <<<<<<<<<<<<<<
+ *                 except: raise ValueError("Don't understand region string '%s'" % r)
+ *         else:
+ */
+        {
+          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+          __Pyx_XGOTREF(__pyx_save_exc_type);
+          __Pyx_XGOTREF(__pyx_save_exc_value);
+          __Pyx_XGOTREF(__pyx_save_exc_tb);
+          /*try:*/ {
+            __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_ielts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+            __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_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(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __pyx_t_4 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+            __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_ielts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+            __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
+            __Pyx_GIVEREF(__pyx_t_5);
+            __pyx_t_5 = 0;
+            __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+            __Pyx_DECREF(__pyx_v_start);
+            __pyx_v_start = __pyx_t_4;
+            __pyx_t_4 = 0;
+            __Pyx_DECREF(__pyx_v_end);
+            __pyx_v_end = __pyx_t_5;
+            __pyx_t_5 = 0;
+          }
+          __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+          __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+          __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+          goto __pyx_L17_try_end;
+          __pyx_L10_error:;
+          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":79
+ *                 if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+ *                 try:    start, end = int(ielts[0])-1, int(ielts[1])
+ *                 except: raise ValueError("Don't understand region string '%s'" % r)             # <<<<<<<<<<<<<<
+ *         else:
+ *             raise ValueError("Don't understand region string '%s'" % r)
+ */
+          /*except:*/ {
+            __Pyx_AddTraceback("cvcf.parse_regions");
+            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_GOTREF(__pyx_t_1);
+            __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_r); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L12_except_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 = 79; __pyx_clineno = __LINE__; goto __pyx_L12_except_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, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_Raise(__pyx_t_8, 0, 0);
+            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+            goto __pyx_L11_exception_handled;
+          }
+          __pyx_L12_except_error:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          goto __pyx_L1_error;
+          __pyx_L11_exception_handled:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          __pyx_L17_try_end:;
+        }
+        goto __pyx_L8;
+      }
+      __pyx_L8:;
+      goto __pyx_L7;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":81
+ *                 except: raise ValueError("Don't understand region string '%s'" % r)
+ *         else:
+ *             raise ValueError("Don't understand region string '%s'" % r)             # <<<<<<<<<<<<<<
+ *         result.append( (chrom,start,end) )
+ *     return result
+ */
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __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 = 81; __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_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __pyx_L7:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":82
+ *         else:
+ *             raise ValueError("Don't understand region string '%s'" % r)
+ *         result.append( (chrom,start,end) )             # <<<<<<<<<<<<<<
+ *     return result
+ * 
+ */
+    if (unlikely(__pyx_v_result == Py_None)) {
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_chrom);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_chrom);
+    __Pyx_GIVEREF(__pyx_v_chrom);
+    __Pyx_INCREF(__pyx_v_start);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
+    __Pyx_GIVEREF(__pyx_v_start);
+    __Pyx_INCREF(__pyx_v_end);
+    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
+    __Pyx_GIVEREF(__pyx_v_end);
+    __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":83
+ *             raise ValueError("Don't understand region string '%s'" % r)
+ *         result.append( (chrom,start,end) )
+ *     return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_result));
+  __pyx_r = ((PyObject *)__pyx_v_result);
+  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_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cvcf.parse_regions");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_result);
+  __Pyx_DECREF(__pyx_v_r);
+  __Pyx_DECREF(__pyx_v_elts);
+  __Pyx_DECREF(__pyx_v_chrom);
+  __Pyx_DECREF(__pyx_v_start);
+  __Pyx_DECREF(__pyx_v_end);
+  __Pyx_DECREF(__pyx_v_ielts);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":104
+ *     cdef uint32_t pos
+ * 
+ *     def __init__(self, vcf):             # <<<<<<<<<<<<<<
+ *         self.vcf = vcf
+ *         # if len(data) != len(self.vcf._samples):
+ */
+
+static int __pyx_pf_4cvcf_9VCFRecord___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_4cvcf_9VCFRecord___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_vcf = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__vcf,0};
+  __Pyx_RefNannySetupContext("__init__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vcf);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_vcf = values[0];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_vcf = PyTuple_GET_ITEM(__pyx_args, 0);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCFRecord.__init__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":105
+ * 
+ *     def __init__(self, vcf):
+ *         self.vcf = vcf             # <<<<<<<<<<<<<<
+ *         # if len(data) != len(self.vcf._samples):
+ *         #     self.error(str(data),
+ */
+  __Pyx_INCREF(__pyx_v_vcf);
+  __Pyx_GIVEREF(__pyx_v_vcf);
+  __Pyx_GOTREF(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf);
+  __Pyx_DECREF(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf);
+  ((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf = __pyx_v_vcf;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":115
+ *         #                     len(data)))
+ * 
+ *     def __cinit__(self, vcf ):             # <<<<<<<<<<<<<<
+ *         # start indexed access at genotypes
+ *         self.offset = 9
+ */
+
+static int __pyx_pf_4cvcf_9VCFRecord___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_4cvcf_9VCFRecord___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_vcf = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__vcf,0};
+  __Pyx_RefNannySetupContext("__cinit__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vcf);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_vcf = values[0];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_vcf = PyTuple_GET_ITEM(__pyx_args, 0);
+  }
+  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 = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCFRecord.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":117
+ *     def __cinit__(self, vcf ):
+ *         # start indexed access at genotypes
+ *         self.offset = 9             # <<<<<<<<<<<<<<
+ * 
+ *         self.vcf = vcf
+ */
+  ((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.offset = 9;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":119
+ *         self.offset = 9
+ * 
+ *         self.vcf = vcf             # <<<<<<<<<<<<<<
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):
+ */
+  __Pyx_INCREF(__pyx_v_vcf);
+  __Pyx_GIVEREF(__pyx_v_vcf);
+  __Pyx_GOTREF(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf);
+  __Pyx_DECREF(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf);
+  ((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf = __pyx_v_vcf;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":121
+ *         self.vcf = vcf
+ * 
+ *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
+ *         '''update internal data.
+ * 
+ */
+
+static  PyObject *__pyx_f_4cvcf_9VCFRecord_update(struct __pyx_obj_4cvcf_VCFRecord *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("update");
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":126
+ *         nbytes does not include the terminal '\0'.
+ *         '''
+ *         TabProxies.TupleProxy.update( self, buffer, nbytes )             # <<<<<<<<<<<<<<
+ * 
+ *         self.contig = self.fields[0]
+ */
+  __pyx_t_1 = __pyx_vtabptr_10TabProxies_TupleProxy->update(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_self), __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":128
+ *         TabProxies.TupleProxy.update( self, buffer, nbytes )
+ * 
+ *         self.contig = self.fields[0]             # <<<<<<<<<<<<<<
+ *         # vcf counts from 1 - correct here
+ *         self.pos = atoi( self.fields[1] ) - 1
+ */
+  __pyx_v_self->contig = (__pyx_v_self->__pyx_base.fields[0]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":130
+ *         self.contig = self.fields[0]
+ *         # vcf counts from 1 - correct here
+ *         self.pos = atoi( self.fields[1] ) - 1             # <<<<<<<<<<<<<<
+ * 
+ *     def __len__(self):
+ */
+  __pyx_v_self->pos = (atoi((__pyx_v_self->__pyx_base.fields[1])) - 1);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cvcf.VCFRecord.update");
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":132
+ *         self.pos = atoi( self.fields[1] ) - 1
+ * 
+ *     def __len__(self):             # <<<<<<<<<<<<<<
+ *         return max(0, self.nfields - 9)
+ * 
+ */
+
+static Py_ssize_t __pyx_pf_4cvcf_9VCFRecord___len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pf_4cvcf_9VCFRecord___len__(PyObject *__pyx_v_self) {
+  Py_ssize_t __pyx_r;
+  long __pyx_t_1;
+  long __pyx_t_2;
+  long __pyx_t_3;
+  __Pyx_RefNannySetupContext("__len__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":133
+ * 
+ *     def __len__(self):
+ *         return max(0, self.nfields - 9)             # <<<<<<<<<<<<<<
+ * 
+ *     property contig:
+ */
+  __pyx_t_1 = (((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.nfields - 9);
+  __pyx_t_2 = 0;
+  if ((__pyx_t_1 > __pyx_t_2)) {
+    __pyx_t_3 = __pyx_t_1;
+  } else {
+    __pyx_t_3 = __pyx_t_2;
+  }
+  __pyx_r = __pyx_t_3;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":136
+ * 
+ *     property contig:
+ *         def __get__(self): return self.contig             # <<<<<<<<<<<<<<
+ * 
+ *     property pos:
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6contig___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6contig___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->contig); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __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("cvcf.VCFRecord.contig.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":139
+ * 
+ *     property pos:
+ *         def __get__(self): return self.pos             # <<<<<<<<<<<<<<
+ * 
+ *     property id:
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3pos___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3pos___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __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("cvcf.VCFRecord.pos.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":142
+ * 
+ *     property id:
+ *         def __get__(self): return self.fields[2]             # <<<<<<<<<<<<<<
+ * 
+ *     property ref:
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_2id___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_2id___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[2])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __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("cvcf.VCFRecord.id.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":145
+ * 
+ *     property ref:
+ *         def __get__(self): return self.fields[3]             # <<<<<<<<<<<<<<
+ * 
+ *     property alt:
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3ref___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3ref___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[3])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __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("cvcf.VCFRecord.ref.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":148
+ * 
+ *     property alt:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             # convert v3.3 to v4.0 alleles below
+ *             alt = self.fields[4]
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3alt___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_3alt___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_v_alt;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __pyx_v_alt = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":150
+ *         def __get__(self):
+ *             # convert v3.3 to v4.0 alleles below
+ *             alt = self.fields[4]             # <<<<<<<<<<<<<<
+ *             if alt == ".": alt = []
+ *             else: alt = alt.upper().split(',')
+ */
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[4])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(__pyx_v_alt);
+  __pyx_v_alt = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":151
+ *             # convert v3.3 to v4.0 alleles below
+ *             alt = self.fields[4]
+ *             if alt == ".": alt = []             # <<<<<<<<<<<<<<
+ *             else: alt = alt.upper().split(',')
+ *             return alt
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_alt, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __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 = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":152
+ *             alt = self.fields[4]
+ *             if alt == ".": alt = []
+ *             else: alt = alt.upper().split(',')             # <<<<<<<<<<<<<<
+ *             return alt
+ * 
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_alt, __pyx_n_s__upper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __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 = 152; __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__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = __pyx_t_4;
+    __pyx_t_4 = 0;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":153
+ *             if alt == ".": alt = []
+ *             else: alt = alt.upper().split(',')
+ *             return alt             # <<<<<<<<<<<<<<
+ * 
+ *     property qual:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_alt);
+  __pyx_r = __pyx_v_alt;
+  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_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("cvcf.VCFRecord.alt.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_alt);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":156
+ * 
+ *     property qual:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             qual = self.fields[5]
+ *             if qual == b".": qual = -1
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_4qual___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_4qual___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_v_qual;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  double __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":157
+ *     property qual:
+ *         def __get__(self):
+ *             qual = self.fields[5]             # <<<<<<<<<<<<<<
+ *             if qual == b".": qual = -1
+ *             else:
+ */
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[5])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(__pyx_v_qual);
+  __pyx_v_qual = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":158
+ *         def __get__(self):
+ *             qual = self.fields[5]
+ *             if qual == b".": qual = -1             # <<<<<<<<<<<<<<
+ *             else:
+ *                 try:    qual = float(qual)
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qual, ((PyObject *)__pyx_kp_b_6), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __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 = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_INCREF(__pyx_int_neg_1);
+    __Pyx_DECREF(__pyx_v_qual);
+    __pyx_v_qual = __pyx_int_neg_1;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":160
+ *             if qual == b".": qual = -1
+ *             else:
+ *                 try:    qual = float(qual)             # <<<<<<<<<<<<<<
+ *                 except: self.vcf.error(str(self),self.QUAL_NOT_NUMERICAL)
+ * 
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+        __pyx_t_3 = __Pyx_PyObject_AsDouble(__pyx_v_qual); if (unlikely(__pyx_t_3 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+        __pyx_t_1 = PyFloat_FromDouble(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_v_qual);
+        __pyx_v_qual = __pyx_t_1;
+        __pyx_t_1 = 0;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L13_try_end;
+      __pyx_L6_error:;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":161
+ *             else:
+ *                 try:    qual = float(qual)
+ *                 except: self.vcf.error(str(self),self.QUAL_NOT_NUMERICAL)             # <<<<<<<<<<<<<<
+ * 
+ *     property filter:
+ */
+      /*except:*/ {
+        __Pyx_AddTraceback("cvcf.VCFRecord.qual.__get__");
+        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_6 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s__error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(__pyx_v_self);
+        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
+        __Pyx_GIVEREF(__pyx_v_self);
+        __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__QUAL_NOT_NUMERICAL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
+        __Pyx_GIVEREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_8 = 0;
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        goto __pyx_L7_exception_handled;
+      }
+      __pyx_L8_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L7_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L13_try_end:;
+    }
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cvcf.VCFRecord.qual.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_qual);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":164
+ * 
+ *     property filter:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             f = self.fields[6]
+ *             # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6filter___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6filter___get__(PyObject *__pyx_v_self) {
+  char *__pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":165
+ *     property filter:
+ *         def __get__(self):
+ *             f = self.fields[6]             # <<<<<<<<<<<<<<
+ *             # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ *             if f == b"." or f == b"PASS" or f == b"0": return []
+ */
+  __pyx_v_f = (((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[6]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":167
+ *             f = self.fields[6]
+ *             # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ *             if f == b"." or f == b"PASS" or f == b"0": return []             # <<<<<<<<<<<<<<
+ *             else: return f.split(';')
+ * 
+ */
+  __pyx_t_1 = (__pyx_v_f == __pyx_k_6);
+  if (!__pyx_t_1) {
+    __pyx_t_2 = (__pyx_v_f == __pyx_k__PASS);
+    if (!__pyx_t_2) {
+      __pyx_t_3 = (__pyx_v_f == __pyx_k__0);
+      __pyx_t_4 = __pyx_t_3;
+    } else {
+      __pyx_t_4 = __pyx_t_2;
+    }
+    __pyx_t_2 = __pyx_t_4;
+  } else {
+    __pyx_t_2 = __pyx_t_1;
+  }
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_r = ((PyObject *)__pyx_t_5);
+    __pyx_t_5 = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":168
+ *             # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ *             if f == b"." or f == b"PASS" or f == b"0": return []
+ *             else: return f.split(';')             # <<<<<<<<<<<<<<
+ * 
+ *     property info:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_5 = PyBytes_FromString(__pyx_v_f); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_t_5), __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __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 = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+    __pyx_t_7 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_r = __pyx_t_7;
+    __pyx_t_7 = 0;
+    goto __pyx_L0;
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("cvcf.VCFRecord.filter.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":171
+ * 
+ *     property info:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             col = self.fields[7]
+ *             # dictionary of keys, and list of values
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_4info___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_4info___get__(PyObject *__pyx_v_self) {
+  char *__pyx_v_col;
+  PyObject *__pyx_v_info;
+  PyObject *__pyx_v_blurp;
+  PyObject *__pyx_v_elts;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  Py_ssize_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __pyx_v_info = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_blurp = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_elts = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":172
+ *     property info:
+ *         def __get__(self):
+ *             col = self.fields[7]             # <<<<<<<<<<<<<<
+ *             # dictionary of keys, and list of values
+ *             info = {}
+ */
+  __pyx_v_col = (((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[7]);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":174
+ *             col = self.fields[7]
+ *             # dictionary of keys, and list of values
+ *             info = {}             # <<<<<<<<<<<<<<
+ *             if col != b".":
+ *                 for blurp in col.split(';'):
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_v_info));
+  __pyx_v_info = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":175
+ *             # dictionary of keys, and list of values
+ *             info = {}
+ *             if col != b".":             # <<<<<<<<<<<<<<
+ *                 for blurp in col.split(';'):
+ *                     elts = blurp.split('=')
+ */
+  __pyx_t_2 = (__pyx_v_col != __pyx_k_6);
+  if (__pyx_t_2) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":176
+ *             info = {}
+ *             if col != b".":
+ *                 for blurp in col.split(';'):             # <<<<<<<<<<<<<<
+ *                     elts = blurp.split('=')
+ *                     if len(elts) == 1: v = None
+ */
+    __pyx_t_1 = PyBytes_FromString(__pyx_v_col); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_t_1), __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __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 = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
+      __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1);
+    } else {
+      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
+      } else {
+        __pyx_t_5 = PyIter_Next(__pyx_t_1);
+        if (!__pyx_t_5) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_5);
+      }
+      __Pyx_DECREF(__pyx_v_blurp);
+      __pyx_v_blurp = __pyx_t_5;
+      __pyx_t_5 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":177
+ *             if col != b".":
+ *                 for blurp in col.split(';'):
+ *                     elts = blurp.split('=')             # <<<<<<<<<<<<<<
+ *                     if len(elts) == 1: v = None
+ *                     elif len(elts) == 2: v = elts[1]
+ */
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_blurp, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_t_6 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_elts);
+      __pyx_v_elts = __pyx_t_6;
+      __pyx_t_6 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":178
+ *                 for blurp in col.split(';'):
+ *                     elts = blurp.split('=')
+ *                     if len(elts) == 1: v = None             # <<<<<<<<<<<<<<
+ *                     elif len(elts) == 2: v = elts[1]
+ *                     else: self.vcf.error(str(self),self.ERROR_INFO_STRING)
+ */
+      __pyx_t_7 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = (__pyx_t_7 == 1);
+      if (__pyx_t_2) {
+        __Pyx_INCREF(Py_None);
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = Py_None;
+        goto __pyx_L8;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":179
+ *                     elts = blurp.split('=')
+ *                     if len(elts) == 1: v = None
+ *                     elif len(elts) == 2: v = elts[1]             # <<<<<<<<<<<<<<
+ *                     else: self.vcf.error(str(self),self.ERROR_INFO_STRING)
+ *                     info[elts[0]] = self.vcf.parse_formatdata(elts[0], v, self.vcf._info, str(self))
+ */
+      __pyx_t_7 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = (__pyx_t_7 == 2);
+      if (__pyx_t_2) {
+        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_elts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_6;
+        __pyx_t_6 = 0;
+        goto __pyx_L8;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":180
+ *                     if len(elts) == 1: v = None
+ *                     elif len(elts) == 2: v = elts[1]
+ *                     else: self.vcf.error(str(self),self.ERROR_INFO_STRING)             # <<<<<<<<<<<<<<
+ *                     info[elts[0]] = self.vcf.parse_formatdata(elts[0], v, self.vcf._info, str(self))
+ *             return info
+ */
+        __pyx_t_6 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s__error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_INCREF(__pyx_v_self);
+        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
+        __Pyx_GIVEREF(__pyx_v_self);
+        __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ERROR_INFO_STRING); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __pyx_t_5 = 0;
+        __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      }
+      __pyx_L8:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":181
+ *                     elif len(elts) == 2: v = elts[1]
+ *                     else: self.vcf.error(str(self),self.ERROR_INFO_STRING)
+ *                     info[elts[0]] = self.vcf.parse_formatdata(elts[0], v, self.vcf._info, str(self))             # <<<<<<<<<<<<<<
+ *             return info
+ * 
+ */
+      __pyx_t_4 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s__parse_formatdata); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __pyx_t_6 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s___info); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_self);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
+      __Pyx_GIVEREF(__pyx_v_self);
+      __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __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);
+      __Pyx_INCREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_v);
+      __Pyx_GIVEREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      __pyx_t_8 = 0;
+      __pyx_t_6 = 0;
+      __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      if (PyDict_SetItem(((PyObject *)__pyx_v_info), __pyx_t_5, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":182
+ *                     else: self.vcf.error(str(self),self.ERROR_INFO_STRING)
+ *                     info[elts[0]] = self.vcf.parse_formatdata(elts[0], v, self.vcf._info, str(self))
+ *             return info             # <<<<<<<<<<<<<<
+ * 
+ *     property format:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_info));
+  __pyx_r = ((PyObject *)__pyx_v_info);
+  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_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cvcf.VCFRecord.info.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_info);
+  __Pyx_DECREF(__pyx_v_blurp);
+  __Pyx_DECREF(__pyx_v_elts);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":185
+ * 
+ *     property format:
+ *          def __get__(self):             # <<<<<<<<<<<<<<
+ *              return self.fields[8].split(':')
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6format___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_6format___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":186
+ *     property format:
+ *          def __get__(self):
+ *              return self.fields[8].split(':')             # <<<<<<<<<<<<<<
+ * 
+ *     property samples:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[8])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_t_1), __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__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 = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_3));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __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_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 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_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("cvcf.VCFRecord.format.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":189
+ * 
+ *     property samples:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             return self.vcf._samples
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_7samples___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord_7samples___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":190
+ *     property samples:
+ *         def __get__(self):
+ *             return self.vcf._samples             # <<<<<<<<<<<<<<
+ * 
+ *     def __getitem__(self, key):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s___samples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __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("cvcf.VCFRecord.samples.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":192
+ *             return self.vcf._samples
+ * 
+ *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
+ * 
+ *         # parse sample columns
+ */
+
+static PyObject *__pyx_pf_4cvcf_9VCFRecord___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
+static PyObject *__pyx_pf_4cvcf_9VCFRecord___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
+  PyObject *__pyx_v_values;
+  PyObject *__pyx_v_alt;
+  PyObject *__pyx_v_format;
+  PyObject *__pyx_v_result;
+  Py_ssize_t __pyx_v_idx;
+  PyObject *__pyx_v_expected;
+  PyObject *__pyx_v_value;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  int __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  Py_ssize_t __pyx_t_10;
+  int __pyx_t_11;
+  int __pyx_t_12;
+  __Pyx_RefNannySetupContext("__getitem__");
+  __pyx_v_values = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_alt = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_format = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_expected = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":195
+ * 
+ *         # parse sample columns
+ *         values = self.fields[self.vcf._sample2column[key]].split(':')             # <<<<<<<<<<<<<<
+ *         alt = self.alt
+ *         format = self.format
+ */
+  __pyx_t_1 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s___sample2column); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.fields[__pyx_t_3])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_t_2), __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__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 = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_values);
+  __pyx_v_values = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":196
+ *         # parse sample columns
+ *         values = self.fields[self.vcf._sample2column[key]].split(':')
+ *         alt = self.alt             # <<<<<<<<<<<<<<
+ *         format = self.format
+ * 
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__alt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_v_alt);
+  __pyx_v_alt = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":197
+ *         values = self.fields[self.vcf._sample2column[key]].split(':')
+ *         alt = self.alt
+ *         format = self.format             # <<<<<<<<<<<<<<
+ * 
+ *         if len(values) > len(format):
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_v_format);
+  __pyx_v_format = __pyx_t_4;
+  __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":199
+ *         format = self.format
+ * 
+ *         if len(values) > len(format):             # <<<<<<<<<<<<<<
+ *             self.error(str(self.line),self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" %\
+ *                            (len(values),key,len(format)))
+ */
+  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = (__pyx_t_3 > __pyx_t_5);
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":200
+ * 
+ *         if len(values) > len(format):
+ *             self.error(str(self.line),self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" %\             # <<<<<<<<<<<<<<
+ *                            (len(values),key,len(format)))
+ * 
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__line); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":201
+ *         if len(values) > len(format):
+ *             self.error(str(self.line),self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" %\
+ *                            (len(values),key,len(format)))             # <<<<<<<<<<<<<<
+ * 
+ *         result = {}
+ */
+    __pyx_t_5 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_5 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_7);
+    __Pyx_INCREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_key);
+    __Pyx_GIVEREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
+    __Pyx_GIVEREF(__pyx_t_8);
+    __pyx_t_7 = 0;
+    __pyx_t_8 = 0;
+    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __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);
+    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_9, 2, ((PyObject *)__pyx_t_8));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
+    __pyx_t_2 = 0;
+    __pyx_t_1 = 0;
+    __pyx_t_8 = 0;
+    __pyx_t_8 = PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":203
+ *                            (len(values),key,len(format)))
+ * 
+ *         result = {}             # <<<<<<<<<<<<<<
+ *         for idx in range(len(format)):
+ *             expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)
+ */
+  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+  __Pyx_DECREF(((PyObject *)__pyx_v_result));
+  __pyx_v_result = __pyx_t_8;
+  __pyx_t_8 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":204
+ * 
+ *         result = {}
+ *         for idx in range(len(format)):             # <<<<<<<<<<<<<<
+ *             expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)
+ *             if idx < len(values): value = values[idx]
+ */
+  __pyx_t_5 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) {
+    __pyx_v_idx = __pyx_t_3;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":205
+ *         result = {}
+ *         for idx in range(len(format)):
+ *             expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)             # <<<<<<<<<<<<<<
+ *             if idx < len(values): value = values[idx]
+ *             else:
+ */
+    __pyx_t_8 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s__get_expected); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_4 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s___format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __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);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_v_alt);
+    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_alt);
+    __Pyx_GIVEREF(__pyx_v_alt);
+    __pyx_t_9 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_expected);
+    __pyx_v_expected = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":206
+ *         for idx in range(len(format)):
+ *             expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)
+ *             if idx < len(values): value = values[idx]             # <<<<<<<<<<<<<<
+ *             else:
+ *                 if expected == -1: value = "."
+ */
+    __pyx_t_10 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = (__pyx_v_idx < __pyx_t_10);
+    if (__pyx_t_6) {
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_values, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_v_value);
+      __pyx_v_value = __pyx_t_4;
+      __pyx_t_4 = 0;
+      goto __pyx_L8;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":208
+ *             if idx < len(values): value = values[idx]
+ *             else:
+ *                 if expected == -1: value = "."             # <<<<<<<<<<<<<<
+ *                 else: value = ",".join(["."]*expected)
+ * 
+ */
+      __pyx_t_4 = PyObject_RichCompare(__pyx_v_expected, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (__pyx_t_6) {
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+        __Pyx_DECREF(__pyx_v_value);
+        __pyx_v_value = ((PyObject *)__pyx_kp_s_6);
+        goto __pyx_L9;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":209
+ *             else:
+ *                 if expected == -1: value = "."
+ *                 else: value = ",".join(["."]*expected)             # <<<<<<<<<<<<<<
+ * 
+ *             result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, str(self.data))
+ */
+        __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+        PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+        __pyx_t_8 = PyNumber_Multiply(((PyObject *)__pyx_t_1), __pyx_v_expected); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        __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 = 209; __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);
+        __pyx_t_8 = 0;
+        __pyx_t_8 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_v_value);
+        __pyx_v_value = __pyx_t_8;
+        __pyx_t_8 = 0;
+      }
+      __pyx_L9:;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":211
+ *                 else: value = ",".join(["."]*expected)
+ * 
+ *             result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, str(self.data))             # <<<<<<<<<<<<<<
+ *             if expected != -1 and len(result[format[idx]]) != expected:
+ *                 self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+ */
+    __pyx_t_8 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s__parse_formatdata); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = PyObject_GetAttr(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->vcf, __pyx_n_s___format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_9 = PyBytes_FromString(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.data); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_9));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
+    __pyx_t_9 = 0;
+    __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_9);
+    __Pyx_GIVEREF(__pyx_t_9);
+    __pyx_t_1 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_9 = 0;
+    __pyx_t_9 = PyObject_Call(__pyx_t_8, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __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_2); __pyx_t_2 = 0;
+    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_t_2, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":212
+ * 
+ *             result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, str(self.data))
+ *             if expected != -1 and len(result[format[idx]]) != expected:             # <<<<<<<<<<<<<<
+ *                 self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+ *                            "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+ */
+    __pyx_t_9 = PyObject_RichCompare(__pyx_v_expected, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    if (__pyx_t_6) {
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_10 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_v_expected, Py_NE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_12 = __pyx_t_11;
+    } else {
+      __pyx_t_12 = __pyx_t_6;
+    }
+    if (__pyx_t_12) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":213
+ *             result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, str(self.data))
+ *             if expected != -1 and len(result[format[idx]]) != expected:
+ *                 self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,             # <<<<<<<<<<<<<<
+ *                            "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+ *                 if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))
+ */
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_v_self)->__pyx_base.data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":214
+ *             if expected != -1 and len(result[format[idx]]) != expected:
+ *                 self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+ *                            "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))             # <<<<<<<<<<<<<<
+ *                 if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))
+ *                 result[format[idx]] = result[format[idx]][:expected]
+ */
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_1); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __Pyx_INCREF(__pyx_v_expected);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_expected);
+      __Pyx_GIVEREF(__pyx_v_expected);
+      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_7);
+      __pyx_t_4 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_t_7));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+      __pyx_t_2 = 0;
+      __pyx_t_8 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_7 = PyObject_Call(__pyx_t_9, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":215
+ *                 self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+ *                            "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+ *                 if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))             # <<<<<<<<<<<<<<
+ *                 result[format[idx]] = result[format[idx]][:expected]
+ * 
+ */
+      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_7); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_v_expected, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_12) {
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_7); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_7 = 0;
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_7); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_10 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_7 = PyNumber_Subtract(__pyx_v_expected, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyNumber_Multiply(((PyObject *)__pyx_t_1), __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_7); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_t_7, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        goto __pyx_L11;
+      }
+      __pyx_L11:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":216
+ *                            "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+ *                 if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))
+ *                 result[format[idx]] = result[format[idx]][:expected]             # <<<<<<<<<<<<<<
+ * 
+ *         return result
+ */
+      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_8 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_7); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_expected); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PySequence_GetSlice(__pyx_t_8, 0, __pyx_t_10); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_t_8, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L10;
+    }
+    __pyx_L10:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":218
+ *                 result[format[idx]] = result[format[idx]][:expected]
+ * 
+ *         return result             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_result));
+  __pyx_r = ((PyObject *)__pyx_v_result);
+  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_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cvcf.VCFRecord.__getitem__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_values);
+  __Pyx_DECREF(__pyx_v_alt);
+  __Pyx_DECREF(__pyx_v_format);
+  __Pyx_DECREF(__pyx_v_result);
+  __Pyx_DECREF(__pyx_v_expected);
+  __Pyx_DECREF(__pyx_v_value);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":224
+ *     '''converts a :term:`tabix row` into a VCF record.'''
+ *     cdef vcffile
+ *     def __init__(self, vcffile ):             # <<<<<<<<<<<<<<
+ *         self.vcffile = vcffile
+ *     def __call__(self, char * buffer, int len ):
+ */
+
+static int __pyx_pf_4cvcf_11asVCFRecord___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_4cvcf_11asVCFRecord___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_vcffile = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__vcffile,0};
+  __Pyx_RefNannySetupContext("__init__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vcffile);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_vcffile = values[0];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_vcffile = PyTuple_GET_ITEM(__pyx_args, 0);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.asVCFRecord.__init__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":225
+ *     cdef vcffile
+ *     def __init__(self, vcffile ):
+ *         self.vcffile = vcffile             # <<<<<<<<<<<<<<
+ *     def __call__(self, char * buffer, int len ):
+ *         cdef VCFRecord r
+ */
+  __Pyx_INCREF(__pyx_v_vcffile);
+  __Pyx_GIVEREF(__pyx_v_vcffile);
+  __Pyx_GOTREF(((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile);
+  __Pyx_DECREF(((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile);
+  ((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile = __pyx_v_vcffile;
+
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":226
+ *     def __init__(self, vcffile ):
+ *         self.vcffile = vcffile
+ *     def __call__(self, char * buffer, int len ):             # <<<<<<<<<<<<<<
+ *         cdef VCFRecord r
+ *         r = VCFRecord( self.vcffile )
+ */
+
+static PyObject *__pyx_pf_4cvcf_11asVCFRecord___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_4cvcf_11asVCFRecord___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  char *__pyx_v_buffer;
+  int __pyx_v_len;
+  struct __pyx_obj_4cvcf_VCFRecord *__pyx_v_r;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
+  __Pyx_RefNannySetupContext("__call__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.asVCFRecord.__call__");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_r = ((struct __pyx_obj_4cvcf_VCFRecord *)Py_None); __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":228
+ *     def __call__(self, char * buffer, int len ):
+ *         cdef VCFRecord r
+ *         r = VCFRecord( self.vcffile )             # <<<<<<<<<<<<<<
+ *         r.copy( buffer, len )
+ *         return r
+ */
+  __pyx_t_1 = PyTuple_New(1); 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_INCREF(((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile);
+  __Pyx_GIVEREF(((struct __pyx_obj_4cvcf_asVCFRecord *)__pyx_v_self)->vcffile);
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4cvcf_VCFRecord)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __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_v_r));
+  __pyx_v_r = ((struct __pyx_obj_4cvcf_VCFRecord *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":229
+ *         cdef VCFRecord r
+ *         r = VCFRecord( self.vcffile )
+ *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
+ *         return r
+ * 
+ */
+  __pyx_t_2 = ((struct __pyx_vtabstruct_4cvcf_VCFRecord *)__pyx_v_r->__pyx_base.__pyx_vtab)->__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":230
+ *         r = VCFRecord( self.vcffile )
+ *         r.copy( buffer, len )
+ *         return r             # <<<<<<<<<<<<<<
+ * 
+ * class VCF(object):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_r));
+  __pyx_r = ((PyObject *)__pyx_v_r);
+  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("cvcf.asVCFRecord.__call__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_r);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":306
+ *     _lines = None
+ * 
+ *     def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):             # <<<<<<<<<<<<<<
+ *         # make error identifiers accessible by name
+ *         for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_4cvcf_3VCF___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v__copy = 0;
+  PyObject *__pyx_v_reference = 0;
+  PyObject *__pyx_v_regions = 0;
+  PyObject *__pyx_v_lines = 0;
+  PyObject *__pyx_v_leftalign = 0;
+  PyObject *__pyx_v_id;
+  PyObject *__pyx_r = NULL;
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s___copy,&__pyx_n_s__reference,&__pyx_n_s__regions,&__pyx_n_s__lines,&__pyx_n_s__leftalign,0};
+  __Pyx_RefNannySetupContext("__init__");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[6] = {0,0,0,0,0,0};
+    values[1] = ((PyObject *)Py_None);
+    values[2] = ((PyObject *)Py_None);
+    values[3] = ((PyObject *)Py_None);
+    values[4] = ((PyObject *)Py_None);
+    values[5] = __pyx_k_13;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s___copy);
+        if (value) { values[1] = value; kw_args--; }
+      }
+      case  2:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+        if (value) { values[2] = value; kw_args--; }
+      }
+      case  3:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__regions);
+        if (value) { values[3] = value; kw_args--; }
+      }
+      case  4:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lines);
+        if (value) { values[4] = value; kw_args--; }
+      }
+      case  5:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__leftalign);
+        if (value) { values[5] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v__copy = values[1];
+    __pyx_v_reference = values[2];
+    __pyx_v_regions = values[3];
+    __pyx_v_lines = values[4];
+    __pyx_v_leftalign = values[5];
+  } else {
+    __pyx_v__copy = ((PyObject *)Py_None);
+    __pyx_v_reference = ((PyObject *)Py_None);
+    __pyx_v_regions = ((PyObject *)Py_None);
+    __pyx_v_lines = ((PyObject *)Py_None);
+    __pyx_v_leftalign = __pyx_k_13;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  6: __pyx_v_leftalign = PyTuple_GET_ITEM(__pyx_args, 5);
+      case  5: __pyx_v_lines = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: __pyx_v_regions = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: __pyx_v__copy = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.__init__");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_id = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":308
+ *     def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):
+ *         # make error identifiers accessible by name
+ *         for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id             # <<<<<<<<<<<<<<
+ *         if _copy != None:
+ *             self._leftalign = _copy._leftalign
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_3);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_id);
+    __pyx_v_id = __pyx_t_2;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___errors); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_v_id); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__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 = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (PyObject_SetItem(__pyx_t_2, __pyx_t_5, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":309
+ *         # make error identifiers accessible by name
+ *         for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+ *         if _copy != None:             # <<<<<<<<<<<<<<
+ *             self._leftalign = _copy._leftalign
+ *             self._header = _copy._header[:]
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v__copy, Py_None, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_7) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":310
+ *         for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+ *         if _copy != None:
+ *             self._leftalign = _copy._leftalign             # <<<<<<<<<<<<<<
+ *             self._header = _copy._header[:]
+ *             self._version = _copy._version
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___leftalign); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___leftalign, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":311
+ *         if _copy != None:
+ *             self._leftalign = _copy._leftalign
+ *             self._header = _copy._header[:]             # <<<<<<<<<<<<<<
+ *             self._version = _copy._version
+ *             self._info = copy.deepcopy(_copy._info)
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PySequence_GetSlice(__pyx_t_3, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___header, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":312
+ *             self._leftalign = _copy._leftalign
+ *             self._header = _copy._header[:]
+ *             self._version = _copy._version             # <<<<<<<<<<<<<<
+ *             self._info = copy.deepcopy(_copy._info)
+ *             self._filter = copy.deepcopy(_copy._filter)
+ */
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___version); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___version, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":313
+ *             self._header = _copy._header[:]
+ *             self._version = _copy._version
+ *             self._info = copy.deepcopy(_copy._info)             # <<<<<<<<<<<<<<
+ *             self._filter = copy.deepcopy(_copy._filter)
+ *             self._format = copy.deepcopy(_copy._format)
+ */
+    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___info); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___info, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":314
+ *             self._version = _copy._version
+ *             self._info = copy.deepcopy(_copy._info)
+ *             self._filter = copy.deepcopy(_copy._filter)             # <<<<<<<<<<<<<<
+ *             self._format = copy.deepcopy(_copy._format)
+ *             self._samples = _copy._samples[:]
+ */
+    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___filter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___filter, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":315
+ *             self._info = copy.deepcopy(_copy._info)
+ *             self._filter = copy.deepcopy(_copy._filter)
+ *             self._format = copy.deepcopy(_copy._format)             # <<<<<<<<<<<<<<
+ *             self._samples = _copy._samples[:]
+ *             self._sample2column = copy.deepcopy(_copy._sample2column)
+ */
+    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___format, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":316
+ *             self._filter = copy.deepcopy(_copy._filter)
+ *             self._format = copy.deepcopy(_copy._format)
+ *             self._samples = _copy._samples[:]             # <<<<<<<<<<<<<<
+ *             self._sample2column = copy.deepcopy(_copy._sample2column)
+ *             self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+ */
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___samples); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PySequence_GetSlice(__pyx_t_5, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___samples, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":317
+ *             self._format = copy.deepcopy(_copy._format)
+ *             self._samples = _copy._samples[:]
+ *             self._sample2column = copy.deepcopy(_copy._sample2column)             # <<<<<<<<<<<<<<
+ *             self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+ *             self._warn_errors = copy.deepcopy(_copy._warn_errors)
+ */
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___sample2column); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __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);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __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_3); __pyx_t_3 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___sample2column, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":318
+ *             self._samples = _copy._samples[:]
+ *             self._sample2column = copy.deepcopy(_copy._sample2column)
+ *             self._ignored_errors = copy.deepcopy(_copy._ignored_errors)             # <<<<<<<<<<<<<<
+ *             self._warn_errors = copy.deepcopy(_copy._warn_errors)
+ *             self._reference = _copy._reference
+ */
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___ignored_errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __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);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __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_5); __pyx_t_5 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___ignored_errors, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":319
+ *             self._sample2column = copy.deepcopy(_copy._sample2column)
+ *             self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+ *             self._warn_errors = copy.deepcopy(_copy._warn_errors)             # <<<<<<<<<<<<<<
+ *             self._reference = _copy._reference
+ *             self._regions = _copy._regions
+ */
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__deepcopy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___warn_errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __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);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __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_3); __pyx_t_3 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___warn_errors, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":320
+ *             self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+ *             self._warn_errors = copy.deepcopy(_copy._warn_errors)
+ *             self._reference = _copy._reference             # <<<<<<<<<<<<<<
+ *             self._regions = _copy._regions
+ *         if reference: self._reference = reference
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___reference); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___reference, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":321
+ *             self._warn_errors = copy.deepcopy(_copy._warn_errors)
+ *             self._reference = _copy._reference
+ *             self._regions = _copy._regions             # <<<<<<<<<<<<<<
+ *         if reference: self._reference = reference
+ *         if regions: self._regions = regions
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v__copy, __pyx_n_s___regions); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___regions, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":322
+ *             self._reference = _copy._reference
+ *             self._regions = _copy._regions
+ *         if reference: self._reference = reference             # <<<<<<<<<<<<<<
+ *         if regions: self._regions = regions
+ *         if leftalign: self._leftalign = leftalign
+ */
+  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_7) {
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___reference, __pyx_v_reference) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":323
+ *             self._regions = _copy._regions
+ *         if reference: self._reference = reference
+ *         if regions: self._regions = regions             # <<<<<<<<<<<<<<
+ *         if leftalign: self._leftalign = leftalign
+ *         self._lines = lines
+ */
+  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_regions); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_7) {
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___regions, __pyx_v_regions) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L10;
+  }
+  __pyx_L10:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":324
+ *         if reference: self._reference = reference
+ *         if regions: self._regions = regions
+ *         if leftalign: self._leftalign = leftalign             # <<<<<<<<<<<<<<
+ *         self._lines = lines
+ * 
+ */
+  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_leftalign); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_7) {
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___leftalign, __pyx_v_leftalign) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L11;
+  }
+  __pyx_L11:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":325
+ *         if regions: self._regions = regions
+ *         if leftalign: self._leftalign = leftalign
+ *         self._lines = lines             # <<<<<<<<<<<<<<
+ * 
+ *     def error(self,line,error,opt=None):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___lines, __pyx_v_lines) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.VCF.__init__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_id);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":327
+ *         self._lines = lines
+ * 
+ *     def error(self,line,error,opt=None):             # <<<<<<<<<<<<<<
+ *         if error in self._ignored_errors: return
+ *         errorlabel, errorstring = self._errors[error].split(':')
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_error = {__Pyx_NAMESTR("error"), (PyCFunction)__pyx_pf_4cvcf_3VCF_error, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_error = 0;
+  PyObject *__pyx_v_opt = 0;
+  PyObject *__pyx_v_errorlabel;
+  PyObject *__pyx_v_errorstring;
+  PyObject *__pyx_v_errwarn;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,&__pyx_n_s__error,&__pyx_n_s__opt,0};
+  __Pyx_RefNannySetupContext("error");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[4] = {0,0,0,0};
+    values[3] = ((PyObject *)Py_None);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("error", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__error);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("error", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__opt);
+        if (value) { values[3] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "error") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+    __pyx_v_error = values[2];
+    __pyx_v_opt = values[3];
+  } else {
+    __pyx_v_opt = ((PyObject *)Py_None);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4:
+      __pyx_v_opt = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3:
+      __pyx_v_error = PyTuple_GET_ITEM(__pyx_args, 2);
+      __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("error", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.error");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_errorlabel = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_errorstring = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_errwarn = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":328
+ * 
+ *     def error(self,line,error,opt=None):
+ *         if error in self._ignored_errors: return             # <<<<<<<<<<<<<<
+ *         errorlabel, errorstring = self._errors[error].split(':')
+ *         if opt: errorstring = errorstring % opt
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___ignored_errors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = ((PySequence_Contains(__pyx_t_1, __pyx_v_error))); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":329
+ *     def error(self,line,error,opt=None):
+ *         if error in self._ignored_errors: return
+ *         errorlabel, errorstring = self._errors[error].split(':')             # <<<<<<<<<<<<<<
+ *         if opt: errorstring = errorstring % opt
+ *         errwarn = ["Error","Warning"][error in self._warn_errors]
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___errors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_v_error); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __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__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
+    PyObject* tuple = __pyx_t_4;
+    __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_v_errorlabel);
+    __pyx_v_errorlabel = __pyx_t_3;
+    __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_errorstring);
+    __pyx_v_errorstring = __pyx_t_1;
+    __pyx_t_1 = 0;
+  } else {
+    __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_v_errorlabel);
+    __pyx_v_errorlabel = __pyx_t_3;
+    __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_errorstring);
+    __pyx_v_errorstring = __pyx_t_1;
+    __pyx_t_1 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":330
+ *         if error in self._ignored_errors: return
+ *         errorlabel, errorstring = self._errors[error].split(':')
+ *         if opt: errorstring = errorstring % opt             # <<<<<<<<<<<<<<
+ *         errwarn = ["Error","Warning"][error in self._warn_errors]
+ *         sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+ */
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_opt); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_2) {
+    __pyx_t_4 = PyNumber_Remainder(__pyx_v_errorstring, __pyx_v_opt); 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);
+    __Pyx_DECREF(__pyx_v_errorstring);
+    __pyx_v_errorstring = __pyx_t_4;
+    __pyx_t_4 = 0;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":331
+ *         errorlabel, errorstring = self._errors[error].split(':')
+ *         if opt: errorstring = errorstring % opt
+ *         errwarn = ["Error","Warning"][error in self._warn_errors]             # <<<<<<<<<<<<<<
+ *         sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+ *         if error in self._warn_errors: return
+ */
+  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Error));
+  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__Error));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Error));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Warning));
+  PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__Warning));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Warning));
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___warn_errors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = ((PySequence_Contains(__pyx_t_1, __pyx_v_error))); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_t_4), __pyx_t_2, sizeof(int), __Pyx_PyBool_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_v_errwarn);
+  __pyx_v_errwarn = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":332
+ *         if opt: errorstring = errorstring % opt
+ *         errwarn = ["Error","Warning"][error in self._warn_errors]
+ *         sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))             # <<<<<<<<<<<<<<
+ *         if error in self._warn_errors: return
+ *         raise ValueError(errorstring)
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __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_t_4, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __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_GetAttr(__pyx_v_self, __pyx_n_s___lineno); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_v_line);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_line);
+  __Pyx_GIVEREF(__pyx_v_line);
+  __Pyx_INCREF(__pyx_v_errwarn);
+  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_errwarn);
+  __Pyx_GIVEREF(__pyx_v_errwarn);
+  __Pyx_INCREF(__pyx_v_errorlabel);
+  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_errorlabel);
+  __Pyx_GIVEREF(__pyx_v_errorlabel);
+  __Pyx_INCREF(__pyx_v_errorstring);
+  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_errorstring);
+  __Pyx_GIVEREF(__pyx_v_errorstring);
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __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 = 332; __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_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":333
+ *         errwarn = ["Error","Warning"][error in self._warn_errors]
+ *         sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+ *         if error in self._warn_errors: return             # <<<<<<<<<<<<<<
+ *         raise ValueError(errorstring)
+ * 
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___warn_errors); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = ((PySequence_Contains(__pyx_t_4, __pyx_v_error))); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":334
+ *         sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+ *         if error in self._warn_errors: return
+ *         raise ValueError(errorstring)             # <<<<<<<<<<<<<<
+ * 
+ *     def parse_format(self,line,format,filter=False):
+ */
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_v_errorstring);
+  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_errorstring);
+  __Pyx_GIVEREF(__pyx_v_errorstring);
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_Raise(__pyx_t_3, 0, 0);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.error");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_errorlabel);
+  __Pyx_DECREF(__pyx_v_errorstring);
+  __Pyx_DECREF(__pyx_v_errwarn);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":336
+ *         raise ValueError(errorstring)
+ * 
+ *     def parse_format(self,line,format,filter=False):             # <<<<<<<<<<<<<<
+ *         if self._version == 40:
+ *             if not format.startswith('<'):
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse_format = {__Pyx_NAMESTR("parse_format"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse_format, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_format = 0;
+  PyObject *__pyx_v_filter = 0;
+  PyObject *__pyx_v_data;
+  PyObject *__pyx_v_idx;
+  PyObject *__pyx_v_elts;
+  PyObject *__pyx_v_first;
+  PyObject *__pyx_v_rest;
+  PyObject *__pyx_v_n;
+  PyObject *__pyx_v_t;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  Py_ssize_t __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  PyObject *__pyx_t_12 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,&__pyx_n_s__format,&__pyx_n_s__filter,0};
+  __Pyx_RefNannySetupContext("parse_format");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[4] = {0,0,0,0};
+    values[3] = __pyx_k_15;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_format", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_format", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filter);
+        if (value) { values[3] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse_format") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+    __pyx_v_format = values[2];
+    __pyx_v_filter = values[3];
+  } else {
+    __pyx_v_filter = __pyx_k_15;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4:
+      __pyx_v_filter = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3:
+      __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 2);
+      __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse_format", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse_format");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __Pyx_INCREF(__pyx_v_format);
+  __pyx_v_data = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_idx = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_elts = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_first = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_rest = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":337
+ * 
+ *     def parse_format(self,line,format,filter=False):
+ *         if self._version == 40:             # <<<<<<<<<<<<<<
+ *             if not format.startswith('<'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); 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_RichCompare(__pyx_t_1, __pyx_int_40, Py_EQ); 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_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":338
+ *     def parse_format(self,line,format,filter=False):
+ *         if self._version == 40:
+ *             if not format.startswith('<'):             # <<<<<<<<<<<<<<
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format = "<"+format
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_format, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __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 = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_16));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __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_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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_5 = (!__pyx_t_3);
+    if (__pyx_t_5) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":339
+ *         if self._version == 40:
+ *             if not format.startswith('<'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)             # <<<<<<<<<<<<<<
+ *                 format = "<"+format
+ *             if not format.endswith('>'):
+ */
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); 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);
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_17); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      __pyx_t_1 = 0;
+      __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":340
+ *             if not format.startswith('<'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format = "<"+format             # <<<<<<<<<<<<<<
+ *             if not format.endswith('>'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ */
+      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_16), __pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_v_format);
+      __pyx_v_format = __pyx_t_1;
+      __pyx_t_1 = 0;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":341
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format = "<"+format
+ *             if not format.endswith('>'):             # <<<<<<<<<<<<<<
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format += ">"
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_format, __pyx_n_s__endswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_18));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); 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);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 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;
+    __pyx_t_3 = (!__pyx_t_5);
+    if (__pyx_t_3) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":342
+ *                 format = "<"+format
+ *             if not format.endswith('>'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)             # <<<<<<<<<<<<<<
+ *                 format += ">"
+ *             format = format[1:-1]
+ */
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); 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);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __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 = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":343
+ *             if not format.endswith('>'):
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format += ">"             # <<<<<<<<<<<<<<
+ *             format = format[1:-1]
+ *         data = {'id':None,'number':None,'type':None,'descr':None}
+ */
+      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_format, ((PyObject *)__pyx_kp_s_18)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_v_format);
+      __pyx_v_format = __pyx_t_2;
+      __pyx_t_2 = 0;
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":344
+ *                 self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+ *                 format += ">"
+ *             format = format[1:-1]             # <<<<<<<<<<<<<<
+ *         data = {'id':None,'number':None,'type':None,'descr':None}
+ *         idx = 0
+ */
+    __pyx_t_2 = PySequence_GetSlice(__pyx_v_format, 1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = __pyx_t_2;
+    __pyx_t_2 = 0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":345
+ *                 format += ">"
+ *             format = format[1:-1]
+ *         data = {'id':None,'number':None,'type':None,'descr':None}             # <<<<<<<<<<<<<<
+ *         idx = 0
+ *         while len(format.strip())>0:
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__id), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__number), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__type), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__descr), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_v_data));
+  __pyx_v_data = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":346
+ *             format = format[1:-1]
+ *         data = {'id':None,'number':None,'type':None,'descr':None}
+ *         idx = 0             # <<<<<<<<<<<<<<
+ *         while len(format.strip())>0:
+ *             elts = format.strip().split(',')
+ */
+  __Pyx_INCREF(__pyx_int_0);
+  __Pyx_DECREF(__pyx_v_idx);
+  __pyx_v_idx = __pyx_int_0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":347
+ *         data = {'id':None,'number':None,'type':None,'descr':None}
+ *         idx = 0
+ *         while len(format.strip())>0:             # <<<<<<<<<<<<<<
+ *             elts = format.strip().split(',')
+ *             first, rest = elts[0], ','.join(elts[1:])
+ */
+  while (1) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_format, __pyx_n_s__strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __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 = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = (__pyx_t_6 > 0);
+    if (!__pyx_t_3) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":348
+ *         idx = 0
+ *         while len(format.strip())>0:
+ *             elts = format.strip().split(',')             # <<<<<<<<<<<<<<
+ *             first, rest = elts[0], ','.join(elts[1:])
+ *             if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_format, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __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 = 348; __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__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __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 = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_v_elts);
+    __pyx_v_elts = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":349
+ *         while len(format.strip())>0:
+ *             elts = format.strip().split(',')
+ *             first, rest = elts[0], ','.join(elts[1:])             # <<<<<<<<<<<<<<
+ *             if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+ *                 if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+ */
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PySequence_GetSlice(__pyx_v_elts, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __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 = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __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_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_v_first);
+    __pyx_v_first = __pyx_t_4;
+    __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_v_rest);
+    __pyx_v_rest = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":350
+ *             elts = format.strip().split(',')
+ *             first, rest = elts[0], ','.join(elts[1:])
+ *             if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):             # <<<<<<<<<<<<<<
+ *                 if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+ *                 if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__find); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __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 = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_8));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+    __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    if (!__pyx_t_3) {
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__find); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_19));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
+      __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_5) {
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__find); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_8));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+        __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_1 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__find); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __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 = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
+        PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_19));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
+        __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __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_7); __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_GT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_9 = __pyx_t_8;
+      } else {
+        __pyx_t_9 = __pyx_t_5;
+      }
+      __pyx_t_5 = __pyx_t_9;
+    } else {
+      __pyx_t_5 = __pyx_t_3;
+    }
+    if (__pyx_t_5) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":351
+ *             first, rest = elts[0], ','.join(elts[1:])
+ *             if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+ *                 if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)             # <<<<<<<<<<<<<<
+ *                 if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *                 first = ["ID=","Number=","Type=","Description="][idx] + first
+ */
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, __pyx_int_40, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (__pyx_t_5) {
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_20); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        goto __pyx_L12;
+      }
+      __pyx_L12:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":352
+ *             if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+ *                 if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+ *                 if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *                 first = ["ID=","Number=","Type=","Description="][idx] + first
+ *             if first.startswith('ID='):            data['id'] = first.split('=')[1]
+ */
+      __pyx_t_7 = PyObject_RichCompare(__pyx_v_idx, __pyx_int_4, Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_5) {
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        goto __pyx_L13;
+      }
+      __pyx_L13:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":353
+ *                 if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+ *                 if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *                 first = ["ID=","Number=","Type=","Description="][idx] + first             # <<<<<<<<<<<<<<
+ *             if first.startswith('ID='):            data['id'] = first.split('=')[1]
+ *             elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+ */
+      __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
+      PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_22));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
+      PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_23));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
+      PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_kp_s_24));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
+      PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_kp_s_25));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
+      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_t_4), __pyx_v_idx); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+      __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_v_first); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_v_first);
+      __pyx_v_first = __pyx_t_4;
+      __pyx_t_4 = 0;
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":354
+ *                 if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *                 first = ["ID=","Number=","Type=","Description="][idx] + first
+ *             if first.startswith('ID='):            data['id'] = first.split('=')[1]             # <<<<<<<<<<<<<<
+ *             elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+ *             elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__startswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_22));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
+    __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    if (__pyx_t_5) {
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __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 = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__id), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L14;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":355
+ *                 first = ["ID=","Number=","Type=","Description="][idx] + first
+ *             if first.startswith('ID='):            data['id'] = first.split('=')[1]
+ *             elif first.startswith('Number='):      data['number'] = first.split('=')[1]             # <<<<<<<<<<<<<<
+ *             elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+ *             elif first.startswith('Description='):
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_23));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+    __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    if (__pyx_t_5) {
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_t_2 = PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L14;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":356
+ *             if first.startswith('ID='):            data['id'] = first.split('=')[1]
+ *             elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+ *             elif first.startswith('Type='):        data['type'] = first.split('=')[1]             # <<<<<<<<<<<<<<
+ *             elif first.startswith('Description='):
+ *                 elts = format.split('"')
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__startswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_24));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
+    __pyx_t_7 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    if (__pyx_t_5) {
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __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 = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__type), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L14;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":357
+ *             elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+ *             elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+ *             elif first.startswith('Description='):             # <<<<<<<<<<<<<<
+ *                 elts = format.split('"')
+ *                 if len(elts)<3:
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_25));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
+    __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    if (__pyx_t_5) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":358
+ *             elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+ *             elif first.startswith('Description='):
+ *                 elts = format.split('"')             # <<<<<<<<<<<<<<
+ *                 if len(elts)<3:
+ *                     self.error(line,self.FORMAT_MISSING_QUOTES)
+ */
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_format, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
+      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_19));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
+      __pyx_t_2 = PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_elts);
+      __pyx_v_elts = __pyx_t_2;
+      __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":359
+ *             elif first.startswith('Description='):
+ *                 elts = format.split('"')
+ *                 if len(elts)<3:             # <<<<<<<<<<<<<<
+ *                     self.error(line,self.FORMAT_MISSING_QUOTES)
+ *                     elts = first.split('=') + [rest]
+ */
+      __pyx_t_6 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = (__pyx_t_6 < 3);
+      if (__pyx_t_5) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":360
+ *                 elts = format.split('"')
+ *                 if len(elts)<3:
+ *                     self.error(line,self.FORMAT_MISSING_QUOTES)             # <<<<<<<<<<<<<<
+ *                     elts = first.split('=') + [rest]
+ *                 data['descr'] = elts[1]
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_26); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __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_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":361
+ *                 if len(elts)<3:
+ *                     self.error(line,self.FORMAT_MISSING_QUOTES)
+ *                     elts = first.split('=') + [rest]             # <<<<<<<<<<<<<<
+ *                 data['descr'] = elts[1]
+ *                 rest = '"'.join(elts[2:])
+ */
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_first, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+        PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_8));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+        __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        __Pyx_INCREF(__pyx_v_rest);
+        PyList_SET_ITEM(__pyx_t_7, 0, __pyx_v_rest);
+        __Pyx_GIVEREF(__pyx_v_rest);
+        __pyx_t_4 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_v_elts);
+        __pyx_v_elts = __pyx_t_4;
+        __pyx_t_4 = 0;
+        goto __pyx_L15;
+      }
+      __pyx_L15:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":362
+ *                     self.error(line,self.FORMAT_MISSING_QUOTES)
+ *                     elts = first.split('=') + [rest]
+ *                 data['descr'] = elts[1]             # <<<<<<<<<<<<<<
+ *                 rest = '"'.join(elts[2:])
+ *                 if rest.startswith(','): rest = rest[1:]
+ */
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_elts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__descr), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":363
+ *                     elts = first.split('=') + [rest]
+ *                 data['descr'] = elts[1]
+ *                 rest = '"'.join(elts[2:])             # <<<<<<<<<<<<<<
+ *                 if rest.startswith(','): rest = rest[1:]
+ *             else:
+ */
+      __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_19), __pyx_n_s__join); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_7 = PySequence_GetSlice(__pyx_v_elts, 2, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __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 = 363; __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(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_v_rest);
+      __pyx_v_rest = __pyx_t_7;
+      __pyx_t_7 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":364
+ *                 data['descr'] = elts[1]
+ *                 rest = '"'.join(elts[2:])
+ *                 if rest.startswith(','): rest = rest[1:]             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_rest, __pyx_n_s__startswith); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __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 = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+      __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (__pyx_t_5) {
+        __pyx_t_4 = PySequence_GetSlice(__pyx_v_rest, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_v_rest);
+        __pyx_v_rest = __pyx_t_4;
+        __pyx_t_4 = 0;
+        goto __pyx_L16;
+      }
+      __pyx_L16:;
+      goto __pyx_L14;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":366
+ *                 if rest.startswith(','): rest = rest[1:]
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *             format = rest
+ *             idx += 1
+ */
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    }
+    __pyx_L14:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":367
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *             format = rest             # <<<<<<<<<<<<<<
+ *             idx += 1
+ *             if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+ */
+    __Pyx_INCREF(__pyx_v_rest);
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = __pyx_v_rest;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":368
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *             format = rest
+ *             idx += 1             # <<<<<<<<<<<<<<
+ *             if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+ *         if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_v_idx);
+    __pyx_v_idx = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":369
+ *             format = rest
+ *             idx += 1
+ *             if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings             # <<<<<<<<<<<<<<
+ *         if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         if not data['descr']:
+ */
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_filter); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_5) {
+      __pyx_t_2 = PyObject_RichCompare(__pyx_v_idx, __pyx_int_1, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_9 = __pyx_t_3;
+    } else {
+      __pyx_t_9 = __pyx_t_5;
+    }
+    if (__pyx_t_9) {
+      __Pyx_INCREF(__pyx_int_3);
+      __Pyx_DECREF(__pyx_v_idx);
+      __pyx_v_idx = __pyx_int_3;
+      goto __pyx_L17;
+    }
+    __pyx_L17:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":370
+ *             idx += 1
+ *             if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+ *         if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *         if not data['descr']:
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+  __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__id)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_5 = (!__pyx_t_9);
+  if (__pyx_t_5) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_7);
+    __pyx_t_7 = 0;
+    __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    goto __pyx_L18;
+  }
+  __pyx_L18:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":371
+ *             if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+ *         if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         if not data['descr']:             # <<<<<<<<<<<<<<
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *             data['descr'] = '<none>'
+ */
+  __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__descr)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_9 = (!__pyx_t_5);
+  if (__pyx_t_9) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":372
+ *         if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         if not data['descr']:
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *             data['descr'] = '<none>'
+ *         if not data['type'] and not data['number']:
+ */
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":373
+ *         if not data['descr']:
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *             data['descr'] = '<none>'             # <<<<<<<<<<<<<<
+ *         if not data['type'] and not data['number']:
+ *             # fine, ##filter format
+ */
+    if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__descr), ((PyObject *)__pyx_kp_s_27)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L19;
+  }
+  __pyx_L19:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":374
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *             data['descr'] = '<none>'
+ *         if not data['type'] and not data['number']:             # <<<<<<<<<<<<<<
+ *             # fine, ##filter format
+ *             return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')
+ */
+  __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_5 = (!__pyx_t_9);
+  if (__pyx_t_5) {
+    __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_3 = (!__pyx_t_9);
+    __pyx_t_9 = __pyx_t_3;
+  } else {
+    __pyx_t_9 = __pyx_t_5;
+  }
+  if (__pyx_t_9) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":376
+ *         if not data['type'] and not data['number']:
+ *             # fine, ##filter format
+ *             return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')             # <<<<<<<<<<<<<<
+ *         if not data['type'] in ["Integer","Float","Character","String","Flag"]:
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__id)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__descr)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = PyTuple_New(6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __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);
+    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_7);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Flag));
+    PyTuple_SET_ITEM(__pyx_t_10, 3, ((PyObject *)__pyx_n_s__Flag));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Flag));
+    PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_10, 5, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_2 = 0;
+    __pyx_t_7 = 0;
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L20;
+  }
+  __pyx_L20:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":377
+ *             # fine, ##filter format
+ *             return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')
+ *         if not data['type'] in ["Integer","Float","Character","String","Flag"]:             # <<<<<<<<<<<<<<
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         # I would like a missing-value field, but it isn't there
+ */
+  __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Integer), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_5 = __pyx_t_9;
+  if (!__pyx_t_5) {
+    __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Float), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_3 = __pyx_t_9;
+    __pyx_t_9 = __pyx_t_3;
+  } else {
+    __pyx_t_9 = __pyx_t_5;
+  }
+  if (!__pyx_t_9) {
+    __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Character), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_3 = __pyx_t_5;
+    __pyx_t_5 = __pyx_t_3;
+  } else {
+    __pyx_t_5 = __pyx_t_9;
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__String), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_3 = __pyx_t_9;
+    __pyx_t_9 = __pyx_t_3;
+  } else {
+    __pyx_t_9 = __pyx_t_5;
+  }
+  if (!__pyx_t_9) {
+    __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Flag), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_3 = __pyx_t_5;
+    __pyx_t_5 = __pyx_t_3;
+  } else {
+    __pyx_t_5 = __pyx_t_9;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_9 = (!__pyx_t_5);
+  if (__pyx_t_9) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":378
+ *             return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')
+ *         if not data['type'] in ["Integer","Float","Character","String","Flag"]:
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *         # I would like a missing-value field, but it isn't there
+ *         if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_10);
+    __Pyx_GIVEREF(__pyx_t_10);
+    __pyx_t_10 = 0;
+    __pyx_t_10 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    goto __pyx_L21;
+  }
+  __pyx_L21:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":380
+ *             self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         # I would like a missing-value field, but it isn't there
+ *         if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value             # <<<<<<<<<<<<<<
+ *         else:                                   data['missing'] = '.'
+ *         if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+  __pyx_t_10 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, ((PyObject *)__pyx_n_s__Integer), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_5 = __pyx_t_9;
+  if (!__pyx_t_5) {
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, ((PyObject *)__pyx_n_s__Float), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_3 = __pyx_t_9;
+    __pyx_t_9 = __pyx_t_3;
+  } else {
+    __pyx_t_9 = __pyx_t_5;
+  }
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_5 = __pyx_t_9;
+  if (__pyx_t_5) {
+    if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__missing), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L22;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":381
+ *         # I would like a missing-value field, but it isn't there
+ *         if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value
+ *         else:                                   data['missing'] = '.'             # <<<<<<<<<<<<<<
+ *         if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         try:
+ */
+    if (PyDict_SetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__missing), ((PyObject *)__pyx_kp_s_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_L22:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":382
+ *         if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value
+ *         else:                                   data['missing'] = '.'
+ *         if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *         try:
+ *             n = int(data['number'])
+ */
+  __pyx_t_10 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_9 = (!__pyx_t_5);
+  if (__pyx_t_9) {
+    __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_10, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    goto __pyx_L23;
+  }
+  __pyx_L23:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":383
+ *         else:                                   data['missing'] = '.'
+ *         if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         try:             # <<<<<<<<<<<<<<
+ *             n = int(data['number'])
+ *             t = self.NT_NUMBER
+ */
+  {
+    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+    __Pyx_XGOTREF(__pyx_save_exc_type);
+    __Pyx_XGOTREF(__pyx_save_exc_value);
+    __Pyx_XGOTREF(__pyx_save_exc_tb);
+    /*try:*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":384
+ *         if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         try:
+ *             n = int(data['number'])             # <<<<<<<<<<<<<<
+ *             t = self.NT_NUMBER
+ *         except ValueError:
+ */
+      __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_n);
+      __pyx_v_n = __pyx_t_4;
+      __pyx_t_4 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":385
+ *         try:
+ *             n = int(data['number'])
+ *             t = self.NT_NUMBER             # <<<<<<<<<<<<<<
+ *         except ValueError:
+ *             n = -1
+ */
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_v_t);
+      __pyx_v_t = __pyx_t_4;
+      __pyx_t_4 = 0;
+    }
+    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+    goto __pyx_L31_try_end;
+    __pyx_L24_error:;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":386
+ *             n = int(data['number'])
+ *             t = self.NT_NUMBER
+ *         except ValueError:             # <<<<<<<<<<<<<<
+ *             n = -1
+ *             if data['number'] == '.':                   t = self.NT_UNKNOWN
+ */
+    __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+    if (__pyx_t_11) {
+      __Pyx_AddTraceback("cvcf.VCF.parse_format");
+      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_10);
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":387
+ *             t = self.NT_NUMBER
+ *         except ValueError:
+ *             n = -1             # <<<<<<<<<<<<<<
+ *             if data['number'] == '.':                   t = self.NT_UNKNOWN
+ *             elif data['number'] == '#alleles':          t = self.NT_ALLELES
+ */
+      __Pyx_INCREF(__pyx_int_neg_1);
+      __Pyx_DECREF(__pyx_v_n);
+      __pyx_v_n = __pyx_int_neg_1;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":388
+ *         except ValueError:
+ *             n = -1
+ *             if data['number'] == '.':                   t = self.NT_UNKNOWN             # <<<<<<<<<<<<<<
+ *             elif data['number'] == '#alleles':          t = self.NT_ALLELES
+ *             elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+ */
+      __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (__pyx_t_9) {
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_t);
+        __pyx_v_t = __pyx_t_2;
+        __pyx_t_2 = 0;
+        goto __pyx_L34;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":389
+ *             n = -1
+ *             if data['number'] == '.':                   t = self.NT_UNKNOWN
+ *             elif data['number'] == '#alleles':          t = self.NT_ALLELES             # <<<<<<<<<<<<<<
+ *             elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+ *             elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES
+ */
+      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_kp_s_28), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_9) {
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_ALLELES); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_v_t);
+        __pyx_v_t = __pyx_t_7;
+        __pyx_t_7 = 0;
+        goto __pyx_L34;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":390
+ *             if data['number'] == '.':                   t = self.NT_UNKNOWN
+ *             elif data['number'] == '#alleles':          t = self.NT_ALLELES
+ *             elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES             # <<<<<<<<<<<<<<
+ *             elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES
+ *             elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES
+ */
+      __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_kp_s_29), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (__pyx_t_9) {
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NR_ALLELES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_t);
+        __pyx_v_t = __pyx_t_2;
+        __pyx_t_2 = 0;
+        goto __pyx_L34;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":391
+ *             elif data['number'] == '#alleles':          t = self.NT_ALLELES
+ *             elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+ *             elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES             # <<<<<<<<<<<<<<
+ *             elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES
+ *             else:
+ */
+      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_kp_s_30), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_9) {
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_GENOTYPES); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_v_t);
+        __pyx_v_t = __pyx_t_7;
+        __pyx_t_7 = 0;
+        goto __pyx_L34;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":392
+ *             elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+ *             elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES
+ *             elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ */
+      __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__number)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_kp_s_31), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (__pyx_t_9) {
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_PHASED_GENOTYPES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_t);
+        __pyx_v_t = __pyx_t_2;
+        __pyx_t_2 = 0;
+        goto __pyx_L34;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":394
+ *             elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *         return FORMAT(data['id'],t,n,data['type'],data['descr'],data['missing'])
+ * 
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_21); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+      __pyx_L34:;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      goto __pyx_L25_exception_handled;
+    }
+    __pyx_L26_except_error:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L1_error;
+    __pyx_L25_exception_handled:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    __pyx_L31_try_end:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":395
+ *             else:
+ *                 self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+ *         return FORMAT(data['id'],t,n,data['type'],data['descr'],data['missing'])             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__id)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__descr)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_12 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_data), ((PyObject *)__pyx_n_s__missing)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_t);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_t);
+  __Pyx_GIVEREF(__pyx_v_t);
+  __Pyx_INCREF(__pyx_v_n);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_n);
+  __Pyx_GIVEREF(__pyx_v_n);
+  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  __pyx_t_1 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_12 = 0;
+  __pyx_t_12 = PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_12;
+  __pyx_t_12 = 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_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_AddTraceback("cvcf.VCF.parse_format");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_data);
+  __Pyx_DECREF(__pyx_v_idx);
+  __Pyx_DECREF(__pyx_v_elts);
+  __Pyx_DECREF(__pyx_v_first);
+  __Pyx_DECREF(__pyx_v_rest);
+  __Pyx_DECREF(__pyx_v_n);
+  __Pyx_DECREF(__pyx_v_t);
+  __Pyx_DECREF(__pyx_v_format);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":398
+ * 
+ * 
+ *     def format_format( self, fmt, filter=False ):             # <<<<<<<<<<<<<<
+ *         values = [('ID',fmt.id)]
+ *         if fmt.number != None and not filter:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_format_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_format_format = {__Pyx_NAMESTR("format_format"), (PyCFunction)__pyx_pf_4cvcf_3VCF_format_format, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_format_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_fmt = 0;
+  PyObject *__pyx_v_filter = 0;
+  PyObject *__pyx_v_values;
+  PyObject *__pyx_v_nmb;
+  PyObject *__pyx_v_format;
+  PyObject *__pyx_v_k;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  Py_ssize_t __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fmt,&__pyx_n_s__filter,0};
+  __Pyx_RefNannySetupContext("format_format");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    values[2] = __pyx_k_32;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fmt);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("format_format", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filter);
+        if (value) { values[2] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "format_format") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_fmt = values[1];
+    __pyx_v_filter = values[2];
+  } else {
+    __pyx_v_filter = __pyx_k_32;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3:
+      __pyx_v_filter = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2:
+      __pyx_v_fmt = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("format_format", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.format_format");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_values = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_nmb = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_format = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":399
+ * 
+ *     def format_format( self, fmt, filter=False ):
+ *         values = [('ID',fmt.id)]             # <<<<<<<<<<<<<<
+ *         if fmt.number != None and not filter:
+ *             if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__ID));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_v_values));
+  __pyx_v_values = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":400
+ *     def format_format( self, fmt, filter=False ):
+ *         values = [('ID',fmt.id)]
+ *         if fmt.number != None and not filter:             # <<<<<<<<<<<<<<
+ *             if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+ *             elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__number); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __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 = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_3) {
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_filter); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = (!__pyx_t_4);
+    __pyx_t_4 = __pyx_t_5;
+  } else {
+    __pyx_t_4 = __pyx_t_3;
+  }
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":401
+ *         values = [('ID',fmt.id)]
+ *         if fmt.number != None and not filter:
+ *             if fmt.numbertype == self.NT_UNKNOWN: nmb = "."             # <<<<<<<<<<<<<<
+ *             elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+ *             elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); 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_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __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_1); __pyx_t_1 = 0;
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__pyx_t_4) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+      __Pyx_DECREF(__pyx_v_nmb);
+      __pyx_v_nmb = ((PyObject *)__pyx_kp_s_6);
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":402
+ *         if fmt.number != None and not filter:
+ *             if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+ *             elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)             # <<<<<<<<<<<<<<
+ *             elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+ *             elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+ */
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __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 = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_4) {
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__number); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __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 = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __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_nmb);
+      __pyx_v_nmb = __pyx_t_2;
+      __pyx_t_2 = 0;
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":403
+ *             if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+ *             elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+ *             elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"             # <<<<<<<<<<<<<<
+ *             elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+ *             elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_ALLELES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __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_1); __pyx_t_1 = 0;
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__pyx_t_4) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
+      __Pyx_DECREF(__pyx_v_nmb);
+      __pyx_v_nmb = ((PyObject *)__pyx_kp_s_28);
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":404
+ *             elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+ *             elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+ *             elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"             # <<<<<<<<<<<<<<
+ *             elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"
+ *             elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"
+ */
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NR_ALLELES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __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 = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_4) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_29));
+      __Pyx_DECREF(__pyx_v_nmb);
+      __pyx_v_nmb = ((PyObject *)__pyx_kp_s_29);
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":405
+ *             elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+ *             elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+ *             elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"             # <<<<<<<<<<<<<<
+ *             elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"
+ *             else:
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); 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_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_GENOTYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __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_1); __pyx_t_1 = 0;
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__pyx_t_4) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
+      __Pyx_DECREF(__pyx_v_nmb);
+      __pyx_v_nmb = ((PyObject *)__pyx_kp_s_30);
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":406
+ *             elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+ *             elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"
+ *             elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"             # <<<<<<<<<<<<<<
+ *             else:
+ *                 raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)
+ */
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_PHASED_GENOTYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __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 = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_4) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
+      __Pyx_DECREF(__pyx_v_nmb);
+      __pyx_v_nmb = ((PyObject *)__pyx_kp_s_31);
+      goto __pyx_L7;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":408
+ *             elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"
+ *             else:
+ *                 raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)             # <<<<<<<<<<<<<<
+ *             values.append( ('Number',nmb) )
+ *             values.append( ('Type', fmt.type) )
+ */
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__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 = 408; __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, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __pyx_L7:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":409
+ *             else:
+ *                 raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)
+ *             values.append( ('Number',nmb) )             # <<<<<<<<<<<<<<
+ *             values.append( ('Type', fmt.type) )
+ *         values.append( ('Description', '"' + fmt.description + '"') )
+ */
+    if (unlikely(__pyx_v_values == Py_None)) {
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __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 = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Number));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Number));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Number));
+    __Pyx_INCREF(__pyx_v_nmb);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_nmb);
+    __Pyx_GIVEREF(__pyx_v_nmb);
+    __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_values), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":410
+ *                 raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)
+ *             values.append( ('Number',nmb) )
+ *             values.append( ('Type', fmt.type) )             # <<<<<<<<<<<<<<
+ *         values.append( ('Description', '"' + fmt.description + '"') )
+ *         if self._version == 33:
+ */
+    if (unlikely(__pyx_v_values == Py_None)) {
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    }
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Type));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__Type));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Type));
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_values), __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":411
+ *             values.append( ('Number',nmb) )
+ *             values.append( ('Type', fmt.type) )
+ *         values.append( ('Description', '"' + fmt.description + '"') )             # <<<<<<<<<<<<<<
+ *         if self._version == 33:
+ *             format = ",".join([v for k,v in values])
+ */
+  if (unlikely(__pyx_v_values == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__description); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_19), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_kp_s_19)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __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(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Description));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Description));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Description));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_values), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":412
+ *             values.append( ('Type', fmt.type) )
+ *         values.append( ('Description', '"' + fmt.description + '"') )
+ *         if self._version == 33:             # <<<<<<<<<<<<<<
+ *             format = ",".join([v for k,v in values])
+ *         else:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __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 = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":413
+ *         values.append( ('Description', '"' + fmt.description + '"') )
+ *         if self._version == 33:
+ *             format = ",".join([v for k,v in values])             # <<<<<<<<<<<<<<
+ *         else:
+ *             format = "<" + (",".join( ["%s=%s" % (k,v) for (k,v) in values] )) + ">"
+ */
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    if (likely(((PyObject *)__pyx_v_values) != Py_None)) {
+      __pyx_t_8 = 0; __pyx_t_6 = ((PyObject *)__pyx_v_values); __Pyx_INCREF(__pyx_t_6);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
+      __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++;
+      if (PyTuple_CheckExact(__pyx_t_9) && likely(PyTuple_GET_SIZE(__pyx_t_9) == 2)) {
+        PyObject* tuple = __pyx_t_9;
+        __pyx_t_10 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_10);
+        __pyx_t_11 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_k);
+        __pyx_v_k = __pyx_t_10;
+        __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_11;
+        __pyx_t_11 = 0;
+      } else {
+        __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_11 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        if (__Pyx_EndUnpack(__pyx_t_12, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_v_k);
+        __pyx_v_k = __pyx_t_10;
+        __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_11;
+        __pyx_t_11 = 0;
+      }
+      if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_v_v))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_DECREF(__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 = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_INCREF(((PyObject *)__pyx_t_1));
+    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __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_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L8;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":415
+ *             format = ",".join([v for k,v in values])
+ *         else:
+ *             format = "<" + (",".join( ["%s=%s" % (k,v) for (k,v) in values] )) + ">"             # <<<<<<<<<<<<<<
+ *         return format
+ * 
+ */
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    if (likely(((PyObject *)__pyx_v_values) != Py_None)) {
+      __pyx_t_8 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_values); __Pyx_INCREF(__pyx_t_2);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++;
+      if (PyTuple_CheckExact(__pyx_t_9) && likely(PyTuple_GET_SIZE(__pyx_t_9) == 2)) {
+        PyObject* tuple = __pyx_t_9;
+        __pyx_t_11 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_11);
+        __pyx_t_10 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_k);
+        __pyx_v_k = __pyx_t_11;
+        __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_10;
+        __pyx_t_10 = 0;
+      } else {
+        __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_11 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        if (__Pyx_EndUnpack(__pyx_t_12, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_v_k);
+        __pyx_v_k = __pyx_t_11;
+        __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_10;
+        __pyx_t_10 = 0;
+      }
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_k);
+      __Pyx_GIVEREF(__pyx_v_k);
+      __Pyx_INCREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_v);
+      __Pyx_GIVEREF(__pyx_v_v);
+      __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      if (unlikely(PyList_Append(__pyx_t_6, (PyObject*)__pyx_t_10))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+    }
+    __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 = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_t_6));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_kp_s_16), __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_kp_s_18)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = __pyx_t_6;
+    __pyx_t_6 = 0;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":416
+ *         else:
+ *             format = "<" + (",".join( ["%s=%s" % (k,v) for (k,v) in values] )) + ">"
+ *         return format             # <<<<<<<<<<<<<<
+ * 
+ *     def get_expected(self, format, formatdict, alt):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_format);
+  __pyx_r = __pyx_v_format;
+  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_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_AddTraceback("cvcf.VCF.format_format");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_values);
+  __Pyx_DECREF(__pyx_v_nmb);
+  __Pyx_DECREF(__pyx_v_format);
+  __Pyx_DECREF(__pyx_v_k);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":418
+ *         return format
+ * 
+ *     def get_expected(self, format, formatdict, alt):             # <<<<<<<<<<<<<<
+ *         fmt = formatdict[format]
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_get_expected(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_get_expected = {__Pyx_NAMESTR("get_expected"), (PyCFunction)__pyx_pf_4cvcf_3VCF_get_expected, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_get_expected(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_format = 0;
+  PyObject *__pyx_v_formatdict = 0;
+  PyObject *__pyx_v_alt = 0;
+  PyObject *__pyx_v_fmt;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  Py_ssize_t __pyx_t_6;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__format,&__pyx_n_s__formatdict,&__pyx_n_s__alt,0};
+  __Pyx_RefNannySetupContext("get_expected");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[4] = {0,0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_expected", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__formatdict);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_expected", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alt);
+      if (likely(values[3])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("get_expected", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_expected") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_format = values[1];
+    __pyx_v_formatdict = values[2];
+    __pyx_v_alt = values[3];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_formatdict = PyTuple_GET_ITEM(__pyx_args, 2);
+    __pyx_v_alt = PyTuple_GET_ITEM(__pyx_args, 3);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("get_expected", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.get_expected");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_fmt = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":419
+ * 
+ *     def get_expected(self, format, formatdict, alt):
+ *         fmt = formatdict[format]             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1
+ *         if fmt.numbertype == self.NT_NUMBER: return fmt.number
+ */
+  __pyx_t_1 = PyObject_GetItem(__pyx_v_formatdict, __pyx_v_format); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_v_fmt);
+  __pyx_v_fmt = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":420
+ *     def get_expected(self, format, formatdict, alt):
+ *         fmt = formatdict[format]
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_NUMBER: return fmt.number
+ *         if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __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_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 = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_int_neg_1);
+    __pyx_r = __pyx_int_neg_1;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":421
+ *         fmt = formatdict[format]
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1
+ *         if fmt.numbertype == self.NT_NUMBER: return fmt.number             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+ *         if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __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_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 = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__number); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":422
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1
+ *         if fmt.numbertype == self.NT_NUMBER: return fmt.number
+ *         if fmt.numbertype == self.NT_ALLELES: return len(alt)+1             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+ *         if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_ALLELES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __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_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 = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_5 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromSsize_t((__pyx_t_5 + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":423
+ *         if fmt.numbertype == self.NT_NUMBER: return fmt.number
+ *         if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+ *         if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+ *         if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NR_ALLELES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __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_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 = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_5 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":424
+ *         if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+ *         if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+ *         if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2             # <<<<<<<<<<<<<<
+ *         if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)
+ *         return 0
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_GENOTYPES); 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);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); 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(__pyx_t_1); __pyx_t_1 = 0;
+  __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 = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_5 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromSsize_t(__Pyx_div_Py_ssize_t(((__pyx_t_5 + 1) * (__pyx_t_6 + 2)), 2)); 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_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+    goto __pyx_L10;
+  }
+  __pyx_L10:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":425
+ *         if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+ *         if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+ *         if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)             # <<<<<<<<<<<<<<
+ *         return 0
+ * 
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_fmt, __pyx_n_s__numbertype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_PHASED_GENOTYPES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __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_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 = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_4) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_6 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Length(__pyx_v_alt); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromSsize_t(((__pyx_t_6 + 1) * (__pyx_t_5 + 1))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L11;
+  }
+  __pyx_L11:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":426
+ *         if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+ *         if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)
+ *         return 0             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_int_0);
+  __pyx_r = __pyx_int_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_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("cvcf.VCF.get_expected");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_fmt);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":429
+ * 
+ * 
+ *     def _add_definition(self, formatdict, key, data, line ):             # <<<<<<<<<<<<<<
+ *         if key in formatdict: return
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF__add_definition(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF__add_definition = {__Pyx_NAMESTR("_add_definition"), (PyCFunction)__pyx_pf_4cvcf_3VCF__add_definition, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF__add_definition(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_formatdict = 0;
+  PyObject *__pyx_v_key = 0;
+  PyObject *__pyx_v_data = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__formatdict,&__pyx_n_s__key,&__pyx_n_s__data,&__pyx_n_s__line,0};
+  __Pyx_RefNannySetupContext("_add_definition");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[5] = {0,0,0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__formatdict);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_add_definition", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_add_definition", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
+      if (likely(values[3])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_add_definition", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  4:
+      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[4])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_add_definition", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_add_definition") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_formatdict = values[1];
+    __pyx_v_key = values[2];
+    __pyx_v_data = values[3];
+    __pyx_v_line = values[4];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_formatdict = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 2);
+    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 3);
+    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 4);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_add_definition", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF._add_definition");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __Pyx_INCREF(__pyx_v_data);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":430
+ * 
+ *     def _add_definition(self, formatdict, key, data, line ):
+ *         if key in formatdict: return             # <<<<<<<<<<<<<<
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)
+ *         if data == None:
+ */
+  __pyx_t_1 = ((PySequence_Contains(__pyx_v_formatdict, __pyx_v_key))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":431
+ *     def _add_definition(self, formatdict, key, data, line ):
+ *         if key in formatdict: return
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)             # <<<<<<<<<<<<<<
+ *         if data == None:
+ *             formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ERROR_UNKNOWN_KEY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_v_line);
+  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_line);
+  __Pyx_GIVEREF(__pyx_v_line);
+  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_v_key);
+  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_key);
+  __Pyx_GIVEREF(__pyx_v_key);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __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_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":432
+ *         if key in formatdict: return
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)
+ *         if data == None:             # <<<<<<<<<<<<<<
+ *             formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+ *             return
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_data, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":433
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)
+ *         if data == None:
+ *             formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")             # <<<<<<<<<<<<<<
+ *             return
+ *         if data == []: data = [""]             # unsure what type -- say string
+ */
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __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);
+    __Pyx_GIVEREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Flag));
+    PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__Flag));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Flag));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+    PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_kp_s_35));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_2, 5, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (PyObject_SetItem(__pyx_v_formatdict, __pyx_v_key, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":434
+ *         if data == None:
+ *             formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+ *             return             # <<<<<<<<<<<<<<
+ *         if data == []: data = [""]             # unsure what type -- say string
+ *         if type(data[0]) == type(0.0):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":435
+ *             formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+ *             return
+ *         if data == []: data = [""]             # unsure what type -- say string             # <<<<<<<<<<<<<<
+ *         if type(data[0]) == type(0.0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+ */
+  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_data, ((PyObject *)__pyx_t_4), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_1) {
+    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+    PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
+    __Pyx_DECREF(__pyx_v_data);
+    __pyx_v_data = ((PyObject *)__pyx_t_2);
+    __pyx_t_2 = 0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":436
+ *             return
+ *         if data == []: data = [""]             # unsure what type -- say string
+ *         if type(data[0]) == type(0.0):             # <<<<<<<<<<<<<<
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+ *             return
+ */
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_data, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_2)), ((PyObject *)Py_TYPE(__pyx_t_4)), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __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_4); __pyx_t_4 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":437
+ *         if data == []: data = [""]             # unsure what type -- say string
+ *         if type(data[0]) == type(0.0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)             # <<<<<<<<<<<<<<
+ *             return
+ *         if type(data[0]) == type(0):
+ */
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __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);
+    __Pyx_GIVEREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_int_neg_1);
+    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_neg_1);
+    __Pyx_GIVEREF(__pyx_int_neg_1);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Float));
+    PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__Float));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Float));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+    PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_kp_s_35));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+    __Pyx_INCREF(Py_None);
+    PyTuple_SET_ITEM(__pyx_t_2, 5, Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (PyObject_SetItem(__pyx_v_formatdict, __pyx_v_key, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":438
+ *         if type(data[0]) == type(0.0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+ *             return             # <<<<<<<<<<<<<<
+ *         if type(data[0]) == type(0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":439
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+ *             return
+ *         if type(data[0]) == type(0):             # <<<<<<<<<<<<<<
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+ *             return
+ */
+  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_data, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_4)), ((PyObject *)Py_TYPE(__pyx_int_0)), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":440
+ *             return
+ *         if type(data[0]) == type(0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)             # <<<<<<<<<<<<<<
+ *             return
+ *         formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"String","(Undefined tag)",".")
+ */
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
+    __Pyx_GIVEREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_INCREF(__pyx_int_neg_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_neg_1);
+    __Pyx_GIVEREF(__pyx_int_neg_1);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__Integer));
+    PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__Integer));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Integer));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+    PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_kp_s_35));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+    __Pyx_INCREF(Py_None);
+    PyTuple_SET_ITEM(__pyx_t_3, 5, Py_None);
+    __Pyx_GIVEREF(Py_None);
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __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_3); __pyx_t_3 = 0;
+    if (PyObject_SetItem(__pyx_v_formatdict, __pyx_v_key, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":441
+ *         if type(data[0]) == type(0):
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+ *             return             # <<<<<<<<<<<<<<
+ *         formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"String","(Undefined tag)",".")
+ * 
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L10;
+  }
+  __pyx_L10:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":442
+ *             formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+ *             return
+ *         formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"String","(Undefined tag)",".")             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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);
+  __Pyx_GIVEREF(__pyx_v_key);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_int_neg_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_neg_1);
+  __Pyx_GIVEREF(__pyx_int_neg_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__String));
+  PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__String));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__String));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+  PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_kp_s_35));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+  PyTuple_SET_ITEM(__pyx_t_2, 5, ((PyObject *)__pyx_kp_s_6));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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_2); __pyx_t_2 = 0;
+  if (PyObject_SetItem(__pyx_v_formatdict, __pyx_v_key, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("cvcf.VCF._add_definition");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_data);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":446
+ * 
+ *     # todo: trim trailing missing values
+ *     def format_formatdata( self, data, format, key=True, value=True, separator=":" ):             # <<<<<<<<<<<<<<
+ *         output, sdata = [], []
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_format_formatdata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_format_formatdata = {__Pyx_NAMESTR("format_formatdata"), (PyCFunction)__pyx_pf_4cvcf_3VCF_format_formatdata, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_format_formatdata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_data = 0;
+  PyObject *__pyx_v_format = 0;
+  PyObject *__pyx_v_key = 0;
+  PyObject *__pyx_v_value = 0;
+  PyObject *__pyx_v_separator = 0;
+  PyObject *__pyx_v_output;
+  PyObject *__pyx_v_sdata;
+  PyObject *__pyx_v_d;
+  PyObject *__pyx_v_k;
+  PyObject *__pyx_v_idx;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_v_last;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  Py_ssize_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  int __pyx_t_10;
+  int __pyx_t_11;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__data,&__pyx_n_s__format,&__pyx_n_s__key,&__pyx_n_s__value,&__pyx_n_s__separator,0};
+  __Pyx_RefNannySetupContext("format_formatdata");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[6] = {0,0,0,0,0,0};
+    values[3] = __pyx_k_36;
+    values[4] = __pyx_k_37;
+    values[5] = ((PyObject *)__pyx_kp_s_3);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("format_formatdata", 0, 3, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("format_formatdata", 0, 3, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
+        if (value) { values[3] = value; kw_args--; }
+      }
+      case  4:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
+        if (value) { values[4] = value; kw_args--; }
+      }
+      case  5:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__separator);
+        if (value) { values[5] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "format_formatdata") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_data = values[1];
+    __pyx_v_format = values[2];
+    __pyx_v_key = values[3];
+    __pyx_v_value = values[4];
+    __pyx_v_separator = values[5];
+  } else {
+    __pyx_v_key = __pyx_k_36;
+    __pyx_v_value = __pyx_k_37;
+    __pyx_v_separator = ((PyObject *)__pyx_kp_s_3);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  6:
+      __pyx_v_separator = PyTuple_GET_ITEM(__pyx_args, 5);
+      case  5:
+      __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4:
+      __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3:
+      __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 2);
+      __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("format_formatdata", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.format_formatdata");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __Pyx_INCREF(__pyx_v_data);
+  __pyx_v_output = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_sdata = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_d = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_idx = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_last = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":447
+ *     # todo: trim trailing missing values
+ *     def format_formatdata( self, data, format, key=True, value=True, separator=":" ):
+ *         output, sdata = [], []             # <<<<<<<<<<<<<<
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values
+ *             d = {}
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __Pyx_DECREF(((PyObject *)__pyx_v_output));
+  __pyx_v_output = __pyx_t_1;
+  __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_v_sdata));
+  __pyx_v_sdata = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":448
+ *     def format_formatdata( self, data, format, key=True, value=True, separator=":" ):
+ *         output, sdata = [], []
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values             # <<<<<<<<<<<<<<
+ *             d = {}
+ *             for k in data: d[k] = []
+ */
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(((PyObject *)__pyx_t_2))), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__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 = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":449
+ *         output, sdata = [], []
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values
+ *             d = {}             # <<<<<<<<<<<<<<
+ *             for k in data: d[k] = []
+ *             data = d
+ */
+    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(((PyObject *)__pyx_v_d));
+    __pyx_v_d = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":450
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values
+ *             d = {}
+ *             for k in data: d[k] = []             # <<<<<<<<<<<<<<
+ *             data = d
+ *         # convert missing values; and silently add definitions if required
+ */
+    if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) {
+      __pyx_t_4 = 0; __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1);
+    } else {
+      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+      } else {
+        __pyx_t_2 = PyIter_Next(__pyx_t_1);
+        if (!__pyx_t_2) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_2);
+      }
+      __Pyx_DECREF(__pyx_v_k);
+      __pyx_v_k = __pyx_t_2;
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      if (PyDict_SetItem(((PyObject *)__pyx_v_d), __pyx_v_k, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __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;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":451
+ *             d = {}
+ *             for k in data: d[k] = []
+ *             data = d             # <<<<<<<<<<<<<<
+ *         # convert missing values; and silently add definitions if required
+ *         for k in data:
+ */
+    __Pyx_INCREF(((PyObject *)__pyx_v_d));
+    __Pyx_DECREF(__pyx_v_data);
+    __pyx_v_data = ((PyObject *)__pyx_v_d);
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":453
+ *             data = d
+ *         # convert missing values; and silently add definitions if required
+ *         for k in data:             # <<<<<<<<<<<<<<
+ *             self._add_definition( format, k, data[k], "(output)" )
+ *             for idx,v in enumerate(data[k]):
+ */
+  if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) {
+    __pyx_t_4 = 0; __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_1);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_k);
+    __pyx_v_k = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":454
+ *         # convert missing values; and silently add definitions if required
+ *         for k in data:
+ *             self._add_definition( format, k, data[k], "(output)" )             # <<<<<<<<<<<<<<
+ *             for idx,v in enumerate(data[k]):
+ *                 if v == format[k].missingvalue: data[k][idx] = "."
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___add_definition); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyObject_GetItem(__pyx_v_data, __pyx_v_k); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_INCREF(__pyx_v_format);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_format);
+    __Pyx_GIVEREF(__pyx_v_format);
+    __Pyx_INCREF(__pyx_v_k);
+    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_k);
+    __Pyx_GIVEREF(__pyx_v_k);
+    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
+    PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_kp_s_38));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":455
+ *         for k in data:
+ *             self._add_definition( format, k, data[k], "(output)" )
+ *             for idx,v in enumerate(data[k]):             # <<<<<<<<<<<<<<
+ *                 if v == format[k].missingvalue: data[k][idx] = "."
+ *         # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+ */
+    __Pyx_INCREF(__pyx_int_0);
+    __pyx_t_5 = __pyx_int_0;
+    __pyx_t_6 = PyObject_GetItem(__pyx_v_data, __pyx_v_k); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
+      __pyx_t_7 = 0; __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++;
+      } else {
+        __pyx_t_6 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_6) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_6);
+      }
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_6;
+      __pyx_t_6 = 0;
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_v_idx);
+      __pyx_v_idx = __pyx_t_5;
+      __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_5);
+      __pyx_t_5 = __pyx_t_6;
+      __pyx_t_6 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":456
+ *             self._add_definition( format, k, data[k], "(output)" )
+ *             for idx,v in enumerate(data[k]):
+ *                 if v == format[k].missingvalue: data[k][idx] = "."             # <<<<<<<<<<<<<<
+ *         # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+ *         for k in data:
+ */
+      __pyx_t_6 = PyObject_GetItem(__pyx_v_format, __pyx_v_k); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_8 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__missingvalue); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_6 = PyObject_RichCompare(__pyx_v_v, __pyx_t_8, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      if (__pyx_t_3) {
+        __pyx_t_6 = PyObject_GetItem(__pyx_v_data, __pyx_v_k); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        if (PyObject_SetItem(__pyx_t_6, __pyx_v_idx, ((PyObject *)__pyx_kp_s_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        goto __pyx_L13;
+      }
+      __pyx_L13:;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":458
+ *                 if v == format[k].missingvalue: data[k][idx] = "."
+ *         # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+ *         for k in data:             # <<<<<<<<<<<<<<
+ *             if k != 'GT': sdata.append( (k,data[k]) )
+ *         sdata.sort()
+ */
+  if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) {
+    __pyx_t_4 = 0; __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++;
+    } else {
+      __pyx_t_5 = PyIter_Next(__pyx_t_1);
+      if (!__pyx_t_5) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_5);
+    }
+    __Pyx_DECREF(__pyx_v_k);
+    __pyx_v_k = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":459
+ *         # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+ *         for k in data:
+ *             if k != 'GT': sdata.append( (k,data[k]) )             # <<<<<<<<<<<<<<
+ *         sdata.sort()
+ *         if 'GT' in data:
+ */
+    __pyx_t_5 = PyObject_RichCompare(__pyx_v_k, ((PyObject *)__pyx_n_s__GT), Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_3) {
+      if (unlikely(__pyx_v_sdata == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      }
+      __pyx_t_5 = PyObject_GetItem(__pyx_v_data, __pyx_v_k); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k);
+      __Pyx_GIVEREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_5);
+      __pyx_t_5 = 0;
+      __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_sdata), __pyx_t_2); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L16;
+    }
+    __pyx_L16:;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":460
+ *         for k in data:
+ *             if k != 'GT': sdata.append( (k,data[k]) )
+ *         sdata.sort()             # <<<<<<<<<<<<<<
+ *         if 'GT' in data:
+ *             sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+ */
+  if (unlikely(__pyx_v_sdata == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'sort'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_9 = PyList_Sort(((PyObject *)__pyx_v_sdata)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":461
+ *             if k != 'GT': sdata.append( (k,data[k]) )
+ *         sdata.sort()
+ *         if 'GT' in data:             # <<<<<<<<<<<<<<
+ *             sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+ *         for k,v in sdata:
+ */
+  __pyx_t_3 = ((PySequence_Contains(__pyx_v_data, ((PyObject *)__pyx_n_s__GT)))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":462
+ *         sdata.sort()
+ *         if 'GT' in data:
+ *             sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata             # <<<<<<<<<<<<<<
+ *         for k,v in sdata:
+ *             if v == []: v = None
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__convertGTback); 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_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__GT)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_1 = 0;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_map, __pyx_t_5, 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_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__GT));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__GT));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GT));
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_sdata)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_v_sdata));
+    __pyx_v_sdata = __pyx_t_5;
+    __pyx_t_5 = 0;
+    goto __pyx_L17;
+  }
+  __pyx_L17:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":463
+ *         if 'GT' in data:
+ *             sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+ *         for k,v in sdata:             # <<<<<<<<<<<<<<
+ *             if v == []: v = None
+ *             if key and value:
+ */
+  if (likely(((PyObject *)__pyx_v_sdata) != Py_None)) {
+    __pyx_t_4 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_sdata); __Pyx_INCREF(__pyx_t_5);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  for (;;) {
+    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
+    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+      PyObject* tuple = __pyx_t_2;
+      __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+      __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_v_k);
+      __pyx_v_k = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_6;
+      __pyx_t_6 = 0;
+    } else {
+      __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_8, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_8, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      if (__Pyx_EndUnpack(__pyx_t_8, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __Pyx_DECREF(__pyx_v_k);
+      __pyx_v_k = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_6;
+      __pyx_t_6 = 0;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":464
+ *             sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+ *         for k,v in sdata:
+ *             if v == []: v = None             # <<<<<<<<<<<<<<
+ *             if key and value:
+ *                 if v != None: output.append( k+"="+','.join(map(str,v)) )
+ */
+    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_6 = PyObject_RichCompare(__pyx_v_v, ((PyObject *)__pyx_t_2), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__pyx_t_3) {
+      __Pyx_INCREF(Py_None);
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = Py_None;
+      goto __pyx_L20;
+    }
+    __pyx_L20:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":465
+ *         for k,v in sdata:
+ *             if v == []: v = None
+ *             if key and value:             # <<<<<<<<<<<<<<
+ *                 if v != None: output.append( k+"="+','.join(map(str,v)) )
+ *                 else: output.append( k )
+ */
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_key); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_3) {
+      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __pyx_t_10;
+    } else {
+      __pyx_t_11 = __pyx_t_3;
+    }
+    if (__pyx_t_11) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":466
+ *             if v == []: v = None
+ *             if key and value:
+ *                 if v != None: output.append( k+"="+','.join(map(str,v)) )             # <<<<<<<<<<<<<<
+ *                 else: output.append( k )
+ *             elif key: output.append(k)
+ */
+      __pyx_t_6 = PyObject_RichCompare(__pyx_v_v, Py_None, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      if (__pyx_t_11) {
+        if (unlikely(__pyx_v_output == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_6 = PyNumber_Add(__pyx_v_k, ((PyObject *)__pyx_kp_s_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __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 = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+        __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+        __Pyx_INCREF(__pyx_v_v);
+        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_v);
+        __Pyx_GIVEREF(__pyx_v_v);
+        __pyx_t_8 = PyObject_Call(__pyx_builtin_map, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __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(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __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);
+        __pyx_t_8 = 0;
+        __pyx_t_8 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_output), __pyx_t_1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        goto __pyx_L22;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":467
+ *             if key and value:
+ *                 if v != None: output.append( k+"="+','.join(map(str,v)) )
+ *                 else: output.append( k )             # <<<<<<<<<<<<<<
+ *             elif key: output.append(k)
+ *             elif value:
+ */
+        if (unlikely(__pyx_v_output == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_output), __pyx_v_k); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      __pyx_L22:;
+      goto __pyx_L21;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":468
+ *                 if v != None: output.append( k+"="+','.join(map(str,v)) )
+ *                 else: output.append( k )
+ *             elif key: output.append(k)             # <<<<<<<<<<<<<<
+ *             elif value:
+ *                 if v != None: output.append( ','.join(map(str,v)) )
+ */
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_key); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_11) {
+      if (unlikely(__pyx_v_output == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      }
+      __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_output), __pyx_v_k); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L21;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":469
+ *                 else: output.append( k )
+ *             elif key: output.append(k)
+ *             elif value:             # <<<<<<<<<<<<<<
+ *                 if v != None: output.append( ','.join(map(str,v)) )
+ *                 else: output.append( "." )                    # should not happen
+ */
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_11) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":470
+ *             elif key: output.append(k)
+ *             elif value:
+ *                 if v != None: output.append( ','.join(map(str,v)) )             # <<<<<<<<<<<<<<
+ *                 else: output.append( "." )                    # should not happen
+ *         # snip off trailing missing data
+ */
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_v, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      if (__pyx_t_11) {
+        if (unlikely(__pyx_v_output == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __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)));
+        __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+        __Pyx_INCREF(__pyx_v_v);
+        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_v);
+        __Pyx_GIVEREF(__pyx_v_v);
+        __pyx_t_6 = PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __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 = 470; __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);
+        __pyx_t_6 = 0;
+        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_output), __pyx_t_6); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        goto __pyx_L23;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":471
+ *             elif value:
+ *                 if v != None: output.append( ','.join(map(str,v)) )
+ *                 else: output.append( "." )                    # should not happen             # <<<<<<<<<<<<<<
+ *         # snip off trailing missing data
+ *         while len(output) > 1:
+ */
+        if (unlikely(__pyx_v_output == Py_None)) {
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        }
+        __pyx_t_9 = PyList_Append(((PyObject *)__pyx_v_output), ((PyObject *)__pyx_kp_s_6)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      __pyx_L23:;
+      goto __pyx_L21;
+    }
+    __pyx_L21:;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":473
+ *                 else: output.append( "." )                    # should not happen
+ *         # snip off trailing missing data
+ *         while len(output) > 1:             # <<<<<<<<<<<<<<
+ *             last = output[-1].replace(',','').replace('.','')
+ *             if len(last)>0: break
+ */
+  while (1) {
+    if (unlikely(__pyx_v_output == Py_None)) {
+      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    }
+    __pyx_t_4 = PyList_GET_SIZE(((PyObject *)__pyx_v_output)); 
+    __pyx_t_11 = (__pyx_t_4 > 1);
+    if (!__pyx_t_11) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":474
+ *         # snip off trailing missing data
+ *         while len(output) > 1:
+ *             last = output[-1].replace(',','').replace('.','')             # <<<<<<<<<<<<<<
+ *             if len(last)>0: break
+ *             output = output[:-1]
+ */
+    __pyx_t_5 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_output), -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__replace); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_kp_s_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
+    __pyx_t_8 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__replace); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+    PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
+    __pyx_t_6 = PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_DECREF(__pyx_v_last);
+    __pyx_v_last = __pyx_t_6;
+    __pyx_t_6 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":475
+ *         while len(output) > 1:
+ *             last = output[-1].replace(',','').replace('.','')
+ *             if len(last)>0: break             # <<<<<<<<<<<<<<
+ *             output = output[:-1]
+ *         return separator.join(output)
+ */
+    __pyx_t_4 = PyObject_Length(__pyx_v_last); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = (__pyx_t_4 > 0);
+    if (__pyx_t_11) {
+      goto __pyx_L25_break;
+      goto __pyx_L26;
+    }
+    __pyx_L26:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":476
+ *             last = output[-1].replace(',','').replace('.','')
+ *             if len(last)>0: break
+ *             output = output[:-1]             # <<<<<<<<<<<<<<
+ *         return separator.join(output)
+ * 
+ */
+    __pyx_t_6 = PySequence_GetSlice(((PyObject *)__pyx_v_output), 0, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    __Pyx_DECREF(((PyObject *)__pyx_v_output));
+    __pyx_v_output = __pyx_t_6;
+    __pyx_t_6 = 0;
+  }
+  __pyx_L25_break:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":477
+ *             if len(last)>0: break
+ *             output = output[:-1]
+ *         return separator.join(output)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_separator, __pyx_n_s__join); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __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 = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_INCREF(((PyObject *)__pyx_v_output));
+  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_output));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_output));
+  __pyx_t_5 = PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __pyx_r = __pyx_t_5;
+  __pyx_t_5 = 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_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("cvcf.VCF.format_formatdata");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_output);
+  __Pyx_DECREF(__pyx_v_sdata);
+  __Pyx_DECREF(__pyx_v_d);
+  __Pyx_DECREF(__pyx_v_k);
+  __Pyx_DECREF(__pyx_v_idx);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_DECREF(__pyx_v_last);
+  __Pyx_DECREF(__pyx_v_data);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":480
+ * 
+ * 
+ *     def enter_default_format(self):             # <<<<<<<<<<<<<<
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_enter_default_format(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_enter_default_format = {__Pyx_NAMESTR("enter_default_format"), (PyCFunction)__pyx_pf_4cvcf_3VCF_enter_default_format, METH_O, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_enter_default_format(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  int __pyx_t_9;
+  __Pyx_RefNannySetupContext("enter_default_format");
+  __pyx_self = __pyx_self;
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":481
+ * 
+ *     def enter_default_format(self):
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),             # <<<<<<<<<<<<<<
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+ */
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); 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_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyTuple_New(6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__GT));
+  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__GT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GT));
+  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__String));
+  PyTuple_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_n_s__String));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__String));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Genotype));
+  PyTuple_SET_ITEM(__pyx_t_4, 4, ((PyObject *)__pyx_n_s__Genotype));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Genotype));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+  PyTuple_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_kp_s_6));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __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_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":482
+ *     def enter_default_format(self):
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),             # <<<<<<<<<<<<<<
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+ *                   FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+ */
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_5 = PyTuple_New(6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__GQ));
+  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__GQ));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GQ));
+  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Integer));
+  PyTuple_SET_ITEM(__pyx_t_5, 3, ((PyObject *)__pyx_n_s__Integer));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Integer));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
+  PyTuple_SET_ITEM(__pyx_t_5, 4, ((PyObject *)__pyx_kp_s_39));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
+  __Pyx_INCREF(__pyx_int_neg_1);
+  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_int_neg_1);
+  __Pyx_GIVEREF(__pyx_int_neg_1);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":483
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),             # <<<<<<<<<<<<<<
+ *                   FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+ *                   FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+ */
+  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__DP));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_n_s__DP));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DP));
+  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Integer));
+  PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_n_s__Integer));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Integer));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
+  PyTuple_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_kp_s_40));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
+  __Pyx_INCREF(__pyx_int_neg_1);
+  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_neg_1);
+  __Pyx_GIVEREF(__pyx_int_neg_1);
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":484
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+ *                   FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid             # <<<<<<<<<<<<<<
+ *                   FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+ *             if f.id not in self._format:
+ */
+  __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_UNKNOWN); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__HQ));
+  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_n_s__HQ));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__HQ));
+  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __Pyx_INCREF(__pyx_int_neg_1);
+  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_neg_1);
+  __Pyx_GIVEREF(__pyx_int_neg_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Integer));
+  PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)__pyx_n_s__Integer));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Integer));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
+  PyTuple_SET_ITEM(__pyx_t_7, 4, ((PyObject *)__pyx_kp_s_41));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
+  __Pyx_INCREF(__pyx_int_neg_1);
+  PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_int_neg_1);
+  __Pyx_GIVEREF(__pyx_int_neg_1);
+  __pyx_t_5 = 0;
+  __pyx_t_5 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":485
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+ *                   FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+ *                   FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:             # <<<<<<<<<<<<<<
+ *             if f.id not in self._format:
+ *                 self._format[f.id] = f
+ */
+  __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__FORMAT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__NT_NUMBER); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __pyx_t_8 = PyTuple_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FT));
+  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_n_s__FT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FT));
+  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__String));
+  PyTuple_SET_ITEM(__pyx_t_8, 3, ((PyObject *)__pyx_n_s__String));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__String));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
+  PyTuple_SET_ITEM(__pyx_t_8, 4, ((PyObject *)__pyx_kp_s_42));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+  PyTuple_SET_ITEM(__pyx_t_8, 5, ((PyObject *)__pyx_kp_s_6));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+  __pyx_t_6 = 0;
+  __pyx_t_6 = PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __pyx_t_8 = PyList_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyList_SET_ITEM(__pyx_t_8, 2, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyList_SET_ITEM(__pyx_t_8, 3, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyList_SET_ITEM(__pyx_t_8, 4, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  __pyx_t_3 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_6 = 0;
+  if (likely(((PyObject *)__pyx_t_8) != Py_None)) {
+    __pyx_t_1 = 0; __pyx_t_6 = ((PyObject *)__pyx_t_8); __Pyx_INCREF(__pyx_t_6);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+  for (;;) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":481
+ * 
+ *     def enter_default_format(self):
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),             # <<<<<<<<<<<<<<
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ *                   FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+ */
+    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_6)) break;
+    __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_t_1++;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_8;
+    __pyx_t_8 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":486
+ *                   FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+ *                   FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+ *             if f.id not in self._format:             # <<<<<<<<<<<<<<
+ *                 self._format[f.id] = f
+ * 
+ */
+    __pyx_t_8 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_9 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_5, __pyx_t_8))); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_9) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":487
+ *                   FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+ *             if f.id not in self._format:
+ *                 self._format[f.id] = f             # <<<<<<<<<<<<<<
+ * 
+ *     def parse_header( self, line ):
+ */
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_8 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      if (PyObject_SetItem(__pyx_t_5, __pyx_t_8, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_AddTraceback("cvcf.VCF.enter_default_format");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":489
+ *                 self._format[f.id] = f
+ * 
+ *     def parse_header( self, line ):             # <<<<<<<<<<<<<<
+ *         assert line.startswith('##')
+ *         elts = line[2:].split('=')
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse_header = {__Pyx_NAMESTR("parse_header"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse_header, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_elts;
+  PyObject *__pyx_v_key;
+  PyObject *__pyx_v_value;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,0};
+  __Pyx_RefNannySetupContext("parse_header");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse_header") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse_header", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse_header");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_elts = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":490
+ * 
+ *     def parse_header( self, line ):
+ *         assert line.startswith('##')             # <<<<<<<<<<<<<<
+ *         elts = line[2:].split('=')
+ *         key = elts[0].strip()
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_43));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __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_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 = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (unlikely(!__pyx_t_4)) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":491
+ *     def parse_header( self, line ):
+ *         assert line.startswith('##')
+ *         elts = line[2:].split('=')             # <<<<<<<<<<<<<<
+ *         key = elts[0].strip()
+ *         value = '='.join(elts[1:]).strip()
+ */
+  __pyx_t_3 = PySequence_GetSlice(__pyx_v_line, 2, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __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 = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_8));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __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_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_v_elts);
+  __pyx_v_elts = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":492
+ *         assert line.startswith('##')
+ *         elts = line[2:].split('=')
+ *         key = elts[0].strip()             # <<<<<<<<<<<<<<
+ *         value = '='.join(elts[1:]).strip()
+ *         if key == "fileformat":
+ */
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __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 = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_v_key);
+  __pyx_v_key = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":493
+ *         elts = line[2:].split('=')
+ *         key = elts[0].strip()
+ *         value = '='.join(elts[1:]).strip()             # <<<<<<<<<<<<<<
+ *         if key == "fileformat":
+ *             if value == "VCFv3.3":
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_8), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PySequence_GetSlice(__pyx_v_elts, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __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_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __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 = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_value);
+  __pyx_v_value = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":494
+ *         key = elts[0].strip()
+ *         value = '='.join(elts[1:]).strip()
+ *         if key == "fileformat":             # <<<<<<<<<<<<<<
+ *             if value == "VCFv3.3":
+ *                 self._version = 33
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__fileformat), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":495
+ *         value = '='.join(elts[1:]).strip()
+ *         if key == "fileformat":
+ *             if value == "VCFv3.3":             # <<<<<<<<<<<<<<
+ *                 self._version = 33
+ *             elif value == "VCFv4.0":
+ */
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, ((PyObject *)__pyx_kp_s_44), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (__pyx_t_4) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":496
+ *         if key == "fileformat":
+ *             if value == "VCFv3.3":
+ *                 self._version = 33             # <<<<<<<<<<<<<<
+ *             elif value == "VCFv4.0":
+ *                 self._version = 40
+ */
+      if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___version, __pyx_int_33) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":497
+ *             if value == "VCFv3.3":
+ *                 self._version = 33
+ *             elif value == "VCFv4.0":             # <<<<<<<<<<<<<<
+ *                 self._version = 40
+ *             elif value == "VCFv4.1":
+ */
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, ((PyObject *)__pyx_kp_s_45), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (__pyx_t_4) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":498
+ *                 self._version = 33
+ *             elif value == "VCFv4.0":
+ *                 self._version = 40             # <<<<<<<<<<<<<<
+ *             elif value == "VCFv4.1":
+ *                 # AH - for testing
+ */
+      if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___version, __pyx_int_40) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":499
+ *             elif value == "VCFv4.0":
+ *                 self._version = 40
+ *             elif value == "VCFv4.1":             # <<<<<<<<<<<<<<
+ *                 # AH - for testing
+ *                 self._version = 40
+ */
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, ((PyObject *)__pyx_kp_s_46), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (__pyx_t_4) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":501
+ *             elif value == "VCFv4.1":
+ *                 # AH - for testing
+ *                 self._version = 40             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.error(line,self.UNKNOWN_FORMAT_STRING)
+ */
+      if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___version, __pyx_int_40) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L7;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":503
+ *                 self._version = 40
+ *             else:
+ *                 self.error(line,self.UNKNOWN_FORMAT_STRING)             # <<<<<<<<<<<<<<
+ *         elif key == "INFO":
+ *             f = self.parse_format(line, value)
+ */
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_47); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __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 = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __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;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    }
+    __pyx_L7:;
+    goto __pyx_L6;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":504
+ *             else:
+ *                 self.error(line,self.UNKNOWN_FORMAT_STRING)
+ *         elif key == "INFO":             # <<<<<<<<<<<<<<
+ *             f = self.parse_format(line, value)
+ *             self._info[ f.id ] = f
+ */
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__INFO), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":505
+ *                 self.error(line,self.UNKNOWN_FORMAT_STRING)
+ *         elif key == "INFO":
+ *             f = self.parse_format(line, value)             # <<<<<<<<<<<<<<
+ *             self._info[ f.id ] = f
+ *         elif key == "FILTER":
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __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 = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __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_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":506
+ *         elif key == "INFO":
+ *             f = self.parse_format(line, value)
+ *             self._info[ f.id ] = f             # <<<<<<<<<<<<<<
+ *         elif key == "FILTER":
+ *             f = self.parse_format(line, value, filter=True)
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetItem(__pyx_t_3, __pyx_t_1, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    goto __pyx_L6;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":507
+ *             f = self.parse_format(line, value)
+ *             self._info[ f.id ] = f
+ *         elif key == "FILTER":             # <<<<<<<<<<<<<<
+ *             f = self.parse_format(line, value, filter=True)
+ *             self._filter[ f.id ] = f
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__FILTER), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":508
+ *             self._info[ f.id ] = f
+ *         elif key == "FILTER":
+ *             f = self.parse_format(line, value, filter=True)             # <<<<<<<<<<<<<<
+ *             self._filter[ f.id ] = f
+ *         elif key == "FORMAT":
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __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 = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__filter), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":509
+ *         elif key == "FILTER":
+ *             f = self.parse_format(line, value, filter=True)
+ *             self._filter[ f.id ] = f             # <<<<<<<<<<<<<<
+ *         elif key == "FORMAT":
+ *             f = self.parse_format(line, value)
+ */
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___filter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    if (PyObject_SetItem(__pyx_t_5, __pyx_t_2, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    goto __pyx_L6;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":510
+ *             f = self.parse_format(line, value, filter=True)
+ *             self._filter[ f.id ] = f
+ *         elif key == "FORMAT":             # <<<<<<<<<<<<<<
+ *             f = self.parse_format(line, value)
+ *             self._format[ f.id ] = f
+ */
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_n_s__FORMAT), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":511
+ *             self._filter[ f.id ] = f
+ *         elif key == "FORMAT":
+ *             f = self.parse_format(line, value)             # <<<<<<<<<<<<<<
+ *             self._format[ f.id ] = f
+ *         else:
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __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_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":512
+ *         elif key == "FORMAT":
+ *             f = self.parse_format(line, value)
+ *             self._format[ f.id ] = f             # <<<<<<<<<<<<<<
+ *         else:
+ *             # keep other keys in the header field
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    if (PyObject_SetItem(__pyx_t_3, __pyx_t_5, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    goto __pyx_L6;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":515
+ *         else:
+ *             # keep other keys in the header field
+ *             self._header.append( (key,value) )             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___header); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
+    __Pyx_GIVEREF(__pyx_v_key);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __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_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __pyx_L6:;
+
+  __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_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.parse_header");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_elts);
+  __Pyx_DECREF(__pyx_v_key);
+  __Pyx_DECREF(__pyx_v_value);
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":518
+ * 
+ * 
+ *     def write_header( self, stream ):             # <<<<<<<<<<<<<<
+ *         stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_write_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_write_header = {__Pyx_NAMESTR("write_header"), (PyCFunction)__pyx_pf_4cvcf_3VCF_write_header, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_write_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_key;
+  PyObject *__pyx_v_value;
+  PyObject *__pyx_v_var;
+  PyObject *__pyx_v_label;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  Py_ssize_t __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("write_header");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write_header") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("write_header", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.write_header");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_var = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_label = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":519
+ * 
+ *     def write_header( self, stream ):
+ *         stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))             # <<<<<<<<<<<<<<
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+ *         for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyNumber_FloorDivide(__pyx_t_2, __pyx_int_10); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyNumber_Remainder(__pyx_t_2, __pyx_int_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__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 = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __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 = 519; __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_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":520
+ *     def write_header( self, stream ):
+ *         stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))             # <<<<<<<<<<<<<<
+ *         for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:
+ *             for f in var.itervalues(): stream.write("##%s=%s\n" % (label,self.format_format(f,filter=(label=="FILTER"))))
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___header); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
+    __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
+    } else {
+      __pyx_t_4 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_4) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
+      PyObject* tuple = __pyx_t_4;
+      __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
+      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_key);
+      __pyx_v_key = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_value);
+      __pyx_v_value = __pyx_t_3;
+      __pyx_t_3 = 0;
+    } else {
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_v_key);
+      __pyx_v_key = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_value);
+      __pyx_v_value = __pyx_t_3;
+      __pyx_t_3 = 0;
+    }
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
+    __Pyx_GIVEREF(__pyx_v_key);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__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 = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":521
+ *         stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+ *         for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:             # <<<<<<<<<<<<<<
+ *             for f in var.itervalues(): stream.write("##%s=%s\n" % (label,self.format_format(f,filter=(label=="FILTER"))))
+ * 
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __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 = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__INFO));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__INFO));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__INFO));
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __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 = 521; __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);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FILTER));
+  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__FILTER));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FILTER));
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FORMAT));
+  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__FORMAT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FORMAT));
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_1 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  if (likely(((PyObject *)__pyx_t_2) != Py_None)) {
+    __pyx_t_5 = 0; __pyx_t_4 = ((PyObject *)__pyx_t_2); __Pyx_INCREF(__pyx_t_4);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  for (;;) {
+    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
+    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+      PyObject* tuple = __pyx_t_2;
+      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
+      __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_v_var);
+      __pyx_v_var = __pyx_t_3;
+      __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_v_label);
+      __pyx_v_label = __pyx_t_1;
+      __pyx_t_1 = 0;
+    } else {
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_v_var);
+      __pyx_v_var = __pyx_t_3;
+      __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_v_label);
+      __pyx_v_label = __pyx_t_1;
+      __pyx_t_1 = 0;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":522
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+ *         for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:
+ *             for f in var.itervalues(): stream.write("##%s=%s\n" % (label,self.format_format(f,filter=(label=="FILTER"))))             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_var, __pyx_n_s__itervalues); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __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 = 522; __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_7 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
+      } else {
+        __pyx_t_1 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_1) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_1);
+      }
+      __Pyx_DECREF(__pyx_v_f);
+      __pyx_v_f = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__format_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_INCREF(__pyx_v_f);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_f);
+      __Pyx_GIVEREF(__pyx_v_f);
+      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+      __pyx_t_9 = PyObject_RichCompare(__pyx_v_label, ((PyObject *)__pyx_n_s__FILTER), Py_EQ); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__filter), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_6, ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_INCREF(__pyx_v_label);
+      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_label);
+      __Pyx_GIVEREF(__pyx_v_label);
+      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      __pyx_t_9 = 0;
+      __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+      __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 = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_9));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
+      __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __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;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  __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_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cvcf.VCF.write_header");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_key);
+  __Pyx_DECREF(__pyx_v_value);
+  __Pyx_DECREF(__pyx_v_var);
+  __Pyx_DECREF(__pyx_v_label);
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":525
+ * 
+ * 
+ *     def parse_heading( self, line ):             # <<<<<<<<<<<<<<
+ *         assert line.startswith('#')
+ *         assert not line.startswith('##')
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_heading(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse_heading = {__Pyx_NAMESTR("parse_heading"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse_heading, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_heading(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_headings;
+  PyObject *__pyx_v_i;
+  PyObject *__pyx_v_s;
+  PyObject *__pyx_v_err;
+  PyObject *__pyx_v_x;
+  PyObject *__pyx_v_y;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  Py_ssize_t __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,0};
+  __Pyx_RefNannySetupContext("parse_heading");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_heading", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse_heading") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse_heading", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse_heading");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_headings = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_err = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_y = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":526
+ * 
+ *     def parse_heading( self, line ):
+ *         assert line.startswith('#')             # <<<<<<<<<<<<<<
+ *         assert not line.startswith('##')
+ *         headings = line[1:].split('\t')
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_50));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __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_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 = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (unlikely(!__pyx_t_4)) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":527
+ *     def parse_heading( self, line ):
+ *         assert line.startswith('#')
+ *         assert not line.startswith('##')             # <<<<<<<<<<<<<<
+ *         headings = line[1:].split('\t')
+ *         if len(headings)==1 and len(line[1:].split()) >= 9:
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_43));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __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_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 = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (unlikely(!(!__pyx_t_4))) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":528
+ *         assert line.startswith('#')
+ *         assert not line.startswith('##')
+ *         headings = line[1:].split('\t')             # <<<<<<<<<<<<<<
+ *         if len(headings)==1 and len(line[1:].split()) >= 9:
+ *             self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)
+ */
+  __pyx_t_1 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __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 = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __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_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __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_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_v_headings);
+  __pyx_v_headings = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":529
+ *         assert not line.startswith('##')
+ *         headings = line[1:].split('\t')
+ *         if len(headings)==1 and len(line[1:].split()) >= 9:             # <<<<<<<<<<<<<<
+ *             self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)
+ *             headings = line[1:].split()
+ */
+  __pyx_t_5 = PyObject_Length(__pyx_v_headings); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = (__pyx_t_5 == 1);
+  if (__pyx_t_4) {
+    __pyx_t_3 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __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 = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_6 = (__pyx_t_5 >= 9);
+    __pyx_t_7 = __pyx_t_6;
+  } else {
+    __pyx_t_7 = __pyx_t_4;
+  }
+  if (__pyx_t_7) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":530
+ *         headings = line[1:].split('\t')
+ *         if len(headings)==1 and len(line[1:].split()) >= 9:
+ *             self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)             # <<<<<<<<<<<<<<
+ *             headings = line[1:].split()
+ * 
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_52); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __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_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":531
+ *         if len(headings)==1 and len(line[1:].split()) >= 9:
+ *             self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)
+ *             headings = line[1:].split()             # <<<<<<<<<<<<<<
+ * 
+ *         for i,s in enumerate(self._required):
+ */
+    __pyx_t_1 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __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 = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_v_headings);
+    __pyx_v_headings = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":533
+ *             headings = line[1:].split()
+ * 
+ *         for i,s in enumerate(self._required):             # <<<<<<<<<<<<<<
+ * 
+ *             if len(headings)<=i or headings[i] != s:
+ */
+  __Pyx_INCREF(__pyx_int_0);
+  __pyx_t_1 = __pyx_int_0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___required); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_5 = 0; __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_3);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_s);
+    __pyx_v_s = __pyx_t_2;
+    __pyx_t_2 = 0;
+    __Pyx_INCREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_i);
+    __pyx_v_i = __pyx_t_1;
+    __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1);
+    __pyx_t_1 = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":535
+ *         for i,s in enumerate(self._required):
+ * 
+ *             if len(headings)<=i or headings[i] != s:             # <<<<<<<<<<<<<<
+ * 
+ *                 if len(headings) <= i:
+ */
+    __pyx_t_8 = PyObject_Length(__pyx_v_headings); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_v_i, Py_LE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    if (!__pyx_t_7) {
+      __pyx_t_9 = PyObject_GetItem(__pyx_v_headings, __pyx_v_i); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, __pyx_v_s, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_6 = __pyx_t_4;
+    } else {
+      __pyx_t_6 = __pyx_t_7;
+    }
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":537
+ *             if len(headings)<=i or headings[i] != s:
+ * 
+ *                 if len(headings) <= i:             # <<<<<<<<<<<<<<
+ *                     err = "(%sth entry not found)" % (i+1)
+ *                 else:
+ */
+      __pyx_t_8 = PyObject_Length(__pyx_v_headings); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_v_i, Py_LE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      if (__pyx_t_6) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":538
+ * 
+ *                 if len(headings) <= i:
+ *                     err = "(%sth entry not found)" % (i+1)             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     err = "(found %s, expected %s)" % (headings[i],s)
+ */
+        __pyx_t_9 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_err);
+        __pyx_v_err = ((PyObject *)__pyx_t_2);
+        __pyx_t_2 = 0;
+        goto __pyx_L10;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":540
+ *                     err = "(%sth entry not found)" % (i+1)
+ *                 else:
+ *                     err = "(found %s, expected %s)" % (headings[i],s)             # <<<<<<<<<<<<<<
+ * 
+ *                 #self.error(line,self.BADLY_FORMATTED_HEADING,err)
+ */
+        __pyx_t_2 = PyObject_GetItem(__pyx_v_headings, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __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);
+        __Pyx_INCREF(__pyx_v_s);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_s);
+        __Pyx_GIVEREF(__pyx_v_s);
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_err);
+        __pyx_v_err = ((PyObject *)__pyx_t_2);
+        __pyx_t_2 = 0;
+      }
+      __pyx_L10:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":545
+ * 
+ *                 # allow FORMAT column to be absent
+ *                 if len(headings) == 8:             # <<<<<<<<<<<<<<
+ *                     headings.append("FORMAT")
+ *                 else:
+ */
+      __pyx_t_8 = PyObject_Length(__pyx_v_headings); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = (__pyx_t_8 == 8);
+      if (__pyx_t_6) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":546
+ *                 # allow FORMAT column to be absent
+ *                 if len(headings) == 8:
+ *                     headings.append("FORMAT")             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.error(line,self.BADLY_FORMATTED_HEADING,err)
+ */
+        __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_headings, ((PyObject *)__pyx_n_s__FORMAT)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        goto __pyx_L11;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":548
+ *                     headings.append("FORMAT")
+ *                 else:
+ *                     self.error(line,self.BADLY_FORMATTED_HEADING,err)             # <<<<<<<<<<<<<<
+ * 
+ *         self._samples = headings[9:]
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_55); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_9);
+        __Pyx_INCREF(__pyx_v_err);
+        PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_err);
+        __Pyx_GIVEREF(__pyx_v_err);
+        __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      }
+      __pyx_L11:;
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":550
+ *                     self.error(line,self.BADLY_FORMATTED_HEADING,err)
+ * 
+ *         self._samples = headings[9:]             # <<<<<<<<<<<<<<
+ *         self._sample2column = dict( [(y,x+9) for x,y in enumerate( self._samples ) ] )
+ * 
+ */
+  __pyx_t_1 = PySequence_GetSlice(__pyx_v_headings, 9, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___samples, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":551
+ * 
+ *         self._samples = headings[9:]
+ *         self._sample2column = dict( [(y,x+9) for x,y in enumerate( self._samples ) ] )             # <<<<<<<<<<<<<<
+ * 
+ *     def write_heading( self, stream ):
+ */
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(__pyx_int_0);
+  __pyx_t_3 = __pyx_int_0;
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __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_5 = 0; __pyx_t_10 = __pyx_t_9; __Pyx_INCREF(__pyx_t_10);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+  }
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_10))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
+      __pyx_t_9 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_10))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
+      __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+    } else {
+      __pyx_t_9 = PyIter_Next(__pyx_t_10);
+      if (!__pyx_t_9) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_9);
+    }
+    __Pyx_DECREF(__pyx_v_y);
+    __pyx_v_y = __pyx_t_9;
+    __pyx_t_9 = 0;
+    __Pyx_INCREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_v_x);
+    __pyx_v_x = __pyx_t_3;
+    __pyx_t_9 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_3);
+    __pyx_t_3 = __pyx_t_9;
+    __pyx_t_9 = 0;
+    __pyx_t_9 = PyNumber_Add(__pyx_v_x, __pyx_int_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_y);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_y);
+    __Pyx_GIVEREF(__pyx_v_y);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
+    __Pyx_GIVEREF(__pyx_t_9);
+    __pyx_t_9 = 0;
+    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __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 = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_t_1));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
+  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___sample2column, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  __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_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_AddTraceback("cvcf.VCF.parse_heading");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_headings);
+  __Pyx_DECREF(__pyx_v_i);
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_DECREF(__pyx_v_err);
+  __Pyx_DECREF(__pyx_v_x);
+  __Pyx_DECREF(__pyx_v_y);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":553
+ *         self._sample2column = dict( [(y,x+9) for x,y in enumerate( self._samples ) ] )
+ * 
+ *     def write_heading( self, stream ):             # <<<<<<<<<<<<<<
+ *         stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_write_heading(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_write_heading = {__Pyx_NAMESTR("write_heading"), (PyCFunction)__pyx_pf_4cvcf_3VCF_write_heading, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_write_heading(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("write_heading");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write_heading", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write_heading") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("write_heading", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.write_heading");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":554
+ * 
+ *     def write_heading( self, stream ):
+ *         stream.write("#" + "\t".join(self._required + self._samples) + "\n")             # <<<<<<<<<<<<<<
+ * 
+ *     def convertGT(self, GTstring):
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_51), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___required); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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 = 554; __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_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_kp_s_50), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = PyNumber_Add(__pyx_t_4, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __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 = 554; __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, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  __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_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.write_heading");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":556
+ *         stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+ * 
+ *     def convertGT(self, GTstring):             # <<<<<<<<<<<<<<
+ *         if GTstring == ".": return ["."]
+ *         try:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_convertGT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_convertGT = {__Pyx_NAMESTR("convertGT"), (PyCFunction)__pyx_pf_4cvcf_3VCF_convertGT, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_convertGT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_GTstring = 0;
+  PyObject *__pyx_v_gts;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  Py_ssize_t __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  Py_ssize_t __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__GTstring,0};
+  __Pyx_RefNannySetupContext("convertGT");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__GTstring);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("convertGT", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "convertGT") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_GTstring = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_GTstring = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("convertGT", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.convertGT");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_gts = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":557
+ * 
+ *     def convertGT(self, GTstring):
+ *         if GTstring == ".": return ["."]             # <<<<<<<<<<<<<<
+ *         try:
+ *             gts = gtsRegEx.split(GTstring)
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_GTstring, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __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 = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+    __pyx_r = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":558
+ *     def convertGT(self, GTstring):
+ *         if GTstring == ".": return ["."]
+ *         try:             # <<<<<<<<<<<<<<
+ *             gts = gtsRegEx.split(GTstring)
+ *             if len(gts) == 1: return [int(gts[0])]
+ */
+  {
+    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+    __Pyx_XGOTREF(__pyx_save_exc_type);
+    __Pyx_XGOTREF(__pyx_save_exc_value);
+    __Pyx_XGOTREF(__pyx_save_exc_tb);
+    /*try:*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":559
+ *         if GTstring == ".": return ["."]
+ *         try:
+ *             gts = gtsRegEx.split(GTstring)             # <<<<<<<<<<<<<<
+ *             if len(gts) == 1: return [int(gts[0])]
+ *             if len(gts) != 2: raise ValueError()
+ */
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__gtsRegEx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L7_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 = 559; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(__pyx_v_GTstring);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_GTstring);
+      __Pyx_GIVEREF(__pyx_v_GTstring);
+      __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_gts);
+      __pyx_v_gts = __pyx_t_4;
+      __pyx_t_4 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":560
+ *         try:
+ *             gts = gtsRegEx.split(GTstring)
+ *             if len(gts) == 1: return [int(gts[0])]             # <<<<<<<<<<<<<<
+ *             if len(gts) != 2: raise ValueError()
+ *             if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+ */
+      __pyx_t_5 = PyObject_Length(__pyx_v_gts); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __pyx_t_2 = (__pyx_t_5 == 1);
+      if (__pyx_t_2) {
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __pyx_t_4 = 0;
+        __pyx_r = ((PyObject *)__pyx_t_1);
+        __pyx_t_1 = 0;
+        goto __pyx_L11_try_return;
+        goto __pyx_L15;
+      }
+      __pyx_L15:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":561
+ *             gts = gtsRegEx.split(GTstring)
+ *             if len(gts) == 1: return [int(gts[0])]
+ *             if len(gts) != 2: raise ValueError()             # <<<<<<<<<<<<<<
+ *             if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+ *             return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+ */
+      __pyx_t_5 = PyObject_Length(__pyx_v_gts); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __pyx_t_2 = (__pyx_t_5 != 2);
+      if (__pyx_t_2) {
+        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_Raise(__pyx_t_1, 0, 0);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        goto __pyx_L16;
+      }
+      __pyx_L16:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":562
+ *             if len(gts) == 1: return [int(gts[0])]
+ *             if len(gts) != 2: raise ValueError()
+ *             if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]             # <<<<<<<<<<<<<<
+ *             return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+ *         except ValueError:
+ */
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      if (__pyx_t_2) {
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_gts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_7 = __pyx_t_6;
+      } else {
+        __pyx_t_7 = __pyx_t_2;
+      }
+      if (__pyx_t_7) {
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_gts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_8 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_4 = PySequence_GetSlice(__pyx_v_GTstring, __pyx_t_5, (-__pyx_t_8)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_gts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_9 = PyList_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+        PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
+        __Pyx_GIVEREF(__pyx_t_1);
+        PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyList_SET_ITEM(__pyx_t_9, 2, __pyx_t_3);
+        __Pyx_GIVEREF(__pyx_t_3);
+        __pyx_t_1 = 0;
+        __pyx_t_4 = 0;
+        __pyx_t_3 = 0;
+        __pyx_r = ((PyObject *)__pyx_t_9);
+        __pyx_t_9 = 0;
+        goto __pyx_L11_try_return;
+        goto __pyx_L17;
+      }
+      __pyx_L17:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":563
+ *             if len(gts) != 2: raise ValueError()
+ *             if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+ *             return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]             # <<<<<<<<<<<<<<
+ *         except ValueError:
+ *             self.error(self._line,self.BAD_GENOTYPE,GTstring)
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_gts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_gts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PySequence_GetSlice(__pyx_v_GTstring, __pyx_t_8, (-__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_gts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __pyx_t_9 = 0;
+      __pyx_t_3 = 0;
+      __pyx_t_4 = 0;
+      __pyx_r = ((PyObject *)__pyx_t_1);
+      __pyx_t_1 = 0;
+      goto __pyx_L11_try_return;
+    }
+    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+    goto __pyx_L14_try_end;
+    __pyx_L11_try_return:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L0;
+    __pyx_L7_error:;
+    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":564
+ *             if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+ *             return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+ *         except ValueError:             # <<<<<<<<<<<<<<
+ *             self.error(self._line,self.BAD_GENOTYPE,GTstring)
+ *             return [".","|","."]
+ */
+    __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+    if (__pyx_t_10) {
+      __Pyx_AddTraceback("cvcf.VCF.convertGT");
+      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_t_3);
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":565
+ *             return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+ *         except ValueError:
+ *             self.error(self._line,self.BAD_GENOTYPE,GTstring)             # <<<<<<<<<<<<<<
+ *             return [".","|","."]
+ * 
+ */
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___line); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__BAD_GENOTYPE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11);
+      __Pyx_GIVEREF(__pyx_t_11);
+      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
+      __Pyx_GIVEREF(__pyx_t_12);
+      __Pyx_INCREF(__pyx_v_GTstring);
+      PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_GTstring);
+      __Pyx_GIVEREF(__pyx_v_GTstring);
+      __pyx_t_11 = 0;
+      __pyx_t_12 = 0;
+      __pyx_t_12 = PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":566
+ *         except ValueError:
+ *             self.error(self._line,self.BAD_GENOTYPE,GTstring)
+ *             return [".","|","."]             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __pyx_t_12 = PyList_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+      PyList_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_kp_s_6));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_57));
+      PyList_SET_ITEM(__pyx_t_12, 1, ((PyObject *)__pyx_kp_s_57));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_57));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+      PyList_SET_ITEM(__pyx_t_12, 2, ((PyObject *)__pyx_kp_s_6));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+      __pyx_r = ((PyObject *)__pyx_t_12);
+      __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L10_except_return;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      goto __pyx_L8_exception_handled;
+    }
+    __pyx_L9_except_error:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L1_error;
+    __pyx_L10_except_return:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L0;
+    __pyx_L8_exception_handled:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    __pyx_L14_try_end:;
+  }
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("cvcf.VCF.convertGT");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_gts);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":569
+ * 
+ * 
+ *     def convertGTback(self, GTdata):             # <<<<<<<<<<<<<<
+ *         return ''.join(map(str,GTdata))
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_convertGTback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_convertGTback = {__Pyx_NAMESTR("convertGTback"), (PyCFunction)__pyx_pf_4cvcf_3VCF_convertGTback, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_convertGTback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_GTdata = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__GTdata,0};
+  __Pyx_RefNannySetupContext("convertGTback");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__GTdata);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("convertGTback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "convertGTback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_GTdata = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_GTdata = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("convertGTback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.convertGTback");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":570
+ * 
+ *     def convertGTback(self, GTdata):
+ *         return ''.join(map(str,GTdata))             # <<<<<<<<<<<<<<
+ * 
+ *     def parse_formatdata( self, key, value, formatdict, line ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(2); 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);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_INCREF(__pyx_v_GTdata);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_GTdata);
+  __Pyx_GIVEREF(__pyx_v_GTdata);
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_map, __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(__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 = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __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(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 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_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("cvcf.VCF.convertGTback");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":572
+ *         return ''.join(map(str,GTdata))
+ * 
+ *     def parse_formatdata( self, key, value, formatdict, line ):             # <<<<<<<<<<<<<<
+ *         # To do: check that the right number of values is present
+ *         f = formatdict.get(key,None)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_formatdata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse_formatdata = {__Pyx_NAMESTR("parse_formatdata"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse_formatdata, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_formatdata(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_key = 0;
+  PyObject *__pyx_v_value = 0;
+  PyObject *__pyx_v_formatdict = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_v_values;
+  PyObject *__pyx_v_idx;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  Py_ssize_t __pyx_t_7;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  Py_ssize_t __pyx_t_14;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,&__pyx_n_s__value,&__pyx_n_s__formatdict,&__pyx_n_s__line,0};
+  __Pyx_RefNannySetupContext("parse_formatdata");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[5] = {0,0,0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_formatdata", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_formatdata", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__formatdict);
+      if (likely(values[3])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_formatdata", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  4:
+      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[4])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_formatdata", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse_formatdata") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_key = values[1];
+    __pyx_v_value = values[2];
+    __pyx_v_formatdict = values[3];
+    __pyx_v_line = values[4];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 2);
+    __pyx_v_formatdict = PyTuple_GET_ITEM(__pyx_args, 3);
+    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 4);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse_formatdata", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse_formatdata");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_values = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_idx = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":574
+ *     def parse_formatdata( self, key, value, formatdict, line ):
+ *         # To do: check that the right number of values is present
+ *         f = formatdict.get(key,None)             # <<<<<<<<<<<<<<
+ *         if f == None:
+ *             self._add_definition(formatdict, key, value, line )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_formatdict, __pyx_n_s__get); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __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);
+  __Pyx_GIVEREF(__pyx_v_key);
+  __Pyx_INCREF(Py_None);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_f);
+  __pyx_v_f = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":575
+ *         # To do: check that the right number of values is present
+ *         f = formatdict.get(key,None)
+ *         if f == None:             # <<<<<<<<<<<<<<
+ *             self._add_definition(formatdict, key, value, line )
+ *             f = formatdict[key]
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_f, Py_None, Py_EQ); 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_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":576
+ *         f = formatdict.get(key,None)
+ *         if f == None:
+ *             self._add_definition(formatdict, key, value, line )             # <<<<<<<<<<<<<<
+ *             f = formatdict[key]
+ *         if f.type == "Flag":
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___add_definition); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_formatdict);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_formatdict);
+    __Pyx_GIVEREF(__pyx_v_formatdict);
+    __Pyx_INCREF(__pyx_v_key);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_key);
+    __Pyx_GIVEREF(__pyx_v_key);
+    __Pyx_INCREF(__pyx_v_value);
+    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_value);
+    __Pyx_GIVEREF(__pyx_v_value);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __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_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":577
+ *         if f == None:
+ *             self._add_definition(formatdict, key, value, line )
+ *             f = formatdict[key]             # <<<<<<<<<<<<<<
+ *         if f.type == "Flag":
+ *             if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+ */
+    __pyx_t_1 = PyObject_GetItem(__pyx_v_formatdict, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":578
+ *             self._add_definition(formatdict, key, value, line )
+ *             f = formatdict[key]
+ *         if f.type == "Flag":             # <<<<<<<<<<<<<<
+ *             if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+ *             return []
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Flag), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __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 = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":579
+ *             f = formatdict[key]
+ *         if f.type == "Flag":
+ *             if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)             # <<<<<<<<<<<<<<
+ *             return []
+ *         values = value.split(',')
+ */
+    __pyx_t_4 = (__pyx_v_value != Py_None);
+    if (__pyx_t_4) {
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_58); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __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 = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      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_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __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_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":580
+ *         if f.type == "Flag":
+ *             if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+ *             return []             # <<<<<<<<<<<<<<
+ *         values = value.split(',')
+ *         # deal with trailing data in some early VCF files
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __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_L7;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":581
+ *             if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+ *             return []
+ *         values = value.split(',')             # <<<<<<<<<<<<<<
+ *         # deal with trailing data in some early VCF files
+ *         if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_value, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __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 = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_2));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __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_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_v_values);
+  __pyx_v_values = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":583
+ *         values = value.split(',')
+ *         # deal with trailing data in some early VCF files
+ *         if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:             # <<<<<<<<<<<<<<
+ *             self.error(line,self.ERROR_TRAILING_DATA,values[-1])
+ *             values[-1] = values[-1].split(';')[0]
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__Float), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __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) {
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__Integer), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_6 = __pyx_t_4;
+    __pyx_t_4 = __pyx_t_6;
+  } else {
+    __pyx_t_4 = __pyx_t_5;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_5 = __pyx_t_4;
+  if (__pyx_t_5) {
+    __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = (__pyx_t_7 > 0);
+    if (__pyx_t_4) {
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_values, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__find); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __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 = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_7));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+      __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __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_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_neg_1, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_8 = __pyx_t_6;
+    } else {
+      __pyx_t_8 = __pyx_t_4;
+    }
+    __pyx_t_4 = __pyx_t_8;
+  } else {
+    __pyx_t_4 = __pyx_t_5;
+  }
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":584
+ *         # deal with trailing data in some early VCF files
+ *         if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:
+ *             self.error(line,self.ERROR_TRAILING_DATA,values[-1])             # <<<<<<<<<<<<<<
+ *             values[-1] = values[-1].split(';')[0]
+ *         if f.type == "Integer":
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ERROR_TRAILING_DATA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_values, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __pyx_t_1 = 0;
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __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_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":585
+ *         if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:
+ *             self.error(line,self.ERROR_TRAILING_DATA,values[-1])
+ *             values[-1] = values[-1].split(';')[0]             # <<<<<<<<<<<<<<
+ *         if f.type == "Integer":
+ *             for idx,v in enumerate(values):
+ */
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_values, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __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 = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+    __pyx_t_2 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__Pyx_SetItemInt(__pyx_v_values, -1, __pyx_t_3, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L9;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":586
+ *             self.error(line,self.ERROR_TRAILING_DATA,values[-1])
+ *             values[-1] = values[-1].split(';')[0]
+ *         if f.type == "Integer":             # <<<<<<<<<<<<<<
+ *             for idx,v in enumerate(values):
+ *                 try:
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__Integer), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":587
+ *             values[-1] = values[-1].split(';')[0]
+ *         if f.type == "Integer":
+ *             for idx,v in enumerate(values):             # <<<<<<<<<<<<<<
+ *                 try:
+ *                     if v == ".": values[idx] = f.missingvalue
+ */
+    __Pyx_INCREF(__pyx_int_0);
+    __pyx_t_2 = __pyx_int_0;
+    if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
+      __pyx_t_7 = 0; __pyx_t_3 = __pyx_v_values; __Pyx_INCREF(__pyx_t_3);
+    } else {
+      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++;
+      } else {
+        __pyx_t_9 = PyIter_Next(__pyx_t_3);
+        if (!__pyx_t_9) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_9);
+      }
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_9;
+      __pyx_t_9 = 0;
+      __Pyx_INCREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_v_idx);
+      __pyx_v_idx = __pyx_t_2;
+      __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2);
+      __pyx_t_2 = __pyx_t_9;
+      __pyx_t_9 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":588
+ *         if f.type == "Integer":
+ *             for idx,v in enumerate(values):
+ *                 try:             # <<<<<<<<<<<<<<
+ *                     if v == ".": values[idx] = f.missingvalue
+ *                     else:        values[idx] = int(v)
+ */
+      {
+        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+        __Pyx_XGOTREF(__pyx_save_exc_type);
+        __Pyx_XGOTREF(__pyx_save_exc_value);
+        __Pyx_XGOTREF(__pyx_save_exc_tb);
+        /*try:*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":589
+ *             for idx,v in enumerate(values):
+ *                 try:
+ *                     if v == ".": values[idx] = f.missingvalue             # <<<<<<<<<<<<<<
+ *                     else:        values[idx] = int(v)
+ *                 except:
+ */
+          __pyx_t_9 = PyObject_RichCompare(__pyx_v_v, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          if (__pyx_t_4) {
+            __pyx_t_9 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__missingvalue); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+            __Pyx_GOTREF(__pyx_t_9);
+            if (PyObject_SetItem(__pyx_v_values, __pyx_v_idx, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            goto __pyx_L21;
+          }
+          /*else*/ {
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":590
+ *                 try:
+ *                     if v == ".": values[idx] = f.missingvalue
+ *                     else:        values[idx] = int(v)             # <<<<<<<<<<<<<<
+ *                 except:
+ *                     self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ */
+            __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_INCREF(__pyx_v_v);
+            PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_v);
+            __Pyx_GIVEREF(__pyx_v_v);
+            __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            if (PyObject_SetItem(__pyx_v_values, __pyx_v_idx, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          }
+          __pyx_L21:;
+        }
+        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+        goto __pyx_L20_try_end;
+        __pyx_L13_error:;
+        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":591
+ *                     if v == ".": values[idx] = f.missingvalue
+ *                     else:        values[idx] = int(v)
+ *                 except:             # <<<<<<<<<<<<<<
+ *                     self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ *                     return [0] * len(values)
+ */
+        /*except:*/ {
+          __Pyx_AddTraceback("cvcf.VCF.parse_formatdata");
+          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_GOTREF(__pyx_t_10);
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":592
+ *                     else:        values[idx] = int(v)
+ *                 except:
+ *                     self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)             # <<<<<<<<<<<<<<
+ *                     return [0] * len(values)
+ *             return values
+ */
+          __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_11);
+          __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_59); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_12);
+          __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_INCREF(__pyx_v_line);
+          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_line);
+          __Pyx_GIVEREF(__pyx_v_line);
+          PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
+          __Pyx_GIVEREF(__pyx_t_12);
+          __Pyx_INCREF(__pyx_v_values);
+          PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_values);
+          __Pyx_GIVEREF(__pyx_v_values);
+          __pyx_t_12 = 0;
+          __pyx_t_12 = PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_12);
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":593
+ *                 except:
+ *                     self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ *                     return [0] * len(values)             # <<<<<<<<<<<<<<
+ *             return values
+ *         elif f.type == "String":
+ */
+          __Pyx_XDECREF(__pyx_r);
+          __pyx_t_12 = PyList_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+          __Pyx_INCREF(__pyx_int_0);
+          PyList_SET_ITEM(__pyx_t_12, 0, __pyx_int_0);
+          __Pyx_GIVEREF(__pyx_int_0);
+          __pyx_t_14 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __pyx_t_13 = PyInt_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __pyx_t_11 = PyNumber_Multiply(((PyObject *)__pyx_t_12), __pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
+          __Pyx_GOTREF(__pyx_t_11);
+          __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __pyx_r = __pyx_t_11;
+          __pyx_t_11 = 0;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          goto __pyx_L16_except_return;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+          goto __pyx_L14_exception_handled;
+        }
+        __pyx_L15_except_error:;
+        __Pyx_XGIVEREF(__pyx_save_exc_type);
+        __Pyx_XGIVEREF(__pyx_save_exc_value);
+        __Pyx_XGIVEREF(__pyx_save_exc_tb);
+        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+        goto __pyx_L1_error;
+        __pyx_L16_except_return:;
+        __Pyx_XGIVEREF(__pyx_save_exc_type);
+        __Pyx_XGIVEREF(__pyx_save_exc_value);
+        __Pyx_XGIVEREF(__pyx_save_exc_tb);
+        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+        goto __pyx_L0;
+        __pyx_L14_exception_handled:;
+        __Pyx_XGIVEREF(__pyx_save_exc_type);
+        __Pyx_XGIVEREF(__pyx_save_exc_value);
+        __Pyx_XGIVEREF(__pyx_save_exc_tb);
+        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+        __pyx_L20_try_end:;
+      }
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":594
+ *                     self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ *                     return [0] * len(values)
+ *             return values             # <<<<<<<<<<<<<<
+ *         elif f.type == "String":
+ *             self._line = line
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_values);
+    __pyx_r = __pyx_v_values;
+    goto __pyx_L0;
+    goto __pyx_L10;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":595
+ *                     return [0] * len(values)
+ *             return values
+ *         elif f.type == "String":             # <<<<<<<<<<<<<<
+ *             self._line = line
+ *             if f.id == "GT": values = map( self.convertGT, values )
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__String), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __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 = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":596
+ *             return values
+ *         elif f.type == "String":
+ *             self._line = line             # <<<<<<<<<<<<<<
+ *             if f.id == "GT": values = map( self.convertGT, values )
+ *             return values
+ */
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___line, __pyx_v_line) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":597
+ *         elif f.type == "String":
+ *             self._line = line
+ *             if f.id == "GT": values = map( self.convertGT, values )             # <<<<<<<<<<<<<<
+ *             return values
+ *         elif f.type == "Character":
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__GT), Py_EQ); 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_3); __pyx_t_3 = 0;
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 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;
+    if (__pyx_t_4) {
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__convertGT); 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_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __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);
+      __Pyx_INCREF(__pyx_v_values);
+      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_values);
+      __Pyx_GIVEREF(__pyx_v_values);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_map, __pyx_t_3, 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_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_v_values);
+      __pyx_v_values = __pyx_t_2;
+      __pyx_t_2 = 0;
+      goto __pyx_L24;
+    }
+    __pyx_L24:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":598
+ *             self._line = line
+ *             if f.id == "GT": values = map( self.convertGT, values )
+ *             return values             # <<<<<<<<<<<<<<
+ *         elif f.type == "Character":
+ *             for v in values:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_values);
+    __pyx_r = __pyx_v_values;
+    goto __pyx_L0;
+    goto __pyx_L10;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":599
+ *             if f.id == "GT": values = map( self.convertGT, values )
+ *             return values
+ *         elif f.type == "Character":             # <<<<<<<<<<<<<<
+ *             for v in values:
+ *                 if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__Character), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __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 = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":600
+ *             return values
+ *         elif f.type == "Character":
+ *             for v in values:             # <<<<<<<<<<<<<<
+ *                 if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+ *             return values
+ */
+    if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
+      __pyx_t_7 = 0; __pyx_t_3 = __pyx_v_values; __Pyx_INCREF(__pyx_t_3);
+    } else {
+      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
+      } else {
+        __pyx_t_2 = PyIter_Next(__pyx_t_3);
+        if (!__pyx_t_2) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_2);
+      }
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_2;
+      __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":601
+ *         elif f.type == "Character":
+ *             for v in values:
+ *                 if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)             # <<<<<<<<<<<<<<
+ *             return values
+ *         elif f.type == "Float":
+ */
+      __pyx_t_14 = PyObject_Length(__pyx_v_v); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = (__pyx_t_14 != 1);
+      if (__pyx_t_4) {
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_60); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        goto __pyx_L27;
+      }
+      __pyx_L27:;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":602
+ *             for v in values:
+ *                 if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+ *             return values             # <<<<<<<<<<<<<<
+ *         elif f.type == "Float":
+ *             for idx,v in enumerate(values):
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_v_values);
+    __pyx_r = __pyx_v_values;
+    goto __pyx_L0;
+    goto __pyx_L10;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":603
+ *                 if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+ *             return values
+ *         elif f.type == "Float":             # <<<<<<<<<<<<<<
+ *             for idx,v in enumerate(values):
+ *                 if v == ".": values[idx] = f.missingvalue
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__type); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_10 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__Float), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":604
+ *             return values
+ *         elif f.type == "Float":
+ *             for idx,v in enumerate(values):             # <<<<<<<<<<<<<<
+ *                 if v == ".": values[idx] = f.missingvalue
+ *             try: return map(float,values)
+ */
+    __Pyx_INCREF(__pyx_int_0);
+    __pyx_t_10 = __pyx_int_0;
+    if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
+      __pyx_t_7 = 0; __pyx_t_3 = __pyx_v_values; __Pyx_INCREF(__pyx_t_3);
+    } else {
+      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++;
+      } else {
+        __pyx_t_9 = PyIter_Next(__pyx_t_3);
+        if (!__pyx_t_9) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_9);
+      }
+      __Pyx_DECREF(__pyx_v_v);
+      __pyx_v_v = __pyx_t_9;
+      __pyx_t_9 = 0;
+      __Pyx_INCREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_v_idx);
+      __pyx_v_idx = __pyx_t_10;
+      __pyx_t_9 = PyNumber_Add(__pyx_t_10, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_10);
+      __pyx_t_10 = __pyx_t_9;
+      __pyx_t_9 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":605
+ *         elif f.type == "Float":
+ *             for idx,v in enumerate(values):
+ *                 if v == ".": values[idx] = f.missingvalue             # <<<<<<<<<<<<<<
+ *             try: return map(float,values)
+ *             except:
+ */
+      __pyx_t_9 = PyObject_RichCompare(__pyx_v_v, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      if (__pyx_t_4) {
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__missingvalue); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        if (PyObject_SetItem(__pyx_v_values, __pyx_v_idx, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        goto __pyx_L30;
+      }
+      __pyx_L30:;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":606
+ *             for idx,v in enumerate(values):
+ *                 if v == ".": values[idx] = f.missingvalue
+ *             try: return map(float,values)             # <<<<<<<<<<<<<<
+ *             except:
+ *                 self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L31_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(((PyObject *)((PyObject*)&PyFloat_Type)));
+        PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)((PyObject*)&PyFloat_Type)));
+        __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyFloat_Type)));
+        __Pyx_INCREF(__pyx_v_values);
+        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_values);
+        __Pyx_GIVEREF(__pyx_v_values);
+        __pyx_t_3 = PyObject_Call(__pyx_builtin_map, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L31_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_r = __pyx_t_3;
+        __pyx_t_3 = 0;
+        goto __pyx_L35_try_return;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L38_try_end;
+      __pyx_L35_try_return:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L0;
+      __pyx_L31_error:;
+      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":607
+ *                 if v == ".": values[idx] = f.missingvalue
+ *             try: return map(float,values)
+ *             except:             # <<<<<<<<<<<<<<
+ *                 self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ *                 return [0.0] * len(values)
+ */
+      /*except:*/ {
+        __Pyx_AddTraceback("cvcf.VCF.parse_formatdata");
+        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_10, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GOTREF(__pyx_t_9);
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":608
+ *             try: return map(float,values)
+ *             except:
+ *                 self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)             # <<<<<<<<<<<<<<
+ *                 return [0.0] * len(values)
+ *         else:
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_59); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1);
+        __Pyx_GIVEREF(__pyx_t_1);
+        __Pyx_INCREF(__pyx_v_values);
+        PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_values);
+        __Pyx_GIVEREF(__pyx_v_values);
+        __pyx_t_1 = 0;
+        __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":609
+ *             except:
+ *                 self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+ *                 return [0.0] * len(values)             # <<<<<<<<<<<<<<
+ *         else:
+ *             # can't happen
+ */
+        __Pyx_XDECREF(__pyx_r);
+        __pyx_t_1 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_11 = PyList_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_11));
+        PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
+        __Pyx_GIVEREF(__pyx_t_1);
+        __pyx_t_1 = 0;
+        __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_t_11), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_r = __pyx_t_2;
+        __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        goto __pyx_L34_except_return;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        goto __pyx_L32_exception_handled;
+      }
+      __pyx_L33_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L34_except_return:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L0;
+      __pyx_L32_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L38_try_end:;
+    }
+    goto __pyx_L10;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":612
+ *         else:
+ *             # can't happen
+ *             self.error(line,self.ERROR_INFO_STRING)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ERROR_INFO_STRING); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
+    __Pyx_GIVEREF(__pyx_t_10);
+    __pyx_t_10 = 0;
+    __pyx_t_10 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  }
+  __pyx_L10:;
+
+  __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_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("cvcf.VCF.parse_formatdata");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_DECREF(__pyx_v_values);
+  __Pyx_DECREF(__pyx_v_idx);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":615
+ * 
+ * 
+ *     def inregion(self, chrom, pos):             # <<<<<<<<<<<<<<
+ *         if not self._regions: return True
+ *         for r in self._regions:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_inregion(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_inregion = {__Pyx_NAMESTR("inregion"), (PyCFunction)__pyx_pf_4cvcf_3VCF_inregion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_inregion(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_chrom = 0;
+  PyObject *__pyx_v_pos = 0;
+  PyObject *__pyx_v_r;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  Py_ssize_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__chrom,&__pyx_n_s__pos,0};
+  __Pyx_RefNannySetupContext("inregion");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__chrom);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("inregion", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("inregion", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "inregion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_chrom = values[1];
+    __pyx_v_pos = values[2];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_chrom = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_pos = PyTuple_GET_ITEM(__pyx_args, 2);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("inregion", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.inregion");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_r = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":616
+ * 
+ *     def inregion(self, chrom, pos):
+ *         if not self._regions: return True             # <<<<<<<<<<<<<<
+ *         for r in self._regions:
+ *             if r[0] == chrom and r[1] <= pos < r[2]: return True
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __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 = 616; __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_XDECREF(__pyx_r);
+    __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":617
+ *     def inregion(self, chrom, pos):
+ *         if not self._regions: return True
+ *         for r in self._regions:             # <<<<<<<<<<<<<<
+ *             if r[0] == chrom and r[1] <= pos < r[2]: return True
+ *         return False
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___regions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __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_4 = 0; __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++;
+    } else {
+      __pyx_t_1 = PyIter_Next(__pyx_t_5);
+      if (!__pyx_t_1) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    __Pyx_DECREF(__pyx_v_r);
+    __pyx_v_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":618
+ *         if not self._regions: return True
+ *         for r in self._regions:
+ *             if r[0] == chrom and r[1] <= pos < r[2]: return True             # <<<<<<<<<<<<<<
+ *         return False
+ * 
+ */
+    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_r, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_chrom, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__pyx_t_3) {
+      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_r, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_v_pos, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
+        __Pyx_DECREF(__pyx_t_1);
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_r, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = PyObject_RichCompare(__pyx_v_pos, __pyx_t_7, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_8 = __pyx_t_2;
+    } else {
+      __pyx_t_8 = __pyx_t_3;
+    }
+    if (__pyx_t_8) {
+      __Pyx_XDECREF(__pyx_r);
+      __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_r = __pyx_t_1;
+      __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      goto __pyx_L0;
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":619
+ *         for r in self._regions:
+ *             if r[0] == chrom and r[1] <= pos < r[2]: return True
+ *         return False             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_r = __pyx_t_5;
+  __pyx_t_5 = 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_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("cvcf.VCF.inregion");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_r);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":622
+ * 
+ * 
+ *     def parse_data( self, line, lineparse=False ):             # <<<<<<<<<<<<<<
+ *         cols = line.split('\t')
+ *         if len(cols) != len(self._samples)+9:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse_data = {__Pyx_NAMESTR("parse_data"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_lineparse = 0;
+  PyObject *__pyx_v_cols;
+  PyObject *__pyx_v_chrom;
+  PyObject *__pyx_v_pos;
+  PyObject *__pyx_v_id;
+  PyObject *__pyx_v_ref;
+  PyObject *__pyx_v_c;
+  PyObject *__pyx_v_left;
+  PyObject *__pyx_v_faref_leftflank;
+  PyObject *__pyx_v_faref;
+  PyObject *__pyx_v_alt;
+  double __pyx_v_qual;
+  PyObject *__pyx_v_filter;
+  PyObject *__pyx_v_info;
+  PyObject *__pyx_v_blurp;
+  PyObject *__pyx_v_elts;
+  PyObject *__pyx_v_v;
+  PyObject *__pyx_v_format;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_v_newalts;
+  int __pyx_v_have_deletions;
+  PyObject *__pyx_v_a;
+  PyObject *__pyx_v_l;
+  PyObject *__pyx_v_addns;
+  PyObject *__pyx_v_i;
+  PyObject *__pyx_v_na;
+  PyObject *__pyx_v_s;
+  PyObject *__pyx_v_addn;
+  PyObject *__pyx_v_allele;
+  int __pyx_v_movable;
+  PyObject *__pyx_v_longest;
+  PyObject *__pyx_v_shortest;
+  PyObject *__pyx_v_samples;
+  PyObject *__pyx_v_sample;
+  PyObject *__pyx_v_dict;
+  PyObject *__pyx_v_values;
+  Py_ssize_t __pyx_v_idx;
+  PyObject *__pyx_v_expected;
+  PyObject *__pyx_v_value;
+  PyObject *__pyx_v_d;
+  PyObject *__pyx_v_key;
+  PyObject *__pyx_8genexpr0__pyx_v_allele;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  long __pyx_t_13;
+  double __pyx_t_14;
+  int __pyx_t_15;
+  int __pyx_t_16;
+  Py_ssize_t __pyx_t_17;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  Py_ssize_t __pyx_t_21;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,&__pyx_n_s__lineparse,0};
+  __Pyx_RefNannySetupContext("parse_data");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    values[2] = __pyx_k_61;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse_data", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lineparse);
+        if (value) { values[2] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+    __pyx_v_lineparse = values[2];
+  } else {
+    __pyx_v_lineparse = __pyx_k_61;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3:
+      __pyx_v_lineparse = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2:
+      __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse_data", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse_data");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_cols = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_chrom = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_pos = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_id = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_ref = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_c = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_left = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_faref_leftflank = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_faref = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_alt = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_filter = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_info = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_blurp = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_elts = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_format = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_newalts = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_addns = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_na = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_addn = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_allele = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_longest = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_shortest = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_samples = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_sample = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_dict = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_values = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_expected = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_d = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_8genexpr0__pyx_v_allele = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":623
+ * 
+ *     def parse_data( self, line, lineparse=False ):
+ *         cols = line.split('\t')             # <<<<<<<<<<<<<<
+ *         if len(cols) != len(self._samples)+9:
+ *             # gracefully deal with absent FORMAT column
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_51));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_51));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51));
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_cols);
+  __pyx_v_cols = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":624
+ *     def parse_data( self, line, lineparse=False ):
+ *         cols = line.split('\t')
+ *         if len(cols) != len(self._samples)+9:             # <<<<<<<<<<<<<<
+ *             # gracefully deal with absent FORMAT column
+ *             if len(cols) == 8 and len(self._samples)==0:
+ */
+  __pyx_t_4 = PyObject_Length(__pyx_v_cols); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_6 = (__pyx_t_4 != (__pyx_t_5 + 9));
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":626
+ *         if len(cols) != len(self._samples)+9:
+ *             # gracefully deal with absent FORMAT column
+ *             if len(cols) == 8 and len(self._samples)==0:             # <<<<<<<<<<<<<<
+ *                 cols.append("")
+ *             else:
+ */
+    __pyx_t_5 = PyObject_Length(__pyx_v_cols); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = (__pyx_t_5 == 8);
+    if (__pyx_t_6) {
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_7 = (__pyx_t_5 == 0);
+      __pyx_t_8 = __pyx_t_7;
+    } else {
+      __pyx_t_8 = __pyx_t_6;
+    }
+    if (__pyx_t_8) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":627
+ *             # gracefully deal with absent FORMAT column
+ *             if len(cols) == 8 and len(self._samples)==0:
+ *                 cols.append("")             # <<<<<<<<<<<<<<
+ *             else:
+ *                 self.error(line,
+ */
+      __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_cols, ((PyObject *)__pyx_kp_s_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      goto __pyx_L7;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":629
+ *                 cols.append("")
+ *             else:
+ *                 self.error(line,             # <<<<<<<<<<<<<<
+ *                            self.BAD_NUMBER_OF_COLUMNS,
+ *                            "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))
+ */
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":630
+ *             else:
+ *                 self.error(line,
+ *                            self.BAD_NUMBER_OF_COLUMNS,             # <<<<<<<<<<<<<<
+ *                            "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))
+ * 
+ */
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_62); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":631
+ *                 self.error(line,
+ *                            self.BAD_NUMBER_OF_COLUMNS,
+ *                            "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))             # <<<<<<<<<<<<<<
+ * 
+ *         chrom = cols[0]
+ */
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_5 + 9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_5 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_5 = PyObject_Length(__pyx_v_cols); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_10);
+      __Pyx_GIVEREF(__pyx_t_10);
+      PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_11);
+      __Pyx_GIVEREF(__pyx_t_11);
+      __pyx_t_1 = 0;
+      __pyx_t_9 = 0;
+      __pyx_t_10 = 0;
+      __pyx_t_11 = 0;
+      __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_63), __pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_11));
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_12, 2, ((PyObject *)__pyx_t_11));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_11));
+      __pyx_t_2 = 0;
+      __pyx_t_11 = 0;
+      __pyx_t_11 = PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    }
+    __pyx_L7:;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":633
+ *                            "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))
+ * 
+ *         chrom = cols[0]             # <<<<<<<<<<<<<<
+ * 
+ *         # get 0-based position
+ */
+  __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __Pyx_DECREF(__pyx_v_chrom);
+  __pyx_v_chrom = __pyx_t_11;
+  __pyx_t_11 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":636
+ * 
+ *         # get 0-based position
+ *         try:    pos = int(cols[1])-1             # <<<<<<<<<<<<<<
+ *         except: self.error(line,self.POS_NOT_NUMERICAL)
+ *         if pos < 0: self.error(line,self.POS_NOT_POSITIVE)
+ */
+  {
+    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+    __Pyx_XGOTREF(__pyx_save_exc_type);
+    __Pyx_XGOTREF(__pyx_save_exc_value);
+    __Pyx_XGOTREF(__pyx_save_exc_tb);
+    /*try:*/ {
+      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11);
+      __Pyx_GIVEREF(__pyx_t_11);
+      __pyx_t_11 = 0;
+      __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_12 = PyNumber_Subtract(__pyx_t_11, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_v_pos);
+      __pyx_v_pos = __pyx_t_12;
+      __pyx_t_12 = 0;
+    }
+    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+    goto __pyx_L15_try_end;
+    __pyx_L8_error:;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":637
+ *         # get 0-based position
+ *         try:    pos = int(cols[1])-1
+ *         except: self.error(line,self.POS_NOT_NUMERICAL)             # <<<<<<<<<<<<<<
+ *         if pos < 0: self.error(line,self.POS_NOT_POSITIVE)
+ * 
+ */
+    /*except:*/ {
+      __Pyx_AddTraceback("cvcf.VCF.parse_data");
+      if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__POS_NOT_NUMERICAL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
+      __Pyx_GIVEREF(__pyx_t_10);
+      __pyx_t_10 = 0;
+      __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      goto __pyx_L9_exception_handled;
+    }
+    __pyx_L10_except_error:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L1_error;
+    __pyx_L9_exception_handled:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    __pyx_L15_try_end:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":638
+ *         try:    pos = int(cols[1])-1
+ *         except: self.error(line,self.POS_NOT_NUMERICAL)
+ *         if pos < 0: self.error(line,self.POS_NOT_POSITIVE)             # <<<<<<<<<<<<<<
+ * 
+ *         # implement filtering
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_pos, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_8) {
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__POS_NOT_POSITIVE); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11);
+    __Pyx_GIVEREF(__pyx_t_11);
+    __pyx_t_11 = 0;
+    __pyx_t_11 = PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    goto __pyx_L18;
+  }
+  __pyx_L18:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":641
+ * 
+ *         # implement filtering
+ *         if not self.inregion(chrom,pos): return None             # <<<<<<<<<<<<<<
+ * 
+ *         # end of first-pass parse for sortedVCF
+ */
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__inregion); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __Pyx_INCREF(__pyx_v_chrom);
+  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_chrom);
+  __Pyx_GIVEREF(__pyx_v_chrom);
+  __Pyx_INCREF(__pyx_v_pos);
+  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_pos);
+  __Pyx_GIVEREF(__pyx_v_pos);
+  __pyx_t_3 = PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_6 = (!__pyx_t_8);
+  if (__pyx_t_6) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+    goto __pyx_L19;
+  }
+  __pyx_L19:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":644
+ * 
+ *         # end of first-pass parse for sortedVCF
+ *         if lineparse: return chrom, pos, line             # <<<<<<<<<<<<<<
+ * 
+ *         id = cols[2]
+ */
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_lineparse); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_6) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_chrom);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_chrom);
+    __Pyx_GIVEREF(__pyx_v_chrom);
+    __Pyx_INCREF(__pyx_v_pos);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_pos);
+    __Pyx_GIVEREF(__pyx_v_pos);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
+    goto __pyx_L20;
+  }
+  __pyx_L20:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":646
+ *         if lineparse: return chrom, pos, line
+ * 
+ *         id = cols[2]             # <<<<<<<<<<<<<<
+ * 
+ *         ref = cols[3].upper()
+ */
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_cols, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_v_id);
+  __pyx_v_id = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":648
+ *         id = cols[2]
+ * 
+ *         ref = cols[3].upper()             # <<<<<<<<<<<<<<
+ *         if ref == ".":
+ *             self.error(line,self.MISSING_REF)
+ */
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_cols, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_12 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__upper); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __Pyx_DECREF(__pyx_v_ref);
+  __pyx_v_ref = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":649
+ * 
+ *         ref = cols[3].upper()
+ *         if ref == ".":             # <<<<<<<<<<<<<<
+ *             self.error(line,self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ */
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_ref, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":650
+ *         ref = cols[3].upper()
+ *         if ref == ".":
+ *             self.error(line,self.MISSING_REF)             # <<<<<<<<<<<<<<
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ *             else:                   ref = ""
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__MISSING_REF); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_INCREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_line);
+    __Pyx_GIVEREF(__pyx_v_line);
+    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_12);
+    __Pyx_GIVEREF(__pyx_t_12);
+    __pyx_t_12 = 0;
+    __pyx_t_12 = PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":651
+ *         if ref == ".":
+ *             self.error(line,self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)             # <<<<<<<<<<<<<<
+ *             else:                   ref = ""
+ *         else:
+ */
+    __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __pyx_t_11 = PyObject_RichCompare(__pyx_t_12, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    if (__pyx_t_6) {
+      __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_12 = PyNumber_Add(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_chrom);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
+      __Pyx_GIVEREF(__pyx_v_chrom);
+      __Pyx_INCREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_pos);
+      __Pyx_GIVEREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_12);
+      __Pyx_GIVEREF(__pyx_t_12);
+      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __pyx_t_12 = 0;
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = __pyx_t_3;
+      __pyx_t_3 = 0;
+      goto __pyx_L22;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":652
+ *             self.error(line,self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ *             else:                   ref = ""             # <<<<<<<<<<<<<<
+ *         else:
+ *             for c in ref:
+ */
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = ((PyObject *)__pyx_kp_s_1);
+    }
+    __pyx_L22:;
+    goto __pyx_L21;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":654
+ *             else:                   ref = ""
+ *         else:
+ *             for c in ref:             # <<<<<<<<<<<<<<
+ *                 if c not in "ACGTN": self.error(line,self.UNKNOWN_CHAR_IN_REF)
+ *             if "N" in ref: ref = get_sequence(chrom,pos,pos+len(ref),self._reference)
+ */
+    if (PyList_CheckExact(__pyx_v_ref) || PyTuple_CheckExact(__pyx_v_ref)) {
+      __pyx_t_5 = 0; __pyx_t_3 = __pyx_v_ref; __Pyx_INCREF(__pyx_t_3);
+    } else {
+      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_10 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_10); __pyx_t_5++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+        __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_10); __pyx_t_5++;
+      } else {
+        __pyx_t_10 = PyIter_Next(__pyx_t_3);
+        if (!__pyx_t_10) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_10);
+      }
+      __Pyx_DECREF(__pyx_v_c);
+      __pyx_v_c = __pyx_t_10;
+      __pyx_t_10 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":655
+ *         else:
+ *             for c in ref:
+ *                 if c not in "ACGTN": self.error(line,self.UNKNOWN_CHAR_IN_REF)             # <<<<<<<<<<<<<<
+ *             if "N" in ref: ref = get_sequence(chrom,pos,pos+len(ref),self._reference)
+ * 
+ */
+      __pyx_t_6 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_n_s__ACGTN), __pyx_v_c))); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_6) {
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__UNKNOWN_CHAR_IN_REF); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11);
+        __Pyx_GIVEREF(__pyx_t_11);
+        __pyx_t_11 = 0;
+        __pyx_t_11 = PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        goto __pyx_L25;
+      }
+      __pyx_L25:;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":656
+ *             for c in ref:
+ *                 if c not in "ACGTN": self.error(line,self.UNKNOWN_CHAR_IN_REF)
+ *             if "N" in ref: ref = get_sequence(chrom,pos,pos+len(ref),self._reference)             # <<<<<<<<<<<<<<
+ * 
+ *         # make sure reference is sane
+ */
+    __pyx_t_6 = ((PySequence_Contains(__pyx_v_ref, ((PyObject *)__pyx_n_s__N)))); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_6) {
+      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_12 = PyNumber_Add(__pyx_v_pos, __pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_chrom);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
+      __Pyx_GIVEREF(__pyx_v_chrom);
+      __Pyx_INCREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_pos);
+      __Pyx_GIVEREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_12);
+      __Pyx_GIVEREF(__pyx_t_12);
+      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_11);
+      __Pyx_GIVEREF(__pyx_t_11);
+      __pyx_t_12 = 0;
+      __pyx_t_11 = 0;
+      __pyx_t_11 = PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = __pyx_t_11;
+      __pyx_t_11 = 0;
+      goto __pyx_L26;
+    }
+    __pyx_L26:;
+  }
+  __pyx_L21:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":659
+ * 
+ *         # make sure reference is sane
+ *         if self._reference:             # <<<<<<<<<<<<<<
+ *             left = max(0,pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+ */
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":660
+ *         # make sure reference is sane
+ *         if self._reference:
+ *             left = max(0,pos-100)             # <<<<<<<<<<<<<<
+ *             faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]
+ */
+    __pyx_t_11 = PyNumber_Subtract(__pyx_v_pos, __pyx_int_100); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_13 = 0;
+    __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_12 = PyObject_RichCompare(__pyx_t_11, __pyx_t_3, Py_GT); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    if (__pyx_t_6) {
+      __Pyx_INCREF(__pyx_t_11);
+      __pyx_t_10 = __pyx_t_11;
+    } else {
+      __pyx_t_12 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_10 = __pyx_t_12;
+      __pyx_t_12 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_INCREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_v_left);
+    __pyx_v_left = __pyx_t_10;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":661
+ *         if self._reference:
+ *             left = max(0,pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)             # <<<<<<<<<<<<<<
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ */
+    __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_12 = PyNumber_Add(__pyx_v_pos, __pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_chrom);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_chrom);
+    __Pyx_GIVEREF(__pyx_v_chrom);
+    __Pyx_INCREF(__pyx_v_left);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_left);
+    __Pyx_GIVEREF(__pyx_v_left);
+    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_12);
+    __Pyx_GIVEREF(__pyx_t_12);
+    PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_11);
+    __Pyx_GIVEREF(__pyx_t_11);
+    __pyx_t_12 = 0;
+    __pyx_t_11 = 0;
+    __pyx_t_11 = PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_faref_leftflank);
+    __pyx_v_faref_leftflank = __pyx_t_11;
+    __pyx_t_11 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":662
+ *             left = max(0,pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]             # <<<<<<<<<<<<<<
+ *             if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ *             ref = faref
+ */
+    __pyx_t_11 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_11); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __pyx_t_11 = PySequence_GetSlice(__pyx_v_faref_leftflank, __pyx_t_5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_v_faref);
+    __pyx_v_faref = __pyx_t_11;
+    __pyx_t_11 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":663
+ *             faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))             # <<<<<<<<<<<<<<
+ *             ref = faref
+ * 
+ */
+    __pyx_t_11 = PyObject_RichCompare(__pyx_v_faref, __pyx_v_ref, Py_NE); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    if (__pyx_t_6) {
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__WRONG_REF); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_faref);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_faref);
+      __Pyx_GIVEREF(__pyx_v_faref);
+      __Pyx_INCREF(__pyx_v_ref);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_ref);
+      __Pyx_GIVEREF(__pyx_v_ref);
+      __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_64), __pyx_t_10); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_10, 2, ((PyObject *)__pyx_t_12));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
+      __pyx_t_3 = 0;
+      __pyx_t_12 = 0;
+      __pyx_t_12 = PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      goto __pyx_L28;
+    }
+    __pyx_L28:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":664
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ *             ref = faref             # <<<<<<<<<<<<<<
+ * 
+ *         # convert v3.3 to v4.0 alleles below
+ */
+    __Pyx_INCREF(__pyx_v_faref);
+    __Pyx_DECREF(__pyx_v_ref);
+    __pyx_v_ref = __pyx_v_faref;
+    goto __pyx_L27;
+  }
+  __pyx_L27:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":667
+ * 
+ *         # convert v3.3 to v4.0 alleles below
+ *         if cols[4] == ".": alt = []             # <<<<<<<<<<<<<<
+ *         else: alt = cols[4].upper().split(',')
+ * 
+ */
+  __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_cols, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_10 = PyObject_RichCompare(__pyx_t_12, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  if (__pyx_t_6) {
+    __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = ((PyObject *)__pyx_t_10);
+    __pyx_t_10 = 0;
+    goto __pyx_L29;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":668
+ *         # convert v3.3 to v4.0 alleles below
+ *         if cols[4] == ".": alt = []
+ *         else: alt = cols[4].upper().split(',')             # <<<<<<<<<<<<<<
+ * 
+ *         if cols[5] == ".": qual = -1
+ */
+    __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_cols, 4, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_12 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__upper); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_10 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __pyx_t_12 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__split); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_kp_s_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+    __pyx_t_11 = PyObject_Call(__pyx_t_12, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = __pyx_t_11;
+    __pyx_t_11 = 0;
+  }
+  __pyx_L29:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":670
+ *         else: alt = cols[4].upper().split(',')
+ * 
+ *         if cols[5] == ".": qual = -1             # <<<<<<<<<<<<<<
+ *         else:
+ *             try:    qual = float(cols[5])
+ */
+  __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 5, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __pyx_t_10 = PyObject_RichCompare(__pyx_t_11, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  if (__pyx_t_6) {
+    __pyx_v_qual = -1.0;
+    goto __pyx_L30;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":672
+ *         if cols[5] == ".": qual = -1
+ *         else:
+ *             try:    qual = float(cols[5])             # <<<<<<<<<<<<<<
+ *             except: self.error(line,self.QUAL_NOT_NUMERICAL)
+ * 
+ */
+    {
+      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+      __Pyx_XGOTREF(__pyx_save_exc_type);
+      __Pyx_XGOTREF(__pyx_save_exc_value);
+      __Pyx_XGOTREF(__pyx_save_exc_tb);
+      /*try:*/ {
+        __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_cols, 5, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L31_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_t_10); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L31_error;}
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_v_qual = __pyx_t_14;
+      }
+      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+      goto __pyx_L38_try_end;
+      __pyx_L31_error:;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":673
+ *         else:
+ *             try:    qual = float(cols[5])
+ *             except: self.error(line,self.QUAL_NOT_NUMERICAL)             # <<<<<<<<<<<<<<
+ * 
+ *         # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ */
+      /*except:*/ {
+        __Pyx_AddTraceback("cvcf.VCF.parse_data");
+        if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_GOTREF(__pyx_t_12);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__QUAL_NOT_NUMERICAL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_9);
+        __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L33_except_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        goto __pyx_L32_exception_handled;
+      }
+      __pyx_L33_except_error:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      goto __pyx_L1_error;
+      __pyx_L32_exception_handled:;
+      __Pyx_XGIVEREF(__pyx_save_exc_type);
+      __Pyx_XGIVEREF(__pyx_save_exc_value);
+      __Pyx_XGIVEREF(__pyx_save_exc_tb);
+      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+      __pyx_L38_try_end:;
+    }
+  }
+  __pyx_L30:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":676
+ * 
+ *         # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ *         if cols[6] == "." or cols[6] == "PASS" or cols[6] == "0": filter = []             # <<<<<<<<<<<<<<
+ *         else: filter = cols[6].split(';')
+ * 
+ */
+  __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_cols, 6, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_11 = PyObject_RichCompare(__pyx_t_12, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  if (!__pyx_t_6) {
+    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 6, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_12 = PyObject_RichCompare(__pyx_t_11, ((PyObject *)__pyx_n_s__PASS), Py_EQ); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    if (!__pyx_t_8) {
+      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_cols, 6, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_11 = PyObject_RichCompare(__pyx_t_12, ((PyObject *)__pyx_kp_s__0), Py_EQ); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __pyx_t_15 = __pyx_t_7;
+    } else {
+      __pyx_t_15 = __pyx_t_8;
+    }
+    __pyx_t_8 = __pyx_t_15;
+  } else {
+    __pyx_t_8 = __pyx_t_6;
+  }
+  if (__pyx_t_8) {
+    __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
+    __Pyx_DECREF(__pyx_v_filter);
+    __pyx_v_filter = ((PyObject *)__pyx_t_11);
+    __pyx_t_11 = 0;
+    goto __pyx_L41;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":677
+ *         # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+ *         if cols[6] == "." or cols[6] == "PASS" or cols[6] == "0": filter = []
+ *         else: filter = cols[6].split(';')             # <<<<<<<<<<<<<<
+ * 
+ *         # dictionary of keys, and list of values
+ */
+    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 6, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_12 = PyObject_GetAttr(__pyx_t_11, __pyx_n_s__split); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+    PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_kp_s_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+    __pyx_t_10 = PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_DECREF(__pyx_v_filter);
+    __pyx_v_filter = __pyx_t_10;
+    __pyx_t_10 = 0;
+  }
+  __pyx_L41:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":680
+ * 
+ *         # dictionary of keys, and list of values
+ *         info = {}             # <<<<<<<<<<<<<<
+ *         if cols[7] != ".":
+ *             for blurp in cols[7].split(';'):
+ */
+  __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+  __Pyx_DECREF(((PyObject *)__pyx_v_info));
+  __pyx_v_info = __pyx_t_10;
+  __pyx_t_10 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":681
+ *         # dictionary of keys, and list of values
+ *         info = {}
+ *         if cols[7] != ".":             # <<<<<<<<<<<<<<
+ *             for blurp in cols[7].split(';'):
+ *                 elts = blurp.split('=')
+ */
+  __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_cols, 7, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_11 = PyObject_RichCompare(__pyx_t_10, ((PyObject *)__pyx_kp_s_6), Py_NE); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  if (__pyx_t_8) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":682
+ *         info = {}
+ *         if cols[7] != ".":
+ *             for blurp in cols[7].split(';'):             # <<<<<<<<<<<<<<
+ *                 elts = blurp.split('=')
+ *                 if len(elts) == 1: v = None
+ */
+    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 7, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_10 = PyObject_GetAttr(__pyx_t_11, __pyx_n_s__split); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
+    PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_kp_s_7));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
+    __pyx_t_12 = PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_12);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
+      __pyx_t_5 = 0; __pyx_t_11 = __pyx_t_12; __Pyx_INCREF(__pyx_t_11);
+    } else {
+      __pyx_t_5 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+    }
+    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_11))) {
+        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_11)) break;
+        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_11))) {
+        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
+        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++;
+      } else {
+        __pyx_t_12 = PyIter_Next(__pyx_t_11);
+        if (!__pyx_t_12) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_12);
+      }
+      __Pyx_DECREF(__pyx_v_blurp);
+      __pyx_v_blurp = __pyx_t_12;
+      __pyx_t_12 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":683
+ *         if cols[7] != ".":
+ *             for blurp in cols[7].split(';'):
+ *                 elts = blurp.split('=')             # <<<<<<<<<<<<<<
+ *                 if len(elts) == 1: v = None
+ *                 elif len(elts) == 2: v = elts[1]
+ */
+      __pyx_t_12 = PyObject_GetAttr(__pyx_v_blurp, __pyx_n_s__split); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_t_9 = PyObject_Call(__pyx_t_12, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_v_elts);
+      __pyx_v_elts = __pyx_t_9;
+      __pyx_t_9 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":684
+ *             for blurp in cols[7].split(';'):
+ *                 elts = blurp.split('=')
+ *                 if len(elts) == 1: v = None             # <<<<<<<<<<<<<<
+ *                 elif len(elts) == 2: v = elts[1]
+ *                 else: self.error(line,self.ERROR_INFO_STRING)
+ */
+      __pyx_t_4 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = (__pyx_t_4 == 1);
+      if (__pyx_t_8) {
+        __Pyx_INCREF(Py_None);
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = Py_None;
+        goto __pyx_L45;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":685
+ *                 elts = blurp.split('=')
+ *                 if len(elts) == 1: v = None
+ *                 elif len(elts) == 2: v = elts[1]             # <<<<<<<<<<<<<<
+ *                 else: self.error(line,self.ERROR_INFO_STRING)
+ *                 info[elts[0]] = self.parse_formatdata(elts[0], v, self._info, line)
+ */
+      __pyx_t_4 = PyObject_Length(__pyx_v_elts); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = (__pyx_t_4 == 2);
+      if (__pyx_t_8) {
+        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_elts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_v_v);
+        __pyx_v_v = __pyx_t_9;
+        __pyx_t_9 = 0;
+        goto __pyx_L45;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":686
+ *                 if len(elts) == 1: v = None
+ *                 elif len(elts) == 2: v = elts[1]
+ *                 else: self.error(line,self.ERROR_INFO_STRING)             # <<<<<<<<<<<<<<
+ *                 info[elts[0]] = self.parse_formatdata(elts[0], v, self._info, line)
+ * 
+ */
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ERROR_INFO_STRING); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+      __pyx_L45:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":687
+ *                 elif len(elts) == 2: v = elts[1]
+ *                 else: self.error(line,self.ERROR_INFO_STRING)
+ *                 info[elts[0]] = self.parse_formatdata(elts[0], v, self._info, line)             # <<<<<<<<<<<<<<
+ * 
+ *         # Gracefully deal with absent FORMAT column
+ */
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_formatdata); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___info); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12);
+      __Pyx_GIVEREF(__pyx_t_12);
+      __Pyx_INCREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_v);
+      __Pyx_GIVEREF(__pyx_v_v);
+      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      __pyx_t_12 = 0;
+      __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_elts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      if (PyDict_SetItem(((PyObject *)__pyx_v_info), __pyx_t_2, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    goto __pyx_L42;
+  }
+  __pyx_L42:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":690
+ * 
+ *         # Gracefully deal with absent FORMAT column
+ *         if cols[8] == "": format = []             # <<<<<<<<<<<<<<
+ *         else: format = cols[8].split(':')
+ * 
+ */
+  __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_cols, 8, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __pyx_t_9 = PyObject_RichCompare(__pyx_t_11, ((PyObject *)__pyx_kp_s_1), Py_EQ); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  if (__pyx_t_8) {
+    __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = ((PyObject *)__pyx_t_9);
+    __pyx_t_9 = 0;
+    goto __pyx_L46;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":691
+ *         # Gracefully deal with absent FORMAT column
+ *         if cols[8] == "": format = []
+ *         else: format = cols[8].split(':')             # <<<<<<<<<<<<<<
+ * 
+ *         # check: all filters are defined
+ */
+    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_cols, 8, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_11 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__split); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __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 = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_2 = PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_v_format);
+    __pyx_v_format = __pyx_t_2;
+    __pyx_t_2 = 0;
+  }
+  __pyx_L46:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":694
+ * 
+ *         # check: all filters are defined
+ *         for f in filter:             # <<<<<<<<<<<<<<
+ *             if f not in self._filter: self.error(line,self.FILTER_NOT_DEFINED, f)
+ * 
+ */
+  if (PyList_CheckExact(__pyx_v_filter) || PyTuple_CheckExact(__pyx_v_filter)) {
+    __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_filter; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+    } else {
+      __pyx_t_9 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_9) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_9);
+    }
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_9;
+    __pyx_t_9 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":695
+ *         # check: all filters are defined
+ *         for f in filter:
+ *             if f not in self._filter: self.error(line,self.FILTER_NOT_DEFINED, f)             # <<<<<<<<<<<<<<
+ * 
+ *         # check: format fields are defined
+ */
+    __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___filter); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_8 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_9, __pyx_v_f))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    if (__pyx_t_8) {
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__FILTER_NOT_DEFINED); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
+      __Pyx_GIVEREF(__pyx_t_11);
+      __Pyx_INCREF(__pyx_v_f);
+      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_f);
+      __Pyx_GIVEREF(__pyx_v_f);
+      __pyx_t_11 = 0;
+      __pyx_t_11 = PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      goto __pyx_L49;
+    }
+    __pyx_L49:;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":698
+ * 
+ *         # check: format fields are defined
+ *         for f in format:             # <<<<<<<<<<<<<<
+ *             if f not in self._format: self.error(line,self.FORMAT_NOT_DEFINED, f)
+ * 
+ */
+  if (PyList_CheckExact(__pyx_v_format) || PyTuple_CheckExact(__pyx_v_format)) {
+    __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_format; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_11 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++;
+    } else {
+      __pyx_t_11 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_11) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_11);
+    }
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_11;
+    __pyx_t_11 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":699
+ *         # check: format fields are defined
+ *         for f in format:
+ *             if f not in self._format: self.error(line,self.FORMAT_NOT_DEFINED, f)             # <<<<<<<<<<<<<<
+ * 
+ *         # convert v3.3 alleles
+ */
+    __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_8 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_11, __pyx_v_f))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+    if (__pyx_t_8) {
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__FORMAT_NOT_DEFINED); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
+      __Pyx_GIVEREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_f);
+      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_f);
+      __Pyx_GIVEREF(__pyx_v_f);
+      __pyx_t_10 = 0;
+      __pyx_t_10 = PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      goto __pyx_L52;
+    }
+    __pyx_L52:;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":702
+ * 
+ *         # convert v3.3 alleles
+ *         if self._version == 33:             # <<<<<<<<<<<<<<
+ *             if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+ *             newalts = []
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_10 = PyObject_RichCompare(__pyx_t_2, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  if (__pyx_t_8) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":703
+ *         # convert v3.3 alleles
+ *         if self._version == 33:
+ *             if len(ref) != 1: self.error(line,self.V33_BAD_REF)             # <<<<<<<<<<<<<<
+ *             newalts = []
+ *             have_deletions = False
+ */
+    __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = (__pyx_t_5 != 1);
+    if (__pyx_t_8) {
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__V33_BAD_REF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L54;
+    }
+    __pyx_L54:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":704
+ *         if self._version == 33:
+ *             if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+ *             newalts = []             # <<<<<<<<<<<<<<
+ *             have_deletions = False
+ *             for a in alt:
+ */
+    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(((PyObject *)__pyx_v_newalts));
+    __pyx_v_newalts = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":705
+ *             if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+ *             newalts = []
+ *             have_deletions = False             # <<<<<<<<<<<<<<
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ */
+    __pyx_v_have_deletions = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":706
+ *             newalts = []
+ *             have_deletions = False
+ *             for a in alt:             # <<<<<<<<<<<<<<
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ */
+    if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+      __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+      } else {
+        __pyx_t_9 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_9) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_9);
+      }
+      __Pyx_DECREF(__pyx_v_a);
+      __pyx_v_a = __pyx_t_9;
+      __pyx_t_9 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":707
+ *             have_deletions = False
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference             # <<<<<<<<<<<<<<
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ */
+      __pyx_t_4 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = (__pyx_t_4 == 1);
+      if (__pyx_t_8) {
+        __pyx_t_9 = PySequence_GetSlice(__pyx_v_ref, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_10 = PyNumber_Add(__pyx_v_a, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_a);
+        __pyx_v_a = __pyx_t_10;
+        __pyx_t_10 = 0;
+        goto __pyx_L57;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":708
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference             # <<<<<<<<<<<<<<
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True
+ */
+      __pyx_t_10 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__startswith); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(((PyObject *)__pyx_n_s__I));
+      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_n_s__I));
+      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__I));
+      __pyx_t_11 = PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      if (__pyx_t_8) {
+        __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __pyx_t_9 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_10 = PyNumber_Add(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PySequence_GetSlice(__pyx_v_ref, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_11 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_11);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_v_a);
+        __pyx_v_a = __pyx_t_11;
+        __pyx_t_11 = 0;
+        goto __pyx_L57;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":709
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>             # <<<<<<<<<<<<<<
+ *                     have_deletions = True
+ *                     try:
+ */
+      __pyx_t_11 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__startswith); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(((PyObject *)__pyx_n_s__D));
+      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_n_s__D));
+      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__D));
+      __pyx_t_10 = PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      if (__pyx_t_8) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":710
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True             # <<<<<<<<<<<<<<
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ */
+        __pyx_v_have_deletions = 1;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":711
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True
+ *                     try:             # <<<<<<<<<<<<<<
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary
+ */
+        {
+          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+          __Pyx_XGOTREF(__pyx_save_exc_type);
+          __Pyx_XGOTREF(__pyx_save_exc_value);
+          __Pyx_XGOTREF(__pyx_save_exc_tb);
+          /*try:*/ {
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":712
+ *                     have_deletions = True
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence             # <<<<<<<<<<<<<<
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ */
+            __pyx_t_10 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_GOTREF(__pyx_t_10);
+            __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L58_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(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_DECREF(__pyx_v_l);
+            __pyx_v_l = __pyx_t_10;
+            __pyx_t_10 = 0;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":713
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary             # <<<<<<<<<<<<<<
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns
+ */
+            __pyx_t_4 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_GOTREF(__pyx_t_10);
+            __pyx_t_9 = PyObject_RichCompare(__pyx_t_10, __pyx_v_l, Py_LT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_GOTREF(__pyx_t_9);
+            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            if (__pyx_t_8) {
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":714
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)             # <<<<<<<<<<<<<<
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ */
+              __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_9);
+              __pyx_t_4 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_10);
+              __pyx_t_11 = PyNumber_Add(__pyx_v_pos, __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __pyx_t_10 = PyNumber_Add(__pyx_v_pos, __pyx_v_l); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_10);
+              __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_12);
+              __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_3);
+              __Pyx_INCREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_chrom);
+              __Pyx_GIVEREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_11);
+              __Pyx_GIVEREF(__pyx_t_11);
+              PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_10);
+              __Pyx_GIVEREF(__pyx_t_10);
+              PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_12);
+              __Pyx_GIVEREF(__pyx_t_12);
+              __pyx_t_11 = 0;
+              __pyx_t_10 = 0;
+              __pyx_t_12 = 0;
+              __pyx_t_12 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_12);
+              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+              __Pyx_DECREF(__pyx_v_addns);
+              __pyx_v_addns = __pyx_t_12;
+              __pyx_t_12 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":715
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns             # <<<<<<<<<<<<<<
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ */
+              __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addns); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              __Pyx_GOTREF(__pyx_t_12);
+              __Pyx_DECREF(__pyx_v_ref);
+              __pyx_v_ref = __pyx_t_12;
+              __pyx_t_12 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":716
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns             # <<<<<<<<<<<<<<
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:
+ */
+              __Pyx_INCREF(__pyx_int_0);
+              __pyx_t_12 = __pyx_int_0;
+              if (likely(((PyObject *)__pyx_v_newalts) != Py_None)) {
+                __pyx_t_4 = 0; __pyx_t_3 = ((PyObject *)__pyx_v_newalts); __Pyx_INCREF(__pyx_t_3);
+              } else {
+                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+              }
+              for (;;) {
+                if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
+                __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_t_4++;
+                __Pyx_DECREF(__pyx_v_na);
+                __pyx_v_na = __pyx_t_9;
+                __pyx_t_9 = 0;
+                __Pyx_INCREF(__pyx_t_12);
+                __Pyx_DECREF(__pyx_v_i);
+                __pyx_v_i = __pyx_t_12;
+                __pyx_t_9 = PyNumber_Add(__pyx_t_12, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+                __Pyx_GOTREF(__pyx_t_9);
+                __Pyx_DECREF(__pyx_t_12);
+                __pyx_t_12 = __pyx_t_9;
+                __pyx_t_9 = 0;
+                __pyx_t_9 = PyNumber_Add(__pyx_v_na, __pyx_v_addns); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+                __Pyx_GOTREF(__pyx_t_9);
+                if (PyObject_SetItem(((PyObject *)__pyx_v_newalts), __pyx_v_i, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+              }
+              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+              goto __pyx_L66;
+            }
+            __pyx_L66:;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":717
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l             # <<<<<<<<<<<<<<
+ *                     except ValueError:
+ *                         s = a[1:]
+ */
+            __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_v_l); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __pyx_t_12 = PySequence_GetSlice(__pyx_v_ref, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L58_error;}
+            __Pyx_GOTREF(__pyx_t_12);
+            __Pyx_DECREF(__pyx_v_a);
+            __pyx_v_a = __pyx_t_12;
+            __pyx_t_12 = 0;
+          }
+          __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+          __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+          __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+          goto __pyx_L65_try_end;
+          __pyx_L58_error:;
+          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":718
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:             # <<<<<<<<<<<<<<
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ */
+          __pyx_t_16 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+          if (__pyx_t_16) {
+            __Pyx_AddTraceback("cvcf.VCF.parse_data");
+            if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_3, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __Pyx_GOTREF(__pyx_t_12);
+            __Pyx_GOTREF(__pyx_t_3);
+            __Pyx_GOTREF(__pyx_t_9);
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":719
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:
+ *                         s = a[1:]             # <<<<<<<<<<<<<<
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ */
+            __pyx_t_10 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_DECREF(__pyx_v_s);
+            __pyx_v_s = __pyx_t_10;
+            __pyx_t_10 = 0;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":720
+ *                     except ValueError:
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary             # <<<<<<<<<<<<<<
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ */
+            __pyx_t_4 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __pyx_t_17 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __pyx_t_8 = (__pyx_t_4 < __pyx_t_17);
+            if (__pyx_t_8) {
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":721
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)             # <<<<<<<<<<<<<<
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(line,self.V33_UNMATCHED_DELETION,
+ */
+              __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_10);
+              __pyx_t_17 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __pyx_t_1 = PyNumber_Add(__pyx_v_pos, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+              __pyx_t_17 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __pyx_t_18 = PyNumber_Add(__pyx_v_pos, __pyx_t_11); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_18);
+              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+              __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __pyx_t_19 = PyTuple_New(4); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_19);
+              __Pyx_INCREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
+              __Pyx_GIVEREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_1);
+              __Pyx_GIVEREF(__pyx_t_1);
+              PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_18);
+              __Pyx_GIVEREF(__pyx_t_18);
+              PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_11);
+              __Pyx_GIVEREF(__pyx_t_11);
+              __pyx_t_1 = 0;
+              __pyx_t_18 = 0;
+              __pyx_t_11 = 0;
+              __pyx_t_11 = PyObject_Call(__pyx_t_10, __pyx_t_19, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+              __Pyx_DECREF(__pyx_v_addns);
+              __pyx_v_addns = __pyx_t_11;
+              __pyx_t_11 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":722
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):             # <<<<<<<<<<<<<<
+ *                                 self.error(line,self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ */
+              __pyx_t_11 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__endswith); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_11);
+              __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_19);
+              __Pyx_INCREF(__pyx_v_addns);
+              PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_addns);
+              __Pyx_GIVEREF(__pyx_v_addns);
+              __pyx_t_10 = PyObject_Call(__pyx_t_11, __pyx_t_19, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_10);
+              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __pyx_t_6 = (!__pyx_t_8);
+              if (__pyx_t_6) {
+                __pyx_t_17 = PyObject_Length(__pyx_v_addns); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_10);
+                __pyx_t_19 = PyNumber_Multiply(((PyObject *)__pyx_n_s__N), __pyx_t_10); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(((PyObject *)__pyx_t_19));
+                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+                __pyx_t_10 = PyObject_RichCompare(__pyx_v_addns, ((PyObject *)__pyx_t_19), Py_NE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_10);
+                __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
+                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+                __pyx_t_15 = __pyx_t_8;
+              } else {
+                __pyx_t_15 = __pyx_t_6;
+              }
+              if (__pyx_t_15) {
+
+                /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":723
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(line,self.V33_UNMATCHED_DELETION,             # <<<<<<<<<<<<<<
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns
+ */
+                __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_10);
+                __pyx_t_19 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_65); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_19);
+
+                /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":724
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(line,self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))             # <<<<<<<<<<<<<<
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ */
+                __pyx_t_11 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_11);
+                __pyx_t_17 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __pyx_t_18 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_18);
+                __pyx_t_1 = PyNumber_Add(__pyx_v_pos, __pyx_t_18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+                __pyx_t_18 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_18);
+                __pyx_t_20 = PyTuple_New(4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_20);
+                __Pyx_INCREF(__pyx_v_chrom);
+                PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_chrom);
+                __Pyx_GIVEREF(__pyx_v_chrom);
+                __Pyx_INCREF(__pyx_v_pos);
+                PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_v_pos);
+                __Pyx_GIVEREF(__pyx_v_pos);
+                PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_1);
+                __Pyx_GIVEREF(__pyx_t_1);
+                PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_t_18);
+                __Pyx_GIVEREF(__pyx_t_18);
+                __pyx_t_1 = 0;
+                __pyx_t_18 = 0;
+                __pyx_t_18 = PyObject_Call(__pyx_t_11, __pyx_t_20, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_18);
+                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+                __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_20);
+                __Pyx_INCREF(__pyx_v_a);
+                PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_a);
+                __Pyx_GIVEREF(__pyx_v_a);
+                PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_18);
+                __Pyx_GIVEREF(__pyx_t_18);
+                __pyx_t_18 = 0;
+                __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), __pyx_t_20); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+                __pyx_t_20 = PyTuple_New(3); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_20);
+                __Pyx_INCREF(__pyx_v_line);
+                PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_line);
+                __Pyx_GIVEREF(__pyx_v_line);
+                PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_19);
+                __Pyx_GIVEREF(__pyx_t_19);
+                PyTuple_SET_ITEM(__pyx_t_20, 2, ((PyObject *)__pyx_t_18));
+                __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
+                __pyx_t_19 = 0;
+                __pyx_t_18 = 0;
+                __pyx_t_18 = PyObject_Call(__pyx_t_10, __pyx_t_20, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_18);
+                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+                goto __pyx_L72;
+              }
+              __pyx_L72:;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":725
+ *                                 self.error(line,self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns             # <<<<<<<<<<<<<<
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ */
+              __pyx_t_18 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addns); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              __Pyx_GOTREF(__pyx_t_18);
+              __Pyx_DECREF(__pyx_v_ref);
+              __pyx_v_ref = __pyx_t_18;
+              __pyx_t_18 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":726
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns             # <<<<<<<<<<<<<<
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ *                 else:
+ */
+              __Pyx_INCREF(__pyx_int_0);
+              __pyx_t_18 = __pyx_int_0;
+              if (likely(((PyObject *)__pyx_v_newalts) != Py_None)) {
+                __pyx_t_17 = 0; __pyx_t_20 = ((PyObject *)__pyx_v_newalts); __Pyx_INCREF(__pyx_t_20);
+              } else {
+                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+              }
+              for (;;) {
+                if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_20)) break;
+                __pyx_t_10 = PyList_GET_ITEM(__pyx_t_20, __pyx_t_17); __Pyx_INCREF(__pyx_t_10); __pyx_t_17++;
+                __Pyx_DECREF(__pyx_v_na);
+                __pyx_v_na = __pyx_t_10;
+                __pyx_t_10 = 0;
+                __Pyx_INCREF(__pyx_t_18);
+                __Pyx_DECREF(__pyx_v_i);
+                __pyx_v_i = __pyx_t_18;
+                __pyx_t_10 = PyNumber_Add(__pyx_t_18, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_10);
+                __Pyx_DECREF(__pyx_t_18);
+                __pyx_t_18 = __pyx_t_10;
+                __pyx_t_10 = 0;
+                __pyx_t_10 = PyNumber_Add(__pyx_v_na, __pyx_v_addns); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_GOTREF(__pyx_t_10);
+                if (PyObject_SetItem(((PyObject *)__pyx_v_newalts), __pyx_v_i, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              }
+              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+              goto __pyx_L71;
+            }
+            __pyx_L71:;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":727
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[len(s):]        # new deletion, deleting from pos             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.error(line,self.V33_BAD_ALLELE)
+ */
+            __pyx_t_17 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __pyx_t_18 = PySequence_GetSlice(__pyx_v_ref, __pyx_t_17, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L60_except_error;}
+            __Pyx_GOTREF(__pyx_t_18);
+            __Pyx_DECREF(__pyx_v_a);
+            __pyx_v_a = __pyx_t_18;
+            __pyx_t_18 = 0;
+            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            goto __pyx_L59_exception_handled;
+          }
+          __pyx_L60_except_error:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          goto __pyx_L1_error;
+          __pyx_L59_exception_handled:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          __pyx_L65_try_end:;
+        }
+        goto __pyx_L57;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":729
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ *                 else:
+ *                     self.error(line,self.V33_BAD_ALLELE)             # <<<<<<<<<<<<<<
+ *                 newalts.append(a)
+ *             alt = newalts
+ */
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__V33_BAD_ALLELE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_3);
+        __Pyx_GIVEREF(__pyx_t_3);
+        __pyx_t_3 = 0;
+        __pyx_t_3 = PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      }
+      __pyx_L57:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":730
+ *                 else:
+ *                     self.error(line,self.V33_BAD_ALLELE)
+ *                 newalts.append(a)             # <<<<<<<<<<<<<<
+ *             alt = newalts
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ */
+      if (unlikely(__pyx_v_newalts == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      }
+      __pyx_t_16 = PyList_Append(((PyObject *)__pyx_v_newalts), __pyx_v_a); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":731
+ *                     self.error(line,self.V33_BAD_ALLELE)
+ *                 newalts.append(a)
+ *             alt = newalts             # <<<<<<<<<<<<<<
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:
+ */
+    __Pyx_INCREF(((PyObject *)__pyx_v_newalts));
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = ((PyObject *)__pyx_v_newalts);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":733
+ *             alt = newalts
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:             # <<<<<<<<<<<<<<
+ *                 if pos == 0:
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ */
+    if (__pyx_v_have_deletions) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":734
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:
+ *                 if pos == 0:             # <<<<<<<<<<<<<<
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ */
+      __pyx_t_2 = PyObject_RichCompare(__pyx_v_pos, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (__pyx_t_15) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":736
+ *                 if pos == 0:
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)             # <<<<<<<<<<<<<<
+ *                     ref += addn
+ *                     alt = [allele+addn for allele in alt]
+ */
+        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_12 = PyNumber_Add(__pyx_v_pos, __pyx_t_3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_9 = PyNumber_Add(__pyx_v_pos, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_3 = PyNumber_Add(__pyx_t_9, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = PyTuple_New(4); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_INCREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_chrom);
+        __Pyx_GIVEREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_12);
+        __Pyx_GIVEREF(__pyx_t_12);
+        PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_3);
+        __Pyx_GIVEREF(__pyx_t_3);
+        PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_9);
+        __pyx_t_12 = 0;
+        __pyx_t_3 = 0;
+        __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_2, __pyx_t_18, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __Pyx_DECREF(__pyx_v_addn);
+        __pyx_v_addn = __pyx_t_9;
+        __pyx_t_9 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":737
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ *                     ref += addn             # <<<<<<<<<<<<<<
+ *                     alt = [allele+addn for allele in alt]
+ *                 else:
+ */
+        __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addn); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_9;
+        __pyx_t_9 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":738
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ *                     ref += addn
+ *                     alt = [allele+addn for allele in alt]             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ */
+        __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+        if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+          __pyx_t_5 = 0; __pyx_t_18 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_18);
+        } else {
+          __pyx_t_5 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+        }
+        for (;;) {
+          if (likely(PyList_CheckExact(__pyx_t_18))) {
+            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_18)) break;
+            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+          } else if (likely(PyTuple_CheckExact(__pyx_t_18))) {
+            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_18)) break;
+            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+          } else {
+            __pyx_t_2 = PyIter_Next(__pyx_t_18);
+            if (!__pyx_t_2) {
+              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              break;
+            }
+            __Pyx_GOTREF(__pyx_t_2);
+          }
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_2;
+          __pyx_t_2 = 0;
+          __pyx_t_2 = PyNumber_Add(__pyx_v_allele, __pyx_v_addn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_2);
+          if (unlikely(PyList_Append(__pyx_t_9, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_9));
+        __Pyx_DECREF(__pyx_v_alt);
+        __pyx_v_alt = ((PyObject *)__pyx_t_9);
+        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+        goto __pyx_L76;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":740
+ *                     alt = [allele+addn for allele in alt]
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)             # <<<<<<<<<<<<<<
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]
+ */
+        __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = PyNumber_Subtract(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_INCREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_chrom);
+        __Pyx_GIVEREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_18);
+        __Pyx_GIVEREF(__pyx_t_18);
+        __Pyx_INCREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_pos);
+        __Pyx_GIVEREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_18 = 0;
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_v_addn);
+        __pyx_v_addn = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":741
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ *                     ref = addn + ref             # <<<<<<<<<<<<<<
+ *                     alt = [addn + allele for allele in alt]
+ *                     pos -= 1
+ */
+        __pyx_t_2 = PyNumber_Add(__pyx_v_addn, __pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":742
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]             # <<<<<<<<<<<<<<
+ *                     pos -= 1
+ *         else:
+ */
+        __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+          __pyx_t_5 = 0; __pyx_t_3 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_3);
+        } else {
+          __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+        }
+        for (;;) {
+          if (likely(PyList_CheckExact(__pyx_t_3))) {
+            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
+            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+          } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
+          } else {
+            __pyx_t_9 = PyIter_Next(__pyx_t_3);
+            if (!__pyx_t_9) {
+              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              break;
+            }
+            __Pyx_GOTREF(__pyx_t_9);
+          }
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_9;
+          __pyx_t_9 = 0;
+          __pyx_t_9 = PyNumber_Add(__pyx_v_addn, __pyx_v_allele); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_2));
+        __Pyx_DECREF(__pyx_v_alt);
+        __pyx_v_alt = ((PyObject *)__pyx_t_2);
+        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":743
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]
+ *                     pos -= 1             # <<<<<<<<<<<<<<
+ *         else:
+ *             # format v4.0 -- just check for nucleotides
+ */
+        __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_pos);
+        __pyx_v_pos = __pyx_t_2;
+        __pyx_t_2 = 0;
+      }
+      __pyx_L76:;
+      goto __pyx_L75;
+    }
+    __pyx_L75:;
+    goto __pyx_L53;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":746
+ *         else:
+ *             # format v4.0 -- just check for nucleotides
+ *             for allele in alt:             # <<<<<<<<<<<<<<
+ *                 if not alleleRegEx.match(allele):
+ *                     self.error(line,self.V40_BAD_ALLELE,allele)
+ */
+    if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+      __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+      } else {
+        __pyx_t_3 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_3) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_3);
+      }
+      __Pyx_DECREF(__pyx_v_allele);
+      __pyx_v_allele = __pyx_t_3;
+      __pyx_t_3 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":747
+ *             # format v4.0 -- just check for nucleotides
+ *             for allele in alt:
+ *                 if not alleleRegEx.match(allele):             # <<<<<<<<<<<<<<
+ *                     self.error(line,self.V40_BAD_ALLELE,allele)
+ * 
+ */
+      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__alleleRegEx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_9 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__match); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __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 = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_allele);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_allele);
+      __Pyx_GIVEREF(__pyx_v_allele);
+      __pyx_t_18 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      __pyx_t_6 = (!__pyx_t_15);
+      if (__pyx_t_6) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":748
+ *             for allele in alt:
+ *                 if not alleleRegEx.match(allele):
+ *                     self.error(line,self.V40_BAD_ALLELE,allele)             # <<<<<<<<<<<<<<
+ * 
+ *         # check for leading nucleotide in indel calls
+ */
+        __pyx_t_18 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__V40_BAD_ALLELE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
+        __Pyx_GIVEREF(__pyx_t_3);
+        __Pyx_INCREF(__pyx_v_allele);
+        PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_allele);
+        __Pyx_GIVEREF(__pyx_v_allele);
+        __pyx_t_3 = 0;
+        __pyx_t_3 = PyObject_Call(__pyx_t_18, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        goto __pyx_L83;
+      }
+      __pyx_L83:;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __pyx_L53:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":751
+ * 
+ *         # check for leading nucleotide in indel calls
+ *         for allele in alt:             # <<<<<<<<<<<<<<
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+ */
+  if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+    __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+    } else {
+      __pyx_t_3 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_3) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    __Pyx_DECREF(__pyx_v_allele);
+    __pyx_v_allele = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":752
+ *         # check for leading nucleotide in indel calls
+ *         for allele in alt:
+ *             if len(allele) != len(ref):             # <<<<<<<<<<<<<<
+ *                 if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ */
+    __pyx_t_17 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = (__pyx_t_17 != __pyx_t_4);
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":753
+ *         for allele in alt:
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)             # <<<<<<<<<<<<<<
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ *                     self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)
+ */
+      __pyx_t_4 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = (__pyx_t_4 == 0);
+      if (__pyx_t_6) {
+        __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ZERO_LENGTH_ALLELE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_9);
+        __Pyx_GIVEREF(__pyx_t_9);
+        __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_3, __pyx_t_18, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        goto __pyx_L87;
+      }
+      __pyx_L87:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":754
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():             # <<<<<<<<<<<<<<
+ *                     self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)
+ * 
+ */
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_18 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__upper); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_Call(__pyx_t_18, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_allele, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_18, __pyx_n_s__upper); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      __pyx_t_18 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_RichCompare(__pyx_t_9, __pyx_t_18, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      if (__pyx_t_6) {
+        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_allele, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_9 = PyNumber_Add(__pyx_t_3, __pyx_t_18); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __pyx_t_18 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__upper); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_18, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __pyx_t_15 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_9, ((PyObject *)__pyx_n_s__N)))); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_8 = __pyx_t_15;
+      } else {
+        __pyx_t_8 = __pyx_t_6;
+      }
+      if (__pyx_t_8) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":755
+ *                 if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ *                     self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)             # <<<<<<<<<<<<<<
+ * 
+ *         # trim trailing bases in alleles
+ */
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_67); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_18);
+        __Pyx_GIVEREF(__pyx_t_18);
+        __pyx_t_18 = 0;
+        __pyx_t_18 = PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        goto __pyx_L88;
+      }
+      __pyx_L88:;
+      goto __pyx_L86;
+    }
+    __pyx_L86:;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":758
+ * 
+ *         # trim trailing bases in alleles
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):             # <<<<<<<<<<<<<<
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break
+ */
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_builtin_len);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_len);
+  __Pyx_GIVEREF(__pyx_builtin_len);
+  __Pyx_INCREF(__pyx_v_alt);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_alt);
+  __Pyx_GIVEREF(__pyx_v_alt);
+  __pyx_t_18 = PyObject_Call(__pyx_builtin_map, __pyx_t_2, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  __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 = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_18);
+  __Pyx_GIVEREF(__pyx_t_18);
+  __pyx_t_18 = 0;
+  __pyx_t_18 = PyObject_Call(__pyx_builtin_min, __pyx_t_2, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_9 = PyObject_RichCompare(__pyx_t_18, __pyx_t_3, Py_LT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  if (__pyx_t_8) {
+    __Pyx_INCREF(__pyx_t_18);
+    __pyx_t_2 = __pyx_t_18;
+  } else {
+    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_2 = __pyx_t_9;
+    __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+  __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_t_18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_5 = 0; __pyx_t_18 = __pyx_t_2; __Pyx_INCREF(__pyx_t_18);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_18);
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_18))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_18)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_18))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_18)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_18);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_i);
+    __pyx_v_i = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":759
+ *         # trim trailing bases in alleles
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():             # <<<<<<<<<<<<<<
+ *                 break
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+ */
+    __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+      __pyx_t_4 = 0; __pyx_t_9 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_9);
+    } else {
+      __pyx_t_4 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_9))) {
+        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_9)) break;
+        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_9))) {
+        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
+        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+      } else {
+        __pyx_t_3 = PyIter_Next(__pyx_t_9);
+        if (!__pyx_t_3) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_3);
+      }
+      __Pyx_DECREF(__pyx_8genexpr0__pyx_v_allele);
+      __pyx_8genexpr0__pyx_v_allele = __pyx_t_3;
+      __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_8genexpr0__pyx_v_allele, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_12 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__upper); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      if (unlikely(PySet_Add(__pyx_t_2, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __pyx_t_4 = PySet_Size(((PyObject *)__pyx_t_2)); 
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_8 = (__pyx_t_4 > 1);
+    if (!__pyx_t_8) {
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ref, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_9 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__upper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_alt, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_9, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__upper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __pyx_t_15 = __pyx_t_6;
+    } else {
+      __pyx_t_15 = __pyx_t_8;
+    }
+    if (__pyx_t_15) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":760
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break             # <<<<<<<<<<<<<<
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+ * 
+ */
+      goto __pyx_L90_break;
+      goto __pyx_L91;
+    }
+    __pyx_L91:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":761
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]             # <<<<<<<<<<<<<<
+ * 
+ *         # left-align alleles, if a reference is available
+ */
+    __pyx_t_9 = PySequence_GetSlice(__pyx_v_ref, 0, -1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+      __pyx_t_4 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+    } else {
+      __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_12); __pyx_t_4++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_12); __pyx_t_4++;
+      } else {
+        __pyx_t_12 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_12) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_12);
+      }
+      __Pyx_DECREF(__pyx_v_allele);
+      __pyx_v_allele = __pyx_t_12;
+      __pyx_t_12 = 0;
+      __pyx_t_12 = PySequence_GetSlice(__pyx_v_allele, 0, -1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      if (unlikely(PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_12))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = ((PyObject *)__pyx_t_3);
+    __Pyx_INCREF(__pyx_t_2);
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_ref);
+    __pyx_v_ref = __pyx_t_9;
+    __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = __pyx_t_2;
+    __pyx_t_2 = 0;
+  }
+  __pyx_L90_break:;
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":764
+ * 
+ *         # left-align alleles, if a reference is available
+ *         if self._leftalign and self._reference:             # <<<<<<<<<<<<<<
+ *             while left < pos:
+ *                 movable = True
+ */
+  __pyx_t_18 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___leftalign); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+  if (__pyx_t_15) {
+    __pyx_t_18 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_18);
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+    __pyx_t_6 = __pyx_t_8;
+  } else {
+    __pyx_t_6 = __pyx_t_15;
+  }
+  if (__pyx_t_6) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":765
+ *         # left-align alleles, if a reference is available
+ *         if self._leftalign and self._reference:
+ *             while left < pos:             # <<<<<<<<<<<<<<
+ *                 movable = True
+ *                 for allele in alt:
+ */
+    while (1) {
+      __pyx_t_18 = PyObject_RichCompare(__pyx_v_left, __pyx_v_pos, Py_LT); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      if (!__pyx_t_6) break;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":766
+ *         if self._leftalign and self._reference:
+ *             while left < pos:
+ *                 movable = True             # <<<<<<<<<<<<<<
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):
+ */
+      __pyx_v_movable = 1;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":767
+ *             while left < pos:
+ *                 movable = True
+ *                 for allele in alt:             # <<<<<<<<<<<<<<
+ *                     if len(allele) > len(ref):
+ *                         longest, shortest = allele, ref
+ */
+      if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+        __pyx_t_5 = 0; __pyx_t_18 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_18);
+      } else {
+        __pyx_t_5 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+      }
+      for (;;) {
+        if (likely(PyList_CheckExact(__pyx_t_18))) {
+          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_18)) break;
+          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+        } else if (likely(PyTuple_CheckExact(__pyx_t_18))) {
+          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_18)) break;
+          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+        } else {
+          __pyx_t_2 = PyIter_Next(__pyx_t_18);
+          if (!__pyx_t_2) {
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            break;
+          }
+          __Pyx_GOTREF(__pyx_t_2);
+        }
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":768
+ *                 movable = True
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):             # <<<<<<<<<<<<<<
+ *                         longest, shortest = allele, ref
+ *                     else:
+ */
+        __pyx_t_4 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_17 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = (__pyx_t_4 > __pyx_t_17);
+        if (__pyx_t_6) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":769
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):
+ *                         longest, shortest = allele, ref             # <<<<<<<<<<<<<<
+ *                     else:
+ *                         longest, shortest = ref, allele
+ */
+          __pyx_t_2 = __pyx_v_allele;
+          __Pyx_INCREF(__pyx_t_2);
+          __pyx_t_9 = __pyx_v_ref;
+          __Pyx_INCREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_v_longest);
+          __pyx_v_longest = __pyx_t_2;
+          __pyx_t_2 = 0;
+          __Pyx_DECREF(__pyx_v_shortest);
+          __pyx_v_shortest = __pyx_t_9;
+          __pyx_t_9 = 0;
+          goto __pyx_L101;
+        }
+        /*else*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":771
+ *                         longest, shortest = allele, ref
+ *                     else:
+ *                         longest, shortest = ref, allele             # <<<<<<<<<<<<<<
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False
+ */
+          __pyx_t_9 = __pyx_v_ref;
+          __Pyx_INCREF(__pyx_t_9);
+          __pyx_t_2 = __pyx_v_allele;
+          __Pyx_INCREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_v_longest);
+          __pyx_v_longest = __pyx_t_9;
+          __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_v_shortest);
+          __pyx_v_shortest = __pyx_t_2;
+          __pyx_t_2 = 0;
+        }
+        __pyx_L101:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":772
+ *                     else:
+ *                         longest, shortest = ref, allele
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():             # <<<<<<<<<<<<<<
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ */
+        __pyx_t_17 = PyObject_Length(__pyx_v_longest); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = (__pyx_t_17 == __pyx_t_4);
+        if (!__pyx_t_6) {
+          __pyx_t_4 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PySequence_GetSlice(__pyx_v_longest, 0, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_2);
+          __pyx_t_9 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__upper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+          __pyx_t_2 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_2);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __pyx_t_9 = PyObject_GetAttr(__pyx_v_shortest, __pyx_n_s__upper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_3 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __pyx_t_8 = __pyx_t_15;
+        } else {
+          __pyx_t_8 = __pyx_t_6;
+        }
+        if (__pyx_t_8) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":773
+ *                         longest, shortest = ref, allele
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False             # <<<<<<<<<<<<<<
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False
+ */
+          __pyx_v_movable = 0;
+          goto __pyx_L102;
+        }
+        __pyx_L102:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":774
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():             # <<<<<<<<<<<<<<
+ *                         movable = False
+ *                 if not movable:
+ */
+        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_longest, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__upper); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_4 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_17 = (__pyx_t_4 - 1);
+        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_longest, __pyx_t_17, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__upper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __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 = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, __pyx_t_3, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        if (__pyx_t_8) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":775
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False             # <<<<<<<<<<<<<<
+ *                 if not movable:
+ *                     break
+ */
+          __pyx_v_movable = 0;
+          goto __pyx_L103;
+        }
+        __pyx_L103:;
+      }
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":776
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False
+ *                 if not movable:             # <<<<<<<<<<<<<<
+ *                     break
+ *                 ref = ref[:-1]
+ */
+      __pyx_t_8 = (!__pyx_v_movable);
+      if (__pyx_t_8) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":777
+ *                         movable = False
+ *                 if not movable:
+ *                     break             # <<<<<<<<<<<<<<
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]
+ */
+        goto __pyx_L98_break;
+        goto __pyx_L104;
+      }
+      __pyx_L104:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":778
+ *                 if not movable:
+ *                     break
+ *                 ref = ref[:-1]             # <<<<<<<<<<<<<<
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ */
+      __pyx_t_18 = PySequence_GetSlice(__pyx_v_ref, 0, -1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = __pyx_t_18;
+      __pyx_t_18 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":779
+ *                     break
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]             # <<<<<<<<<<<<<<
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ */
+      __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+      if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+        __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+      } else {
+        __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+      }
+      for (;;) {
+        if (likely(PyList_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+        } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+        } else {
+          __pyx_t_3 = PyIter_Next(__pyx_t_2);
+          if (!__pyx_t_3) {
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            break;
+          }
+          __Pyx_GOTREF(__pyx_t_3);
+        }
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_3;
+        __pyx_t_3 = 0;
+        __pyx_t_3 = PySequence_GetSlice(__pyx_v_allele, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        if (unlikely(PyList_Append(__pyx_t_18, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_INCREF(((PyObject *)__pyx_t_18));
+      __Pyx_DECREF(__pyx_v_alt);
+      __pyx_v_alt = ((PyObject *)__pyx_t_18);
+      __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":780
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:             # <<<<<<<<<<<<<<
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ */
+      __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+      if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+        __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+      } else {
+        __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+      }
+      for (;;) {
+        if (likely(PyList_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+        } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+        } else {
+          __pyx_t_3 = PyIter_Next(__pyx_t_2);
+          if (!__pyx_t_3) {
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            break;
+          }
+          __Pyx_GOTREF(__pyx_t_3);
+        }
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_3;
+        __pyx_t_3 = 0;
+        __pyx_t_17 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_17); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        if (unlikely(PyList_Append(__pyx_t_18, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      }
+      __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 = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_t_18));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_18));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
+      __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
+      __pyx_t_18 = PyObject_Call(__pyx_builtin_min, __pyx_t_2, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_RichCompare(__pyx_t_18, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (!__pyx_t_8) {
+        __pyx_t_5 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = (__pyx_t_5 == 0);
+        __pyx_t_15 = __pyx_t_6;
+      } else {
+        __pyx_t_15 = __pyx_t_8;
+      }
+      if (__pyx_t_15) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":781
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref             # <<<<<<<<<<<<<<
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ *                     pos -= 1
+ */
+        __pyx_t_2 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_18 = PyNumber_Subtract(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_GetItem(__pyx_v_faref_leftflank, __pyx_t_18); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __pyx_t_18 = PyNumber_Add(__pyx_t_2, __pyx_v_ref); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_18;
+        __pyx_t_18 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":782
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]             # <<<<<<<<<<<<<<
+ *                     pos -= 1
+ * 
+ */
+        __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+        if (PyList_CheckExact(__pyx_v_alt) || PyTuple_CheckExact(__pyx_v_alt)) {
+          __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_alt; __Pyx_INCREF(__pyx_t_2);
+        } else {
+          __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_alt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_2);
+        }
+        for (;;) {
+          if (likely(PyList_CheckExact(__pyx_t_2))) {
+            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+          } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
+          } else {
+            __pyx_t_3 = PyIter_Next(__pyx_t_2);
+            if (!__pyx_t_3) {
+              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              break;
+            }
+            __Pyx_GOTREF(__pyx_t_3);
+          }
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_3;
+          __pyx_t_3 = 0;
+          __pyx_t_3 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __pyx_t_9 = PyNumber_Subtract(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __pyx_t_3 = PyObject_GetItem(__pyx_v_faref_leftflank, __pyx_t_9); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __pyx_t_9 = PyNumber_Add(__pyx_t_3, __pyx_v_allele); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          if (unlikely(PyList_Append(__pyx_t_18, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_18));
+        __Pyx_DECREF(__pyx_v_alt);
+        __pyx_v_alt = ((PyObject *)__pyx_t_18);
+        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":783
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ *                     pos -= 1             # <<<<<<<<<<<<<<
+ * 
+ *         # parse sample columns
+ */
+        __pyx_t_18 = PyNumber_InPlaceSubtract(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_v_pos);
+        __pyx_v_pos = __pyx_t_18;
+        __pyx_t_18 = 0;
+        goto __pyx_L107;
+      }
+      __pyx_L107:;
+    }
+    __pyx_L98_break:;
+    goto __pyx_L96;
+  }
+  __pyx_L96:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":786
+ * 
+ *         # parse sample columns
+ *         samples = []             # <<<<<<<<<<<<<<
+ *         for sample in cols[9:]:
+ *             dict = {}
+ */
+  __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+  __Pyx_DECREF(((PyObject *)__pyx_v_samples));
+  __pyx_v_samples = __pyx_t_18;
+  __pyx_t_18 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":787
+ *         # parse sample columns
+ *         samples = []
+ *         for sample in cols[9:]:             # <<<<<<<<<<<<<<
+ *             dict = {}
+ *             values = sample.split(':')
+ */
+  __pyx_t_18 = PySequence_GetSlice(__pyx_v_cols, 9, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  if (PyList_CheckExact(__pyx_t_18) || PyTuple_CheckExact(__pyx_t_18)) {
+    __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_18; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_18); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_18 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_18); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_18 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_18); __pyx_t_5++;
+    } else {
+      __pyx_t_18 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_18) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_18);
+    }
+    __Pyx_DECREF(__pyx_v_sample);
+    __pyx_v_sample = __pyx_t_18;
+    __pyx_t_18 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":788
+ *         samples = []
+ *         for sample in cols[9:]:
+ *             dict = {}             # <<<<<<<<<<<<<<
+ *             values = sample.split(':')
+ *             if len(values) > len(format):
+ */
+    __pyx_t_18 = PyDict_New(); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+    __Pyx_DECREF(((PyObject *)__pyx_v_dict));
+    __pyx_v_dict = __pyx_t_18;
+    __pyx_t_18 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":789
+ *         for sample in cols[9:]:
+ *             dict = {}
+ *             values = sample.split(':')             # <<<<<<<<<<<<<<
+ *             if len(values) > len(format):
+ *                 self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+ */
+    __pyx_t_18 = PyObject_GetAttr(__pyx_v_sample, __pyx_n_s__split); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_18);
+    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_3 = PyObject_Call(__pyx_t_18, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    __Pyx_DECREF(__pyx_v_values);
+    __pyx_v_values = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":790
+ *             dict = {}
+ *             values = sample.split(':')
+ *             if len(values) > len(format):             # <<<<<<<<<<<<<<
+ *                 self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+ *             for idx in range(len(format)):
+ */
+    __pyx_t_17 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = (__pyx_t_17 > __pyx_t_4);
+    if (__pyx_t_15) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":791
+ *             values = sample.split(':')
+ *             if len(values) > len(format):
+ *                 self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))             # <<<<<<<<<<<<<<
+ *             for idx in range(len(format)):
+ *                 expected = self.get_expected(format[idx], self._format, alt)
+ */
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_4 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_18 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_18);
+      __pyx_t_4 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_12 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_20 = PyTuple_New(3); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18);
+      __Pyx_GIVEREF(__pyx_t_18);
+      __Pyx_INCREF(__pyx_v_sample);
+      PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_v_sample);
+      __Pyx_GIVEREF(__pyx_v_sample);
+      PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_12);
+      __Pyx_GIVEREF(__pyx_t_12);
+      __pyx_t_18 = 0;
+      __pyx_t_12 = 0;
+      __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_20); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      __pyx_t_20 = PyTuple_New(3); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      PyTuple_SET_ITEM(__pyx_t_20, 2, ((PyObject *)__pyx_t_12));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
+      __pyx_t_9 = 0;
+      __pyx_t_12 = 0;
+      __pyx_t_12 = PyObject_Call(__pyx_t_3, __pyx_t_20, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      goto __pyx_L114;
+    }
+    __pyx_L114:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":792
+ *             if len(values) > len(format):
+ *                 self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+ *             for idx in range(len(format)):             # <<<<<<<<<<<<<<
+ *                 expected = self.get_expected(format[idx], self._format, alt)
+ *                 if idx < len(values): value = values[idx]
+ */
+    __pyx_t_4 = PyObject_Length(__pyx_v_format); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_4; __pyx_t_17+=1) {
+      __pyx_v_idx = __pyx_t_17;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":793
+ *                 self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+ *             for idx in range(len(format)):
+ *                 expected = self.get_expected(format[idx], self._format, alt)             # <<<<<<<<<<<<<<
+ *                 if idx < len(values): value = values[idx]
+ *                 else:
+ */
+      __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__get_expected); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_20 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_20);
+      __Pyx_GIVEREF(__pyx_t_20);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_alt);
+      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_alt);
+      __Pyx_GIVEREF(__pyx_v_alt);
+      __pyx_t_20 = 0;
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_v_expected);
+      __pyx_v_expected = __pyx_t_3;
+      __pyx_t_3 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":794
+ *             for idx in range(len(format)):
+ *                 expected = self.get_expected(format[idx], self._format, alt)
+ *                 if idx < len(values): value = values[idx]             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     if expected == -1: value = "."
+ */
+      __pyx_t_21 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_15 = (__pyx_v_idx < __pyx_t_21);
+      if (__pyx_t_15) {
+        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_values, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_v_value);
+        __pyx_v_value = __pyx_t_3;
+        __pyx_t_3 = 0;
+        goto __pyx_L117;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":796
+ *                 if idx < len(values): value = values[idx]
+ *                 else:
+ *                     if expected == -1: value = "."             # <<<<<<<<<<<<<<
+ *                     else: value = ",".join(["."]*expected)
+ *                 dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+ */
+        __pyx_t_3 = PyObject_RichCompare(__pyx_v_expected, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        if (__pyx_t_15) {
+          __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+          __Pyx_DECREF(__pyx_v_value);
+          __pyx_v_value = ((PyObject *)__pyx_kp_s_6);
+          goto __pyx_L118;
+        }
+        /*else*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":797
+ *                 else:
+ *                     if expected == -1: value = "."
+ *                     else: value = ",".join(["."]*expected)             # <<<<<<<<<<<<<<
+ *                 dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+ *                 if expected != -1 and len(dict[format[idx]]) != expected:
+ */
+          __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+          __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+          PyList_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_kp_s_6));
+          __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+          __pyx_t_12 = PyNumber_Multiply(((PyObject *)__pyx_t_9), __pyx_v_expected); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_12);
+          __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 = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
+          __Pyx_GIVEREF(__pyx_t_12);
+          __pyx_t_12 = 0;
+          __pyx_t_12 = PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_12);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_v_value);
+          __pyx_v_value = __pyx_t_12;
+          __pyx_t_12 = 0;
+        }
+        __pyx_L118:;
+      }
+      __pyx_L117:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":798
+ *                     if expected == -1: value = "."
+ *                     else: value = ",".join(["."]*expected)
+ *                 dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)             # <<<<<<<<<<<<<<
+ *                 if expected != -1 and len(dict[format[idx]]) != expected:
+ *                     self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+ */
+      __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_formatdata); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_20 = PyTuple_New(4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_v_value);
+      PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_v_value);
+      __Pyx_GIVEREF(__pyx_v_value);
+      PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_line);
+      PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_v_line);
+      __Pyx_GIVEREF(__pyx_v_line);
+      __pyx_t_9 = 0;
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(__pyx_t_12, __pyx_t_20, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      __pyx_t_20 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      if (PyDict_SetItem(((PyObject *)__pyx_v_dict), __pyx_t_20, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":799
+ *                     else: value = ",".join(["."]*expected)
+ *                 dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+ *                 if expected != -1 and len(dict[format[idx]]) != expected:             # <<<<<<<<<<<<<<
+ *                     self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+ *                                "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+ */
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_expected, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      if (__pyx_t_15) {
+        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_20 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_3); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_20);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_21 = PyObject_Length(__pyx_t_20); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+        __pyx_t_20 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_20);
+        __pyx_t_3 = PyObject_RichCompare(__pyx_t_20, __pyx_v_expected, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_6 = __pyx_t_8;
+      } else {
+        __pyx_t_6 = __pyx_t_15;
+      }
+      if (__pyx_t_6) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":800
+ *                 dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+ *                 if expected != -1 and len(dict[format[idx]]) != expected:
+ *                     self.error(line,self.BAD_NUMBER_OF_PARAMETERS,             # <<<<<<<<<<<<<<
+ *                                "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+ *                     if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+ */
+        __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        __pyx_t_20 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_11); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_20);
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":801
+ *                 if expected != -1 and len(dict[format[idx]]) != expected:
+ *                     self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+ *                                "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))             # <<<<<<<<<<<<<<
+ *                     if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+ *                     dict[format[idx]] = dict[format[idx]][:expected]
+ */
+        __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_12);
+        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_9); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
+        __Pyx_GIVEREF(__pyx_t_12);
+        __Pyx_INCREF(__pyx_v_expected);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_expected);
+        __Pyx_GIVEREF(__pyx_v_expected);
+        PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_18);
+        __Pyx_GIVEREF(__pyx_t_18);
+        __pyx_t_12 = 0;
+        __pyx_t_18 = 0;
+        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_t_9); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_INCREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_line);
+        __Pyx_GIVEREF(__pyx_v_line);
+        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_20);
+        __Pyx_GIVEREF(__pyx_t_20);
+        PyTuple_SET_ITEM(__pyx_t_9, 2, ((PyObject *)__pyx_t_18));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
+        __pyx_t_20 = 0;
+        __pyx_t_18 = 0;
+        __pyx_t_18 = PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":802
+ *                     self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+ *                                "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+ *                     if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))             # <<<<<<<<<<<<<<
+ *                     dict[format[idx]] = dict[format[idx]][:expected]
+ *             samples.append( dict )
+ */
+        __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_18); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __pyx_t_21 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_18 = PyObject_RichCompare(__pyx_t_9, __pyx_v_expected, Py_LT); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        if (__pyx_t_6) {
+          __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+          __pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_18); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+          __pyx_t_18 = __Pyx_GetItemInt(__pyx_t_9, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+          PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_18);
+          __Pyx_GIVEREF(__pyx_t_18);
+          __pyx_t_18 = 0;
+          __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+          __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_18); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+          __pyx_t_21 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __pyx_t_18 = PyNumber_Subtract(__pyx_v_expected, __pyx_t_3); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __pyx_t_3 = PyNumber_Multiply(((PyObject *)__pyx_t_9), __pyx_t_18); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+          __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_18);
+          __pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_18); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_20);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          if (PyDict_SetItem(((PyObject *)__pyx_v_dict), __pyx_t_18, __pyx_t_20) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+          goto __pyx_L120;
+        }
+        __pyx_L120:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":803
+ *                                "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+ *                     if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+ *                     dict[format[idx]] = dict[format[idx]][:expected]             # <<<<<<<<<<<<<<
+ *             samples.append( dict )
+ * 
+ */
+        __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __pyx_t_20 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_dict), __pyx_t_18); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_20);
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        __pyx_t_21 = __Pyx_PyIndex_AsSsize_t(__pyx_v_expected); if (unlikely((__pyx_t_21 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_18 = PySequence_GetSlice(__pyx_t_20, 0, __pyx_t_21); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_18);
+        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+        __pyx_t_20 = __Pyx_GetItemInt(__pyx_v_format, __pyx_v_idx, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_20);
+        if (PyDict_SetItem(((PyObject *)__pyx_v_dict), __pyx_t_20, __pyx_t_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+        goto __pyx_L119;
+      }
+      __pyx_L119:;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":804
+ *                     if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+ *                     dict[format[idx]] = dict[format[idx]][:expected]
+ *             samples.append( dict )             # <<<<<<<<<<<<<<
+ * 
+ *         # done
+ */
+    if (unlikely(__pyx_v_samples == Py_None)) {
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    }
+    __pyx_t_16 = PyList_Append(((PyObject *)__pyx_v_samples), ((PyObject *)__pyx_v_dict)); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":807
+ * 
+ *         # done
+ *         d = {'chrom':chrom,             # <<<<<<<<<<<<<<
+ *              'pos':pos,      # return 0-based position
+ *              'id':id,
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__chrom), __pyx_v_chrom) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":808
+ *         # done
+ *         d = {'chrom':chrom,
+ *              'pos':pos,      # return 0-based position             # <<<<<<<<<<<<<<
+ *              'id':id,
+ *              'ref':ref,
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__pos), __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":809
+ *         d = {'chrom':chrom,
+ *              'pos':pos,      # return 0-based position
+ *              'id':id,             # <<<<<<<<<<<<<<
+ *              'ref':ref,
+ *              'alt':alt,
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__id), __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":810
+ *              'pos':pos,      # return 0-based position
+ *              'id':id,
+ *              'ref':ref,             # <<<<<<<<<<<<<<
+ *              'alt':alt,
+ *              'qual':qual,
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__ref), __pyx_v_ref) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":811
+ *              'id':id,
+ *              'ref':ref,
+ *              'alt':alt,             # <<<<<<<<<<<<<<
+ *              'qual':qual,
+ *              'filter':filter,
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__alt), __pyx_v_alt) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":812
+ *              'ref':ref,
+ *              'alt':alt,
+ *              'qual':qual,             # <<<<<<<<<<<<<<
+ *              'filter':filter,
+ *              'info':info,
+ */
+  __pyx_t_18 = PyFloat_FromDouble(__pyx_v_qual); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__qual), __pyx_t_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":813
+ *              'alt':alt,
+ *              'qual':qual,
+ *              'filter':filter,             # <<<<<<<<<<<<<<
+ *              'info':info,
+ *              'format':format}
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__filter), __pyx_v_filter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":814
+ *              'qual':qual,
+ *              'filter':filter,
+ *              'info':info,             # <<<<<<<<<<<<<<
+ *              'format':format}
+ *         for key,value in zip(self._samples,samples):
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__info), ((PyObject *)__pyx_v_info)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":815
+ *              'filter':filter,
+ *              'info':info,
+ *              'format':format}             # <<<<<<<<<<<<<<
+ *         for key,value in zip(self._samples,samples):
+ *             d[key] = value
+ */
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__format), __pyx_v_format) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_v_d));
+  __pyx_v_d = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":816
+ *              'info':info,
+ *              'format':format}
+ *         for key,value in zip(self._samples,samples):             # <<<<<<<<<<<<<<
+ *             d[key] = value
+ * 
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_INCREF(((PyObject *)__pyx_v_samples));
+  PyTuple_SET_ITEM(__pyx_t_18, 1, ((PyObject *)__pyx_v_samples));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_samples));
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_zip, __pyx_t_18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_5 = 0; __pyx_t_18 = __pyx_t_2; __Pyx_INCREF(__pyx_t_18);
+  } else {
+    __pyx_t_5 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_18);
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_18))) {
+      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_18)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_18))) {
+      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_18)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_18);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    if (PyTuple_CheckExact(__pyx_t_2) && likely(PyTuple_GET_SIZE(__pyx_t_2) == 2)) {
+      PyObject* tuple = __pyx_t_2;
+      __pyx_t_20 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_20);
+      __pyx_t_9 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_9);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_v_key);
+      __pyx_v_key = __pyx_t_20;
+      __pyx_t_20 = 0;
+      __Pyx_DECREF(__pyx_v_value);
+      __pyx_v_value = __pyx_t_9;
+      __pyx_t_9 = 0;
+    } else {
+      __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_20 = __Pyx_UnpackItem(__pyx_t_3, 0); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_3, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      if (__Pyx_EndUnpack(__pyx_t_3, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_v_key);
+      __pyx_v_key = __pyx_t_20;
+      __pyx_t_20 = 0;
+      __Pyx_DECREF(__pyx_v_value);
+      __pyx_v_value = __pyx_t_9;
+      __pyx_t_9 = 0;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":817
+ *              'format':format}
+ *         for key,value in zip(self._samples,samples):
+ *             d[key] = value             # <<<<<<<<<<<<<<
+ * 
+ *         return d
+ */
+    if (PyDict_SetItem(((PyObject *)__pyx_v_d), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":819
+ *             d[key] = value
+ * 
+ *         return d             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_d));
+  __pyx_r = ((PyObject *)__pyx_v_d);
+  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_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_18);
+  __Pyx_XDECREF(__pyx_t_19);
+  __Pyx_XDECREF(__pyx_t_20);
+  __Pyx_AddTraceback("cvcf.VCF.parse_data");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_cols);
+  __Pyx_DECREF(__pyx_v_chrom);
+  __Pyx_DECREF(__pyx_v_pos);
+  __Pyx_DECREF(__pyx_v_id);
+  __Pyx_DECREF(__pyx_v_ref);
+  __Pyx_DECREF(__pyx_v_c);
+  __Pyx_DECREF(__pyx_v_left);
+  __Pyx_DECREF(__pyx_v_faref_leftflank);
+  __Pyx_DECREF(__pyx_v_faref);
+  __Pyx_DECREF(__pyx_v_alt);
+  __Pyx_DECREF(__pyx_v_filter);
+  __Pyx_DECREF(__pyx_v_info);
+  __Pyx_DECREF(__pyx_v_blurp);
+  __Pyx_DECREF(__pyx_v_elts);
+  __Pyx_DECREF(__pyx_v_v);
+  __Pyx_DECREF(__pyx_v_format);
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_DECREF(__pyx_v_newalts);
+  __Pyx_DECREF(__pyx_v_a);
+  __Pyx_DECREF(__pyx_v_l);
+  __Pyx_DECREF(__pyx_v_addns);
+  __Pyx_DECREF(__pyx_v_i);
+  __Pyx_DECREF(__pyx_v_na);
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_DECREF(__pyx_v_addn);
+  __Pyx_DECREF(__pyx_v_allele);
+  __Pyx_DECREF(__pyx_v_longest);
+  __Pyx_DECREF(__pyx_v_shortest);
+  __Pyx_DECREF(__pyx_v_samples);
+  __Pyx_DECREF(__pyx_v_sample);
+  __Pyx_DECREF(__pyx_v_dict);
+  __Pyx_DECREF(__pyx_v_values);
+  __Pyx_DECREF(__pyx_v_expected);
+  __Pyx_DECREF(__pyx_v_value);
+  __Pyx_DECREF(__pyx_v_d);
+  __Pyx_DECREF(__pyx_v_key);
+  __Pyx_DECREF(__pyx_8genexpr0__pyx_v_allele);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":822
+ * 
+ * 
+ *     def write_data(self, stream, data):             # <<<<<<<<<<<<<<
+ *         required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+ *         for k in required:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_write_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_write_data = {__Pyx_NAMESTR("write_data"), (PyCFunction)__pyx_pf_4cvcf_3VCF_write_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_write_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_data = 0;
+  PyObject *__pyx_v_required;
+  PyObject *__pyx_v_k;
+  PyObject *__pyx_v_alt;
+  PyObject *__pyx_v_filter;
+  PyObject *__pyx_v_qual;
+  PyObject *__pyx_v_output;
+  PyObject *__pyx_v_s;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  int __pyx_t_12;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,&__pyx_n_s__data,0};
+  __Pyx_RefNannySetupContext("write_data");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write_data", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write_data", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+    __pyx_v_data = values[2];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 2);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("write_data", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.write_data");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_required = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_alt = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_filter = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_output = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":823
+ * 
+ *     def write_data(self, stream, data):
+ *         required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples             # <<<<<<<<<<<<<<
+ *         for k in required:
+ *             if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+ */
+  __pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__chrom));
+  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__chrom));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chrom));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__pos));
+  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__pos));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pos));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__id));
+  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__id));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__id));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ref));
+  PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__ref));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ref));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__alt));
+  PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__alt));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__alt));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__qual));
+  PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__qual));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qual));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__filter));
+  PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__filter));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filter));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__info));
+  PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__info));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__info));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__format));
+  PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__format));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__format));
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_t_1), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __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_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_required);
+  __pyx_v_required = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":824
+ *     def write_data(self, stream, data):
+ *         required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+ *         for k in required:             # <<<<<<<<<<<<<<
+ *             if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+ *         if data['alt'] == []: alt = "."
+ */
+  if (PyList_CheckExact(__pyx_v_required) || PyTuple_CheckExact(__pyx_v_required)) {
+    __pyx_t_4 = 0; __pyx_t_3 = __pyx_v_required; __Pyx_INCREF(__pyx_t_3);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_required); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_3);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_k);
+    __pyx_v_k = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":825
+ *         required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+ *         for k in required:
+ *             if k not in data: raise ValueError("Required key %s not found in data" % str(k))             # <<<<<<<<<<<<<<
+ *         if data['alt'] == []: alt = "."
+ *         else: alt = ",".join(data['alt'])
+ */
+    __pyx_t_5 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_v_data, __pyx_v_k))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_5) {
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(__pyx_v_k);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k);
+      __Pyx_GIVEREF(__pyx_v_k);
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_68), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__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 = 825; __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, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+  }
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":826
+ *         for k in required:
+ *             if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+ *         if data['alt'] == []: alt = "."             # <<<<<<<<<<<<<<
+ *         else: alt = ",".join(data['alt'])
+ *         if data['filter'] == None: filter = "."
+ */
+  __pyx_t_3 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__alt)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_t_2), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __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_2)); __pyx_t_2 = 0;
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_5) {
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = ((PyObject *)__pyx_kp_s_6);
+    goto __pyx_L9;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":827
+ *             if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+ *         if data['alt'] == []: alt = "."
+ *         else: alt = ",".join(data['alt'])             # <<<<<<<<<<<<<<
+ *         if data['filter'] == None: filter = "."
+ *         elif data['filter'] == []:
+ */
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__alt)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __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);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __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_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_alt);
+    __pyx_v_alt = __pyx_t_2;
+    __pyx_t_2 = 0;
+  }
+  __pyx_L9:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":828
+ *         if data['alt'] == []: alt = "."
+ *         else: alt = ",".join(data['alt'])
+ *         if data['filter'] == None: filter = "."             # <<<<<<<<<<<<<<
+ *         elif data['filter'] == []:
+ *             if self._version == 33: filter = "0"
+ */
+  __pyx_t_2 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__filter)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_5) {
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    __Pyx_DECREF(__pyx_v_filter);
+    __pyx_v_filter = ((PyObject *)__pyx_kp_s_6);
+    goto __pyx_L10;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":829
+ *         else: alt = ",".join(data['alt'])
+ *         if data['filter'] == None: filter = "."
+ *         elif data['filter'] == []:             # <<<<<<<<<<<<<<
+ *             if self._version == 33: filter = "0"
+ *             else: filter = "PASS"
+ */
+  __pyx_t_3 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__filter)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_t_2), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __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_2)); __pyx_t_2 = 0;
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_5) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":830
+ *         if data['filter'] == None: filter = "."
+ *         elif data['filter'] == []:
+ *             if self._version == 33: filter = "0"             # <<<<<<<<<<<<<<
+ *             else: filter = "PASS"
+ *         else: filter = ';'.join(data['filter'])
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_5) {
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s__0));
+      __Pyx_DECREF(__pyx_v_filter);
+      __pyx_v_filter = ((PyObject *)__pyx_kp_s__0);
+      goto __pyx_L11;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":831
+ *         elif data['filter'] == []:
+ *             if self._version == 33: filter = "0"
+ *             else: filter = "PASS"             # <<<<<<<<<<<<<<
+ *         else: filter = ';'.join(data['filter'])
+ *         if data['qual'] == -1: qual = "."
+ */
+      __Pyx_INCREF(((PyObject *)__pyx_n_s__PASS));
+      __Pyx_DECREF(__pyx_v_filter);
+      __pyx_v_filter = ((PyObject *)__pyx_n_s__PASS);
+    }
+    __pyx_L11:;
+    goto __pyx_L10;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":832
+ *             if self._version == 33: filter = "0"
+ *             else: filter = "PASS"
+ *         else: filter = ';'.join(data['filter'])             # <<<<<<<<<<<<<<
+ *         if data['qual'] == -1: qual = "."
+ *         else: qual = str(data['qual'])
+ */
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__filter)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __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 = 832; __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, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __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_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_v_filter);
+    __pyx_v_filter = __pyx_t_1;
+    __pyx_t_1 = 0;
+  }
+  __pyx_L10:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":833
+ *             else: filter = "PASS"
+ *         else: filter = ';'.join(data['filter'])
+ *         if data['qual'] == -1: qual = "."             # <<<<<<<<<<<<<<
+ *         else: qual = str(data['qual'])
+ * 
+ */
+  __pyx_t_1 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__qual)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __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 = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_5) {
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+    __Pyx_DECREF(__pyx_v_qual);
+    __pyx_v_qual = ((PyObject *)__pyx_kp_s_6);
+    goto __pyx_L12;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":834
+ *         else: filter = ';'.join(data['filter'])
+ *         if data['qual'] == -1: qual = "."
+ *         else: qual = str(data['qual'])             # <<<<<<<<<<<<<<
+ * 
+ *         output = [data['chrom'],
+ */
+    __pyx_t_3 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__qual)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __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 = 834; __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(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_qual);
+    __pyx_v_qual = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+  __pyx_L12:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":836
+ *         else: qual = str(data['qual'])
+ * 
+ *         output = [data['chrom'],             # <<<<<<<<<<<<<<
+ *                   str(data['pos']+1),   # change to 1-based position
+ *                   data['id'],
+ */
+  __pyx_t_3 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__chrom)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":837
+ * 
+ *         output = [data['chrom'],
+ *                   str(data['pos']+1),   # change to 1-based position             # <<<<<<<<<<<<<<
+ *                   data['id'],
+ *                   data['ref'],
+ */
+  __pyx_t_1 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__pos)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __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 = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":838
+ *         output = [data['chrom'],
+ *                   str(data['pos']+1),   # change to 1-based position
+ *                   data['id'],             # <<<<<<<<<<<<<<
+ *                   data['ref'],
+ *                   alt,
+ */
+  __pyx_t_1 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__id)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":839
+ *                   str(data['pos']+1),   # change to 1-based position
+ *                   data['id'],
+ *                   data['ref'],             # <<<<<<<<<<<<<<
+ *                   alt,
+ *                   qual,
+ */
+  __pyx_t_6 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__ref)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":843
+ *                   qual,
+ *                   filter,
+ *                   self.format_formatdata( data['info'], self._info, separator=";" ),             # <<<<<<<<<<<<<<
+ *                   self.format_formatdata( data['format'], self._format, value=False ) ]
+ * 
+ */
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__format_formatdata); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_8 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__info)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___info); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_9);
+  __pyx_t_8 = 0;
+  __pyx_t_9 = 0;
+  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+  if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__separator), ((PyObject *)__pyx_kp_s_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_t_7, __pyx_t_10, ((PyObject *)__pyx_t_9)); 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_t_7); __pyx_t_7 = 0;
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":844
+ *                   filter,
+ *                   self.format_formatdata( data['info'], self._info, separator=";" ),
+ *                   self.format_formatdata( data['format'], self._format, value=False ) ]             # <<<<<<<<<<<<<<
+ * 
+ *         for s in self._samples:
+ */
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__format_formatdata); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __pyx_t_10 = PyObject_GetItem(__pyx_v_data, ((PyObject *)__pyx_n_s__format)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  __pyx_t_10 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+  __pyx_t_10 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__value), __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __pyx_t_10 = PyEval_CallObjectWithKeywords(__pyx_t_9, __pyx_t_11, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+  __pyx_t_7 = PyList_New(9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyList_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyList_SET_ITEM(__pyx_t_7, 3, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  __Pyx_INCREF(__pyx_v_alt);
+  PyList_SET_ITEM(__pyx_t_7, 4, __pyx_v_alt);
+  __Pyx_GIVEREF(__pyx_v_alt);
+  __Pyx_INCREF(__pyx_v_qual);
+  PyList_SET_ITEM(__pyx_t_7, 5, __pyx_v_qual);
+  __Pyx_GIVEREF(__pyx_v_qual);
+  __Pyx_INCREF(__pyx_v_filter);
+  PyList_SET_ITEM(__pyx_t_7, 6, __pyx_v_filter);
+  __Pyx_GIVEREF(__pyx_v_filter);
+  PyList_SET_ITEM(__pyx_t_7, 7, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyList_SET_ITEM(__pyx_t_7, 8, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  __pyx_t_3 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_1 = 0;
+  __pyx_t_6 = 0;
+  __pyx_t_8 = 0;
+  __pyx_t_10 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_v_output));
+  __pyx_v_output = __pyx_t_7;
+  __pyx_t_7 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":846
+ *                   self.format_formatdata( data['format'], self._format, value=False ) ]
+ * 
+ *         for s in self._samples:             # <<<<<<<<<<<<<<
+ *             output.append( self.format_formatdata( data[s], self._format, key=False ) )
+ * 
+ */
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __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_4 = 0; __pyx_t_10 = __pyx_t_7; __Pyx_INCREF(__pyx_t_10);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+  }
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_10))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_10)) break;
+      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_4); __Pyx_INCREF(__pyx_t_7); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_10))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
+      __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_4); __Pyx_INCREF(__pyx_t_7); __pyx_t_4++;
+    } else {
+      __pyx_t_7 = PyIter_Next(__pyx_t_10);
+      if (!__pyx_t_7) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_7);
+    }
+    __Pyx_DECREF(__pyx_v_s);
+    __pyx_v_s = __pyx_t_7;
+    __pyx_t_7 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":847
+ * 
+ *         for s in self._samples:
+ *             output.append( self.format_formatdata( data[s], self._format, key=False ) )             # <<<<<<<<<<<<<<
+ * 
+ *         stream.write( "\t".join(output) + "\n" )
+ */
+    if (unlikely(__pyx_v_output == Py_None)) {
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    }
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__format_formatdata); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = PyObject_GetItem(__pyx_v_data, __pyx_v_s); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __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 = 847; __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);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_6);
+    __pyx_t_8 = 0;
+    __pyx_t_6 = 0;
+    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__key), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_t_7, __pyx_t_1, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __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_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    __pyx_t_12 = PyList_Append(((PyObject *)__pyx_v_output), __pyx_t_8); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":849
+ *             output.append( self.format_formatdata( data[s], self._format, key=False ) )
+ * 
+ *         stream.write( "\t".join(output) + "\n" )             # <<<<<<<<<<<<<<
+ * 
+ *     def _parse_header(self, stream):
+ */
+  __pyx_t_10 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_51), __pyx_n_s__join); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_INCREF(((PyObject *)__pyx_v_output));
+  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_output));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_output));
+  __pyx_t_1 = PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_6 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __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 = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  __pyx_t_6 = 0;
+  __pyx_t_6 = PyObject_Call(__pyx_t_10, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+  __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_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("cvcf.VCF.write_data");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_required);
+  __Pyx_DECREF(__pyx_v_k);
+  __Pyx_DECREF(__pyx_v_alt);
+  __Pyx_DECREF(__pyx_v_filter);
+  __Pyx_DECREF(__pyx_v_qual);
+  __Pyx_DECREF(__pyx_v_output);
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":851
+ *         stream.write( "\t".join(output) + "\n" )
+ * 
+ *     def _parse_header(self, stream):             # <<<<<<<<<<<<<<
+ *         self._lineno = 0
+ *         for line in stream:
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF__parse_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF__parse_header = {__Pyx_NAMESTR("_parse_header"), (PyCFunction)__pyx_pf_4cvcf_3VCF__parse_header, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF__parse_header(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_line;
+  PyObject *__pyx_r = NULL;
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("_parse_header");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_parse_header", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parse_header") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_parse_header", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF._parse_header");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":852
+ * 
+ *     def _parse_header(self, stream):
+ *         self._lineno = 0             # <<<<<<<<<<<<<<
+ *         for line in stream:
+ *             self._lineno += 1
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___lineno, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":853
+ *     def _parse_header(self, stream):
+ *         self._lineno = 0
+ *         for line in stream:             # <<<<<<<<<<<<<<
+ *             self._lineno += 1
+ *             if line.startswith('##'):
+ */
+  if (PyList_CheckExact(__pyx_v_stream) || PyTuple_CheckExact(__pyx_v_stream)) {
+    __pyx_t_1 = 0; __pyx_t_2 = __pyx_v_stream; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_stream); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
+    } else {
+      __pyx_t_3 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_3) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_3);
+    }
+    __Pyx_DECREF(__pyx_v_line);
+    __pyx_v_line = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":854
+ *         self._lineno = 0
+ *         for line in stream:
+ *             self._lineno += 1             # <<<<<<<<<<<<<<
+ *             if line.startswith('##'):
+ *                 self.parse_header( line.strip() )
+ */
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___lineno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___lineno, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":855
+ *         for line in stream:
+ *             self._lineno += 1
+ *             if line.startswith('##'):             # <<<<<<<<<<<<<<
+ *                 self.parse_header( line.strip() )
+ *             elif line.startswith('#'):
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_43));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":856
+ *             self._lineno += 1
+ *             if line.startswith('##'):
+ *                 self.parse_header( line.strip() )             # <<<<<<<<<<<<<<
+ *             elif line.startswith('#'):
+ *                 self.parse_heading( line.strip() )
+ */
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_header); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__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 = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L8;
+    }
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":857
+ *             if line.startswith('##'):
+ *                 self.parse_header( line.strip() )
+ *             elif line.startswith('#'):             # <<<<<<<<<<<<<<
+ *                 self.parse_heading( line.strip() )
+ *                 self.enter_default_format()
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_50));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
+    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":858
+ *                 self.parse_header( line.strip() )
+ *             elif line.startswith('#'):
+ *                 self.parse_heading( line.strip() )             # <<<<<<<<<<<<<<
+ *                 self.enter_default_format()
+ *             else:
+ */
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_heading); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_3 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__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 = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":859
+ *             elif line.startswith('#'):
+ *                 self.parse_heading( line.strip() )
+ *                 self.enter_default_format()             # <<<<<<<<<<<<<<
+ *             else:
+ *                 break
+ */
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_69); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __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_3); __pyx_t_3 = 0;
+      goto __pyx_L8;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":861
+ *                 self.enter_default_format()
+ *             else:
+ *                 break             # <<<<<<<<<<<<<<
+ *         return line
+ * 
+ */
+      goto __pyx_L7_break;
+    }
+    __pyx_L8:;
+  }
+  __pyx_L7_break:;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":862
+ *             else:
+ *                 break
+ *         return line             # <<<<<<<<<<<<<<
+ * 
+ *     def _parse(self, line, stream):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_line);
+  __pyx_r = __pyx_v_line;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF._parse_header");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_line);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":864
+ *         return line
+ * 
+ *     def _parse(self, line, stream):             # <<<<<<<<<<<<<<
+ *         if len(line.strip()) > 0:
+ *             d = self.parse_data( line.strip() )
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF__parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF__parse = {__Pyx_NAMESTR("_parse"), (PyCFunction)__pyx_pf_4cvcf_3VCF__parse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF__parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_line = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_d;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("_parse");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_parse", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("_parse", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_line = values[1];
+    __pyx_v_stream = values[2];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 2);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_parse", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF._parse");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __Pyx_INCREF(__pyx_v_line);
+  __pyx_v_d = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":865
+ * 
+ *     def _parse(self, line, stream):
+ *         if len(line.strip()) > 0:             # <<<<<<<<<<<<<<
+ *             d = self.parse_data( line.strip() )
+ *             #if d: yield d
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __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 = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = (__pyx_t_3 > 0);
+  if (__pyx_t_4) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":866
+ *     def _parse(self, line, stream):
+ *         if len(line.strip()) > 0:
+ *             d = self.parse_data( line.strip() )             # <<<<<<<<<<<<<<
+ *             #if d: yield d
+ *         for line in stream:
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), 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_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_1, 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_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_d);
+    __pyx_v_d = __pyx_t_5;
+    __pyx_t_5 = 0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":868
+ *             d = self.parse_data( line.strip() )
+ *             #if d: yield d
+ *         for line in stream:             # <<<<<<<<<<<<<<
+ *             self._lineno += 1
+ *             if self._lines and self._lineno > self._lines: raise StopIteration
+ */
+  if (PyList_CheckExact(__pyx_v_stream) || PyTuple_CheckExact(__pyx_v_stream)) {
+    __pyx_t_3 = 0; __pyx_t_5 = __pyx_v_stream; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_stream); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+    } else {
+      __pyx_t_1 = PyIter_Next(__pyx_t_5);
+      if (!__pyx_t_1) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    __Pyx_DECREF(__pyx_v_line);
+    __pyx_v_line = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":869
+ *             #if d: yield d
+ *         for line in stream:
+ *             self._lineno += 1             # <<<<<<<<<<<<<<
+ *             if self._lines and self._lineno > self._lines: raise StopIteration
+ *             d = self.parse_data( line.strip() )
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___lineno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___lineno, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":870
+ *         for line in stream:
+ *             self._lineno += 1
+ *             if self._lines and self._lineno > self._lines: raise StopIteration             # <<<<<<<<<<<<<<
+ *             d = self.parse_data( line.strip() )
+ *             #if d: yield d
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___lines); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_4) {
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___lineno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___lines); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __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_1); __pyx_t_1 = 0;
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_8 = __pyx_t_7;
+    } else {
+      __pyx_t_8 = __pyx_t_4;
+    }
+    if (__pyx_t_8) {
+      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":871
+ *             self._lineno += 1
+ *             if self._lines and self._lineno > self._lines: raise StopIteration
+ *             d = self.parse_data( line.strip() )             # <<<<<<<<<<<<<<
+ *             #if d: yield d
+ * 
+ */
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parse_data); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __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 = 871; __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 = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_d);
+    __pyx_v_d = __pyx_t_2;
+    __pyx_t_2 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  __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_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.VCF._parse");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_d);
+  __Pyx_DECREF(__pyx_v_line);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":880
+ *     ######################################################################################################
+ * 
+ *     def getsamples(self):             # <<<<<<<<<<<<<<
+ *         """ List of samples in VCF file """
+ *         return self._samples
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_getsamples(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_getsamples[] = " List of samples in VCF file ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_getsamples = {__Pyx_NAMESTR("getsamples"), (PyCFunction)__pyx_pf_4cvcf_3VCF_getsamples, METH_O, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_getsamples)};
+static PyObject *__pyx_pf_4cvcf_3VCF_getsamples(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("getsamples");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":882
+ *     def getsamples(self):
+ *         """ List of samples in VCF file """
+ *         return self._samples             # <<<<<<<<<<<<<<
+ * 
+ *     def setsamples(self,samples):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___samples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __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("cvcf.VCF.getsamples");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":884
+ *         return self._samples
+ * 
+ *     def setsamples(self,samples):             # <<<<<<<<<<<<<<
+ *         """ List of samples in VCF file """
+ *         self._samples = samples
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setsamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setsamples[] = " List of samples in VCF file ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setsamples = {__Pyx_NAMESTR("setsamples"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setsamples, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setsamples)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setsamples(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_samples = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__samples,0};
+  __Pyx_RefNannySetupContext("setsamples");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samples);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setsamples", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setsamples") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_samples = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_samples = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setsamples", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setsamples");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":886
+ *     def setsamples(self,samples):
+ *         """ List of samples in VCF file """
+ *         self._samples = samples             # <<<<<<<<<<<<<<
+ * 
+ *     def getheader(self):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___samples, __pyx_v_samples) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setsamples");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":888
+ *         self._samples = samples
+ * 
+ *     def getheader(self):             # <<<<<<<<<<<<<<
+ *         """ List of header key-value pairs (strings) """
+ *         return self._header
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_getheader(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_getheader[] = " List of header key-value pairs (strings) ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_getheader = {__Pyx_NAMESTR("getheader"), (PyCFunction)__pyx_pf_4cvcf_3VCF_getheader, METH_O, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_getheader)};
+static PyObject *__pyx_pf_4cvcf_3VCF_getheader(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("getheader");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":890
+ *     def getheader(self):
+ *         """ List of header key-value pairs (strings) """
+ *         return self._header             # <<<<<<<<<<<<<<
+ * 
+ *     def setheader(self,header):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___header); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __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("cvcf.VCF.getheader");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":892
+ *         return self._header
+ * 
+ *     def setheader(self,header):             # <<<<<<<<<<<<<<
+ *         """ List of header key-value pairs (strings) """
+ *         self._header = header
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setheader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setheader[] = " List of header key-value pairs (strings) ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setheader = {__Pyx_NAMESTR("setheader"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setheader, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setheader)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setheader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_header = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__header,0};
+  __Pyx_RefNannySetupContext("setheader");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__header);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setheader", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setheader") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_header = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_header = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setheader", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setheader");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":894
+ *     def setheader(self,header):
+ *         """ List of header key-value pairs (strings) """
+ *         self._header = header             # <<<<<<<<<<<<<<
+ * 
+ *     def getinfo(self):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___header, __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setheader");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":896
+ *         self._header = header
+ * 
+ *     def getinfo(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         return self._info
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_getinfo(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_getinfo[] = " Dictionary of ##INFO tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_getinfo = {__Pyx_NAMESTR("getinfo"), (PyCFunction)__pyx_pf_4cvcf_3VCF_getinfo, METH_O, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_getinfo)};
+static PyObject *__pyx_pf_4cvcf_3VCF_getinfo(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("getinfo");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":898
+ *     def getinfo(self):
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         return self._info             # <<<<<<<<<<<<<<
+ * 
+ *     def setinfo(self,info):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __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("cvcf.VCF.getinfo");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":900
+ *         return self._info
+ * 
+ *     def setinfo(self,info):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         self._info = info
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setinfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setinfo[] = " Dictionary of ##INFO tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setinfo = {__Pyx_NAMESTR("setinfo"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setinfo, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setinfo)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setinfo(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_info = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__info,0};
+  __Pyx_RefNannySetupContext("setinfo");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__info);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setinfo", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setinfo") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_info = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_info = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setinfo", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setinfo");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":902
+ *     def setinfo(self,info):
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         self._info = info             # <<<<<<<<<<<<<<
+ * 
+ *     def getformat(self):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___info, __pyx_v_info) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setinfo");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":904
+ *         self._info = info
+ * 
+ *     def getformat(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         return self._format
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_getformat(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_getformat[] = " Dictionary of ##FORMAT tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_getformat = {__Pyx_NAMESTR("getformat"), (PyCFunction)__pyx_pf_4cvcf_3VCF_getformat, METH_O, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_getformat)};
+static PyObject *__pyx_pf_4cvcf_3VCF_getformat(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("getformat");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":906
+ *     def getformat(self):
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         return self._format             # <<<<<<<<<<<<<<
+ * 
+ *     def setformat(self,format):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __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("cvcf.VCF.getformat");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":908
+ *         return self._format
+ * 
+ *     def setformat(self,format):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         self._format = format
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setformat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setformat[] = " Dictionary of ##FORMAT tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setformat = {__Pyx_NAMESTR("setformat"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setformat, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setformat)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setformat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_format = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__format,0};
+  __Pyx_RefNannySetupContext("setformat");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setformat", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setformat") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_format = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setformat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setformat");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":910
+ *     def setformat(self,format):
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         self._format = format             # <<<<<<<<<<<<<<
+ * 
+ *     def getfilter(self):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___format, __pyx_v_format) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setformat");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":912
+ *         self._format = format
+ * 
+ *     def getfilter(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         return self._filter
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_getfilter(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_getfilter[] = " Dictionary of ##FILTER tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_getfilter = {__Pyx_NAMESTR("getfilter"), (PyCFunction)__pyx_pf_4cvcf_3VCF_getfilter, METH_O, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_getfilter)};
+static PyObject *__pyx_pf_4cvcf_3VCF_getfilter(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("getfilter");
+  __pyx_self = __pyx_self;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":914
+ *     def getfilter(self):
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         return self._filter             # <<<<<<<<<<<<<<
+ * 
+ *     def setfilter(self,filter):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __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("cvcf.VCF.getfilter");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":916
+ *         return self._filter
+ * 
+ *     def setfilter(self,filter):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         self._filter = filter
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setfilter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setfilter[] = " Dictionary of ##FILTER tags, as VCF.FORMAT values ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setfilter = {__Pyx_NAMESTR("setfilter"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setfilter, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setfilter)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setfilter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_filter = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filter,0};
+  __Pyx_RefNannySetupContext("setfilter");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filter);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setfilter", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfilter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_filter = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_filter = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setfilter", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setfilter");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":918
+ *     def setfilter(self,filter):
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         self._filter = filter             # <<<<<<<<<<<<<<
+ * 
+ *     def setversion(self, version):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___filter, __pyx_v_filter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setfilter");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":920
+ *         self._filter = filter
+ * 
+ *     def setversion(self, version):             # <<<<<<<<<<<<<<
+ *         if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")
+ *         self._version = version
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setversion(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setversion = {__Pyx_NAMESTR("setversion"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setversion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setversion(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_version = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__version,0};
+  __Pyx_RefNannySetupContext("setversion");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__version);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setversion", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setversion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_version = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_version = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setversion", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setversion");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":921
+ * 
+ *     def setversion(self, version):
+ *         if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")             # <<<<<<<<<<<<<<
+ *         self._version = version
+ * 
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_version, __pyx_int_33, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __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 = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_version, __pyx_int_40, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_4 = __pyx_t_3;
+  } else {
+    __pyx_t_4 = __pyx_t_2;
+  }
+  if (__pyx_t_4) {
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_70));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_70));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_70));
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_5, 0, 0);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":922
+ *     def setversion(self, version):
+ *         if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")
+ *         self._version = version             # <<<<<<<<<<<<<<
+ * 
+ *     def setregions(self, regions):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___version, __pyx_v_version) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.setversion");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":924
+ *         self._version = version
+ * 
+ *     def setregions(self, regions):             # <<<<<<<<<<<<<<
+ *         self._regions = regions
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setregions(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setregions = {__Pyx_NAMESTR("setregions"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setregions, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setregions(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_regions = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__regions,0};
+  __Pyx_RefNannySetupContext("setregions");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__regions);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setregions", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setregions") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_regions = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_regions = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setregions", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setregions");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":925
+ * 
+ *     def setregions(self, regions):
+ *         self._regions = regions             # <<<<<<<<<<<<<<
+ * 
+ *     def setreference(self, ref):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___regions, __pyx_v_regions) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setregions");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":927
+ *         self._regions = regions
+ * 
+ *     def setreference(self, ref):             # <<<<<<<<<<<<<<
+ *         """ Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile """
+ *         self._reference = ref
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_setreference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_setreference[] = " Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_setreference = {__Pyx_NAMESTR("setreference"), (PyCFunction)__pyx_pf_4cvcf_3VCF_setreference, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_setreference)};
+static PyObject *__pyx_pf_4cvcf_3VCF_setreference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_ref = 0;
+  PyObject *__pyx_r = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__ref,0};
+  __Pyx_RefNannySetupContext("setreference");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("setreference", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setreference") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_ref = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_ref = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("setreference", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setreference");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":929
+ *     def setreference(self, ref):
+ *         """ Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile """
+ *         self._reference = ref             # <<<<<<<<<<<<<<
+ * 
+ *     def ignoreerror(self, errorstring):
+ */
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___reference, __pyx_v_ref) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cvcf.VCF.setreference");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":931
+ *         self._reference = ref
+ * 
+ *     def ignoreerror(self, errorstring):             # <<<<<<<<<<<<<<
+ *         try:             self._ignored_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_ignoreerror(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_ignoreerror = {__Pyx_NAMESTR("ignoreerror"), (PyCFunction)__pyx_pf_4cvcf_3VCF_ignoreerror, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_ignoreerror(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_errorstring = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__errorstring,0};
+  __Pyx_RefNannySetupContext("ignoreerror");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__errorstring);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("ignoreerror", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "ignoreerror") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_errorstring = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_errorstring = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("ignoreerror", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.ignoreerror");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":932
+ * 
+ *     def ignoreerror(self, errorstring):
+ *         try:             self._ignored_errors.add(self.__dict__[errorstring])             # <<<<<<<<<<<<<<
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ */
+  {
+    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+    __Pyx_XGOTREF(__pyx_save_exc_type);
+    __Pyx_XGOTREF(__pyx_save_exc_value);
+    __Pyx_XGOTREF(__pyx_save_exc_tb);
+    /*try:*/ {
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___ignored_errors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L6_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____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_v_errorstring); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L6_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 = 932; __pyx_clineno = __LINE__; goto __pyx_L6_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_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    }
+    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+    goto __pyx_L13_try_end;
+    __pyx_L6_error:;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":933
+ *     def ignoreerror(self, errorstring):
+ *         try:             self._ignored_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)             # <<<<<<<<<<<<<<
+ * 
+ *     def warnerror(self, errorstring):
+ */
+    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+    if (__pyx_t_4) {
+      __Pyx_AddTraceback("cvcf.VCF.ignoreerror");
+      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_71), __pyx_v_errorstring); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L7_exception_handled;
+    }
+    __pyx_L8_except_error:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L1_error;
+    __pyx_L7_exception_handled:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    __pyx_L13_try_end:;
+  }
+
+  __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_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.VCF.ignoreerror");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":935
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ *     def warnerror(self, errorstring):             # <<<<<<<<<<<<<<
+ *         try:             self._warn_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_warnerror(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_warnerror = {__Pyx_NAMESTR("warnerror"), (PyCFunction)__pyx_pf_4cvcf_3VCF_warnerror, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_4cvcf_3VCF_warnerror(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_errorstring = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__errorstring,0};
+  __Pyx_RefNannySetupContext("warnerror");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__errorstring);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("warnerror", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "warnerror") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_errorstring = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_errorstring = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("warnerror", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.warnerror");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":936
+ * 
+ *     def warnerror(self, errorstring):
+ *         try:             self._warn_errors.add(self.__dict__[errorstring])             # <<<<<<<<<<<<<<
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ */
+  {
+    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+    __Pyx_XGOTREF(__pyx_save_exc_type);
+    __Pyx_XGOTREF(__pyx_save_exc_value);
+    __Pyx_XGOTREF(__pyx_save_exc_tb);
+    /*try:*/ {
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___warn_errors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L6_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____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_v_errorstring); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L6_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 = 936; __pyx_clineno = __LINE__; goto __pyx_L6_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_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    }
+    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+    goto __pyx_L13_try_end;
+    __pyx_L6_error:;
+    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":937
+ *     def warnerror(self, errorstring):
+ *         try:             self._warn_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)             # <<<<<<<<<<<<<<
+ * 
+ *     def parse(self, stream):
+ */
+    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
+    if (__pyx_t_4) {
+      __Pyx_AddTraceback("cvcf.VCF.warnerror");
+      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_71), __pyx_v_errorstring); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L7_exception_handled;
+    }
+    __pyx_L8_except_error:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    goto __pyx_L1_error;
+    __pyx_L7_exception_handled:;
+    __Pyx_XGIVEREF(__pyx_save_exc_type);
+    __Pyx_XGIVEREF(__pyx_save_exc_value);
+    __Pyx_XGIVEREF(__pyx_save_exc_tb);
+    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+    __pyx_L13_try_end:;
+  }
+
+  __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_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.VCF.warnerror");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":939
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ *     def parse(self, stream):             # <<<<<<<<<<<<<<
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ *         last_line = self._parse_header(stream)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_parse[] = " Parse a stream of VCF-formatted lines.  Initializes class instance and return generator ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_parse = {__Pyx_NAMESTR("parse"), (PyCFunction)__pyx_pf_4cvcf_3VCF_parse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_parse)};
+static PyObject *__pyx_pf_4cvcf_3VCF_parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_last_line;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("parse");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("parse", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("parse", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.parse");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_last_line = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":941
+ *     def parse(self, stream):
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ *         last_line = self._parse_header(stream)             # <<<<<<<<<<<<<<
+ *         # now return a generator that does the actual work.  In this way the pre-processing is done
+ *         # before the first piece of data is yielded
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parse_header); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_last_line);
+  __pyx_v_last_line = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":944
+ *         # now return a generator that does the actual work.  In this way the pre-processing is done
+ *         # before the first piece of data is yielded
+ *         return self._parse(last_line, stream)             # <<<<<<<<<<<<<<
+ * 
+ *     def write(self, stream, datagenerator):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parse); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __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 = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_last_line);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_last_line);
+  __Pyx_GIVEREF(__pyx_v_last_line);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __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_2); __pyx_t_2 = 0;
+  __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_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("cvcf.VCF.parse");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_last_line);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":946
+ *         return self._parse(last_line, stream)
+ * 
+ *     def write(self, stream, datagenerator):             # <<<<<<<<<<<<<<
+ *         """ Writes a VCF file to a stream, using a data generator (or list) """
+ *         self.write_header(stream)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_write[] = " Writes a VCF file to a stream, using a data generator (or list) ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_write = {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_4cvcf_3VCF_write, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_write)};
+static PyObject *__pyx_pf_4cvcf_3VCF_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_v_datagenerator = 0;
+  PyObject *__pyx_v_data;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,&__pyx_n_s__datagenerator,0};
+  __Pyx_RefNannySetupContext("write");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__datagenerator);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("write", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+    __pyx_v_datagenerator = values[2];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_datagenerator = PyTuple_GET_ITEM(__pyx_args, 2);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("write", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.write");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_data = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":948
+ *     def write(self, stream, datagenerator):
+ *         """ Writes a VCF file to a stream, using a data generator (or list) """
+ *         self.write_header(stream)             # <<<<<<<<<<<<<<
+ *         self.write_heading(stream)
+ *         for data in datagenerator: self.write_data(stream,data)
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__write_header); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":949
+ *         """ Writes a VCF file to a stream, using a data generator (or list) """
+ *         self.write_header(stream)
+ *         self.write_heading(stream)             # <<<<<<<<<<<<<<
+ *         for data in datagenerator: self.write_data(stream,data)
+ * 
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__write_heading); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":950
+ *         self.write_header(stream)
+ *         self.write_heading(stream)
+ *         for data in datagenerator: self.write_data(stream,data)             # <<<<<<<<<<<<<<
+ * 
+ *     def writeheader(self, stream):
+ */
+  if (PyList_CheckExact(__pyx_v_datagenerator) || PyTuple_CheckExact(__pyx_v_datagenerator)) {
+    __pyx_t_4 = 0; __pyx_t_1 = __pyx_v_datagenerator; __Pyx_INCREF(__pyx_t_1);
+  } else {
+    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_datagenerator); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+  }
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_1);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_data);
+    __pyx_v_data = __pyx_t_2;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__write_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __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 = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(__pyx_v_stream);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stream);
+    __Pyx_GIVEREF(__pyx_v_stream);
+    __Pyx_INCREF(__pyx_v_data);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_data);
+    __Pyx_GIVEREF(__pyx_v_data);
+    __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  __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_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.write");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_data);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":952
+ *         for data in datagenerator: self.write_data(stream,data)
+ * 
+ *     def writeheader(self, stream):             # <<<<<<<<<<<<<<
+ *         """ Writes a VCF header """
+ *         self.write_header(stream)
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_writeheader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_writeheader[] = " Writes a VCF header ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_writeheader = {__Pyx_NAMESTR("writeheader"), (PyCFunction)__pyx_pf_4cvcf_3VCF_writeheader, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_writeheader)};
+static PyObject *__pyx_pf_4cvcf_3VCF_writeheader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_stream = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__stream,0};
+  __Pyx_RefNannySetupContext("writeheader");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("writeheader", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "writeheader") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_stream = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("writeheader", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.writeheader");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":954
+ *     def writeheader(self, stream):
+ *         """ Writes a VCF header """
+ *         self.write_header(stream)             # <<<<<<<<<<<<<<
+ *         self.write_heading(stream)
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__write_header); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":955
+ *         """ Writes a VCF header """
+ *         self.write_header(stream)
+ *         self.write_heading(stream)             # <<<<<<<<<<<<<<
+ * 
+ *     def compare_calls(self, pos1, ref1, alt1, pos2, ref2, alt2):
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__write_heading); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_stream);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_stream);
+  __Pyx_GIVEREF(__pyx_v_stream);
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __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_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  __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("cvcf.VCF.writeheader");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":957
+ *         self.write_heading(stream)
+ * 
+ *     def compare_calls(self, pos1, ref1, alt1, pos2, ref2, alt2):             # <<<<<<<<<<<<<<
+ *         """ Utility function: compares two calls for equality """
+ *         # a variant should always be assigned to a unique position, one base before
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_compare_calls(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_compare_calls[] = " Utility function: compares two calls for equality ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_compare_calls = {__Pyx_NAMESTR("compare_calls"), (PyCFunction)__pyx_pf_4cvcf_3VCF_compare_calls, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_compare_calls)};
+static PyObject *__pyx_pf_4cvcf_3VCF_compare_calls(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_pos1 = 0;
+  PyObject *__pyx_v_ref1 = 0;
+  PyObject *__pyx_v_alt1 = 0;
+  PyObject *__pyx_v_pos2 = 0;
+  PyObject *__pyx_v_ref2 = 0;
+  PyObject *__pyx_v_alt2 = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  Py_ssize_t __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_t_7;
+  int __pyx_t_8;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__pos1,&__pyx_n_s__ref1,&__pyx_n_s__alt1,&__pyx_n_s__pos2,&__pyx_n_s__ref2,&__pyx_n_s__alt2,0};
+  __Pyx_RefNannySetupContext("compare_calls");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[7] = {0,0,0,0,0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
+      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos1);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref1);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  3:
+      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alt1);
+      if (likely(values[3])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  4:
+      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos2);
+      if (likely(values[4])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  5:
+      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref2);
+      if (likely(values[5])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  6:
+      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alt2);
+      if (likely(values[6])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "compare_calls") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_pos1 = values[1];
+    __pyx_v_ref1 = values[2];
+    __pyx_v_alt1 = values[3];
+    __pyx_v_pos2 = values[4];
+    __pyx_v_ref2 = values[5];
+    __pyx_v_alt2 = values[6];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_pos1 = PyTuple_GET_ITEM(__pyx_args, 1);
+    __pyx_v_ref1 = PyTuple_GET_ITEM(__pyx_args, 2);
+    __pyx_v_alt1 = PyTuple_GET_ITEM(__pyx_args, 3);
+    __pyx_v_pos2 = PyTuple_GET_ITEM(__pyx_args, 4);
+    __pyx_v_ref2 = PyTuple_GET_ITEM(__pyx_args, 5);
+    __pyx_v_alt2 = PyTuple_GET_ITEM(__pyx_args, 6);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("compare_calls", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.compare_calls");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __Pyx_INCREF(__pyx_v_ref1);
+  __Pyx_INCREF(__pyx_v_alt1);
+  __Pyx_INCREF(__pyx_v_ref2);
+  __Pyx_INCREF(__pyx_v_alt2);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":962
+ *         # the leftmost position of the alignment gap.  If this rule is implemented
+ *         # correctly, the two positions must be equal for the calls to be identical.
+ *         if pos1 != pos2: return False             # <<<<<<<<<<<<<<
+ *         # from both calls, trim rightmost bases when identical.  Do this safely, i.e.
+ *         # only when the reference bases are not Ns
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_pos1, __pyx_v_pos2, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __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 = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":965
+ *         # from both calls, trim rightmost bases when identical.  Do this safely, i.e.
+ *         # only when the reference bases are not Ns
+ *         while len(ref1)>0 and len(alt1)>0 and ref1[-1] == alt1[-1]:             # <<<<<<<<<<<<<<
+ *             ref1 = ref1[:-1]
+ *             alt1 = alt1[:-1]
+ */
+  while (1) {
+    __pyx_t_3 = PyObject_Length(__pyx_v_ref1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = (__pyx_t_3 > 0);
+    if (__pyx_t_2) {
+      __pyx_t_3 = PyObject_Length(__pyx_v_alt1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = (__pyx_t_3 > 0);
+      if (__pyx_t_4) {
+        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ref1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_alt1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_8 = __pyx_t_7;
+      } else {
+        __pyx_t_8 = __pyx_t_4;
+      }
+      __pyx_t_4 = __pyx_t_8;
+    } else {
+      __pyx_t_4 = __pyx_t_2;
+    }
+    if (!__pyx_t_4) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":966
+ *         # only when the reference bases are not Ns
+ *         while len(ref1)>0 and len(alt1)>0 and ref1[-1] == alt1[-1]:
+ *             ref1 = ref1[:-1]             # <<<<<<<<<<<<<<
+ *             alt1 = alt1[:-1]
+ *         while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+ */
+    __pyx_t_6 = PySequence_GetSlice(__pyx_v_ref1, 0, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_v_ref1);
+    __pyx_v_ref1 = __pyx_t_6;
+    __pyx_t_6 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":967
+ *         while len(ref1)>0 and len(alt1)>0 and ref1[-1] == alt1[-1]:
+ *             ref1 = ref1[:-1]
+ *             alt1 = alt1[:-1]             # <<<<<<<<<<<<<<
+ *         while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+ *             ref2 = ref2[:-1]
+ */
+    __pyx_t_6 = PySequence_GetSlice(__pyx_v_alt1, 0, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_v_alt1);
+    __pyx_v_alt1 = __pyx_t_6;
+    __pyx_t_6 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":968
+ *             ref1 = ref1[:-1]
+ *             alt1 = alt1[:-1]
+ *         while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:             # <<<<<<<<<<<<<<
+ *             ref2 = ref2[:-1]
+ *             alt2 = alt2[:-1]
+ */
+  while (1) {
+    __pyx_t_3 = PyObject_Length(__pyx_v_ref2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = (__pyx_t_3 > 0);
+    if (__pyx_t_4) {
+      __pyx_t_3 = PyObject_Length(__pyx_v_alt2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = (__pyx_t_3 > 0);
+      if (__pyx_t_2) {
+        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_ref2, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_alt2, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_7 = __pyx_t_8;
+      } else {
+        __pyx_t_7 = __pyx_t_2;
+      }
+      __pyx_t_2 = __pyx_t_7;
+    } else {
+      __pyx_t_2 = __pyx_t_4;
+    }
+    if (!__pyx_t_2) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":969
+ *             alt1 = alt1[:-1]
+ *         while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+ *             ref2 = ref2[:-1]             # <<<<<<<<<<<<<<
+ *             alt2 = alt2[:-1]
+ *         # now, the alternative alleles must be identical
+ */
+    __pyx_t_1 = PySequence_GetSlice(__pyx_v_ref2, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_ref2);
+    __pyx_v_ref2 = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":970
+ *         while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+ *             ref2 = ref2[:-1]
+ *             alt2 = alt2[:-1]             # <<<<<<<<<<<<<<
+ *         # now, the alternative alleles must be identical
+ *         return alt1 == alt2
+ */
+    __pyx_t_1 = PySequence_GetSlice(__pyx_v_alt2, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_alt2);
+    __pyx_v_alt2 = __pyx_t_1;
+    __pyx_t_1 = 0;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":972
+ *             alt2 = alt2[:-1]
+ *         # now, the alternative alleles must be identical
+ *         return alt1 == alt2             # <<<<<<<<<<<<<<
+ * 
+ * ###########################################################################################################
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_alt1, __pyx_v_alt2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __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_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cvcf.VCF.compare_calls");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_ref1);
+  __Pyx_DECREF(__pyx_v_alt1);
+  __Pyx_DECREF(__pyx_v_ref2);
+  __Pyx_DECREF(__pyx_v_alt2);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":979
+ * ###########################################################################################################
+ * 
+ *     def connect( self, filename ):             # <<<<<<<<<<<<<<
+ *         '''connect to tabix file.'''
+ *         self.tabixfile = pysam.Tabixfile( filename )
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_connect[] = "connect to tabix file.";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_connect = {__Pyx_NAMESTR("connect"), (PyCFunction)__pyx_pf_4cvcf_3VCF_connect, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_connect)};
+static PyObject *__pyx_pf_4cvcf_3VCF_connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_filename = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
+  __Pyx_RefNannySetupContext("connect");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("connect", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "connect") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_filename = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("connect", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.connect");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":981
+ *     def connect( self, filename ):
+ *         '''connect to tabix file.'''
+ *         self.tabixfile = pysam.Tabixfile( filename )             # <<<<<<<<<<<<<<
+ *         self._parse_header(self.tabixfile.header)
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pysam); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __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 = 981; __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);
+  __Pyx_GIVEREF(__pyx_v_filename);
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __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_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__tabixfile, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":982
+ *         '''connect to tabix file.'''
+ *         self.tabixfile = pysam.Tabixfile( filename )
+ *         self._parse_header(self.tabixfile.header)             # <<<<<<<<<<<<<<
+ * 
+ *     def fetch(self,
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parse_header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tabixfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__header); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __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 = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __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;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  __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("cvcf.VCF.connect");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":984
+ *         self._parse_header(self.tabixfile.header)
+ * 
+ *     def fetch(self,             # <<<<<<<<<<<<<<
+ *               reference = None,
+ *               start = None,
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_fetch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_fetch[] = " Parse a stream of VCF-formatted lines.  Initializes class instance and return generator ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_fetch = {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_4cvcf_3VCF_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_fetch)};
+static PyObject *__pyx_pf_4cvcf_3VCF_fetch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_reference = 0;
+  PyObject *__pyx_v_start = 0;
+  PyObject *__pyx_v_end = 0;
+  PyObject *__pyx_v_region = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
+  __Pyx_RefNannySetupContext("fetch");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[5] = {0,0,0,0,0};
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":985
+ * 
+ *     def fetch(self,
+ *               reference = None,             # <<<<<<<<<<<<<<
+ *               start = None,
+ *               end = None,
+ */
+    values[1] = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":986
+ *     def fetch(self,
+ *               reference = None,
+ *               start = None,             # <<<<<<<<<<<<<<
+ *               end = None,
+ *               region = None ):
+ */
+    values[2] = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":987
+ *               reference = None,
+ *               start = None,
+ *               end = None,             # <<<<<<<<<<<<<<
+ *               region = None ):
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ */
+    values[3] = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":988
+ *               start = None,
+ *               end = None,
+ *               region = None ):             # <<<<<<<<<<<<<<
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ * 
+ */
+    values[4] = ((PyObject *)Py_None);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+        if (value) { values[1] = value; kw_args--; }
+      }
+      case  2:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
+        if (value) { values[2] = value; kw_args--; }
+      }
+      case  3:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
+        if (value) { values[3] = value; kw_args--; }
+      }
+      case  4:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
+        if (value) { values[4] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_reference = values[1];
+    __pyx_v_start = values[2];
+    __pyx_v_end = values[3];
+    __pyx_v_region = values[4];
+  } else {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":985
+ * 
+ *     def fetch(self,
+ *               reference = None,             # <<<<<<<<<<<<<<
+ *               start = None,
+ *               end = None,
+ */
+    __pyx_v_reference = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":986
+ *     def fetch(self,
+ *               reference = None,
+ *               start = None,             # <<<<<<<<<<<<<<
+ *               end = None,
+ *               region = None ):
+ */
+    __pyx_v_start = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":987
+ *               reference = None,
+ *               start = None,
+ *               end = None,             # <<<<<<<<<<<<<<
+ *               region = None ):
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ */
+    __pyx_v_end = ((PyObject *)Py_None);
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":988
+ *               start = None,
+ *               end = None,
+ *               region = None ):             # <<<<<<<<<<<<<<
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ * 
+ */
+    __pyx_v_region = ((PyObject *)Py_None);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  5: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 4);
+      case  4: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 3);
+      case  3: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("fetch", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.fetch");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":991
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ * 
+ *         return self.tabixfile.fetch( reference, start, end, region, parser = asVCFRecord( self ) )             # <<<<<<<<<<<<<<
+ * 
+ *     def validate( self, record ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tabixfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fetch); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __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(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __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);
+  __Pyx_GIVEREF(__pyx_v_reference);
+  __Pyx_INCREF(__pyx_v_start);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
+  __Pyx_GIVEREF(__pyx_v_start);
+  __Pyx_INCREF(__pyx_v_end);
+  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
+  __Pyx_GIVEREF(__pyx_v_end);
+  __Pyx_INCREF(__pyx_v_region);
+  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
+  __Pyx_GIVEREF(__pyx_v_region);
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4cvcf_asVCFRecord)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__parser), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_5;
+  __pyx_t_5 = 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_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cvcf.VCF.fetch");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":993
+ *         return self.tabixfile.fetch( reference, start, end, region, parser = asVCFRecord( self ) )
+ * 
+ *     def validate( self, record ):             # <<<<<<<<<<<<<<
+ *         '''validate vcf record.
+ * 
+ */
+
+static PyObject *__pyx_pf_4cvcf_3VCF_validate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_4cvcf_3VCF_validate[] = "validate vcf record.\n\n        returns a validated record.\n        ";
+static PyMethodDef __pyx_mdef_4cvcf_3VCF_validate = {__Pyx_NAMESTR("validate"), (PyCFunction)__pyx_pf_4cvcf_3VCF_validate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4cvcf_3VCF_validate)};
+static PyObject *__pyx_pf_4cvcf_3VCF_validate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_record = 0;
+  PyObject *__pyx_v_chrom;
+  PyObject *__pyx_v_pos;
+  PyObject *__pyx_v_ref;
+  PyObject *__pyx_v_c;
+  PyObject *__pyx_v_left;
+  PyObject *__pyx_v_faref_leftflank;
+  PyObject *__pyx_v_faref;
+  PyObject *__pyx_v_f;
+  PyObject *__pyx_v_newalts;
+  int __pyx_v_have_deletions;
+  PyObject *__pyx_v_a;
+  PyObject *__pyx_v_l;
+  PyObject *__pyx_v_addns;
+  PyObject *__pyx_v_i;
+  PyObject *__pyx_v_na;
+  PyObject *__pyx_v_s;
+  PyObject *__pyx_v_alt;
+  PyObject *__pyx_v_addn;
+  PyObject *__pyx_v_allele;
+  int __pyx_v_movable;
+  PyObject *__pyx_v_longest;
+  PyObject *__pyx_v_shortest;
+  PyObject *__pyx_8genexpr1__pyx_v_allele;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  Py_ssize_t __pyx_t_6;
+  PyObject *__pyx_t_7 = NULL;
+  Py_ssize_t __pyx_t_8;
+  long __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  Py_ssize_t __pyx_t_12;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  int __pyx_t_16;
+  int __pyx_t_17;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__record,0};
+  __Pyx_RefNannySetupContext("validate");
+  __pyx_self = __pyx_self;
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__record);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("validate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "validate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_record = values[1];
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_record = PyTuple_GET_ITEM(__pyx_args, 1);
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("validate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cvcf.VCF.validate");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_chrom = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_pos = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_ref = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_c = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_left = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_faref_leftflank = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_faref = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_newalts = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_addns = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_na = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_alt = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_addn = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_allele = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_longest = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_shortest = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_8genexpr1__pyx_v_allele = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":999
+ *         '''
+ * 
+ *         raise NotImplementedError( "needs to be checked" )             # <<<<<<<<<<<<<<
+ * 
+ *         chrom, pos = record.chrom, record.pos
+ */
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_72));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_72));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_72));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_Raise(__pyx_t_2, 0, 0);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1001
+ *         raise NotImplementedError( "needs to be checked" )
+ * 
+ *         chrom, pos = record.chrom, record.pos             # <<<<<<<<<<<<<<
+ * 
+ *         # check reference
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__chrom); 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_t_1 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__pos); 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_DECREF(__pyx_v_chrom);
+  __pyx_v_chrom = __pyx_t_2;
+  __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_v_pos);
+  __pyx_v_pos = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1004
+ * 
+ *         # check reference
+ *         ref = record.ref             # <<<<<<<<<<<<<<
+ *         if ref == ".":
+ *             self.error(str(record),self.MISSING_REF)
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_v_ref);
+  __pyx_v_ref = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1005
+ *         # check reference
+ *         ref = record.ref
+ *         if ref == ".":             # <<<<<<<<<<<<<<
+ *             self.error(str(record),self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ */
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_ref, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1006
+ *         ref = record.ref
+ *         if ref == ".":
+ *             self.error(str(record),self.MISSING_REF)             # <<<<<<<<<<<<<<
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ *             else:                   ref = ""
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(1); 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_INCREF(__pyx_v_record);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_record);
+    __Pyx_GIVEREF(__pyx_v_record);
+    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__MISSING_REF); 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_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __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);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_4 = 0;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_5, 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1007
+ *         if ref == ".":
+ *             self.error(str(record),self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)             # <<<<<<<<<<<<<<
+ *             else:                   ref = ""
+ *         else:
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __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 = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_3) {
+      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_2 = PyNumber_Add(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_INCREF(__pyx_v_chrom);
+      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_chrom);
+      __Pyx_GIVEREF(__pyx_v_chrom);
+      __Pyx_INCREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_pos);
+      __Pyx_GIVEREF(__pyx_v_pos);
+      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      __pyx_t_2 = 0;
+      __pyx_t_1 = 0;
+      __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = __pyx_t_1;
+      __pyx_t_1 = 0;
+      goto __pyx_L7;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1008
+ *             self.error(str(record),self.MISSING_REF)
+ *             if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+ *             else:                   ref = ""             # <<<<<<<<<<<<<<
+ *         else:
+ *             for c in ref:
+ */
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = ((PyObject *)__pyx_kp_s_1);
+    }
+    __pyx_L7:;
+    goto __pyx_L6;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1010
+ *             else:                   ref = ""
+ *         else:
+ *             for c in ref:             # <<<<<<<<<<<<<<
+ *                 if c not in "ACGTN": self.error(str(record),self.UNKNOWN_CHAR_IN_REF)
+ *                 if "N" in ref: ref = get_sequence(chrom,
+ */
+    if (PyList_CheckExact(__pyx_v_ref) || PyTuple_CheckExact(__pyx_v_ref)) {
+      __pyx_t_6 = 0; __pyx_t_1 = __pyx_v_ref; __Pyx_INCREF(__pyx_t_1);
+    } else {
+      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    for (;;) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+      } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+      } else {
+        __pyx_t_4 = PyIter_Next(__pyx_t_1);
+        if (!__pyx_t_4) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          break;
+        }
+        __Pyx_GOTREF(__pyx_t_4);
+      }
+      __Pyx_DECREF(__pyx_v_c);
+      __pyx_v_c = __pyx_t_4;
+      __pyx_t_4 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1011
+ *         else:
+ *             for c in ref:
+ *                 if c not in "ACGTN": self.error(str(record),self.UNKNOWN_CHAR_IN_REF)             # <<<<<<<<<<<<<<
+ *                 if "N" in ref: ref = get_sequence(chrom,
+ *                                                   pos,
+ */
+      __pyx_t_3 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_n_s__ACGTN), __pyx_v_c))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_3) {
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_INCREF(__pyx_v_record);
+        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
+        __Pyx_GIVEREF(__pyx_v_record);
+        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__UNKNOWN_CHAR_IN_REF); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __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);
+        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_5);
+        __pyx_t_2 = 0;
+        __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        goto __pyx_L10;
+      }
+      __pyx_L10:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1012
+ *             for c in ref:
+ *                 if c not in "ACGTN": self.error(str(record),self.UNKNOWN_CHAR_IN_REF)
+ *                 if "N" in ref: ref = get_sequence(chrom,             # <<<<<<<<<<<<<<
+ *                                                   pos,
+ *                                                   pos+len(ref),
+ */
+      __pyx_t_3 = ((PySequence_Contains(__pyx_v_ref, ((PyObject *)__pyx_n_s__N)))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_3) {
+        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1014
+ *                 if "N" in ref: ref = get_sequence(chrom,
+ *                                                   pos,
+ *                                                   pos+len(ref),             # <<<<<<<<<<<<<<
+ *                                                   self._reference)
+ * 
+ */
+        __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_4 = PyNumber_Add(__pyx_v_pos, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1015
+ *                                                   pos,
+ *                                                   pos+len(ref),
+ *                                                   self._reference)             # <<<<<<<<<<<<<<
+ * 
+ *         # make sure reference is sane
+ */
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_INCREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_chrom);
+        __Pyx_GIVEREF(__pyx_v_chrom);
+        __Pyx_INCREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_pos);
+        __Pyx_GIVEREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_7);
+        __Pyx_GIVEREF(__pyx_t_7);
+        __pyx_t_4 = 0;
+        __pyx_t_7 = 0;
+        __pyx_t_7 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_7;
+        __pyx_t_7 = 0;
+        goto __pyx_L11;
+      }
+      __pyx_L11:;
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1018
+ * 
+ *         # make sure reference is sane
+ *         if self._reference:             # <<<<<<<<<<<<<<
+ *             left = max(0,self.pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1019
+ *         # make sure reference is sane
+ *         if self._reference:
+ *             left = max(0,self.pos-100)             # <<<<<<<<<<<<<<
+ *             faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_int_100); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_9 = 0;
+    __pyx_t_2 = PyInt_FromLong(__pyx_t_9); 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_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_2, Py_GT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __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 = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_3) {
+      __Pyx_INCREF(__pyx_t_7);
+      __pyx_t_1 = __pyx_t_7;
+    } else {
+      __pyx_t_5 = PyInt_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_1 = __pyx_t_5;
+      __pyx_t_5 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_INCREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_left);
+    __pyx_v_left = __pyx_t_1;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1020
+ *         if self._reference:
+ *             left = max(0,self.pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)             # <<<<<<<<<<<<<<
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(str(record),self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ */
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_6 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_2 = PyNumber_Add(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_INCREF(__pyx_v_chrom);
+    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chrom);
+    __Pyx_GIVEREF(__pyx_v_chrom);
+    __Pyx_INCREF(__pyx_v_left);
+    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_left);
+    __Pyx_GIVEREF(__pyx_v_left);
+    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_2 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_v_faref_leftflank);
+    __pyx_v_faref_leftflank = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1021
+ *             left = max(0,self.pos-100)
+ *             faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]             # <<<<<<<<<<<<<<
+ *             if faref != ref: self.error(str(record),self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ *             ref = faref
+ */
+    __pyx_t_5 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PySequence_GetSlice(__pyx_v_faref_leftflank, __pyx_t_6, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_v_faref);
+    __pyx_v_faref = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1022
+ *             faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(str(record),self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))             # <<<<<<<<<<<<<<
+ *             ref = faref
+ * 
+ */
+    __pyx_t_5 = PyObject_RichCompare(__pyx_v_faref, __pyx_v_ref, Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    if (__pyx_t_3) {
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __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 = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_INCREF(__pyx_v_record);
+      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_record);
+      __Pyx_GIVEREF(__pyx_v_record);
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__WRONG_REF); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __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 = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(__pyx_v_faref);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_faref);
+      __Pyx_GIVEREF(__pyx_v_faref);
+      __Pyx_INCREF(__pyx_v_ref);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ref);
+      __Pyx_GIVEREF(__pyx_v_ref);
+      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_64), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_t_4));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+      __pyx_t_1 = 0;
+      __pyx_t_7 = 0;
+      __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L13;
+    }
+    __pyx_L13:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1023
+ *             faref = faref_leftflank[pos-left:]
+ *             if faref != ref: self.error(str(record),self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+ *             ref = faref             # <<<<<<<<<<<<<<
+ * 
+ *         # check: format fields are defined
+ */
+    __Pyx_INCREF(__pyx_v_faref);
+    __Pyx_DECREF(__pyx_v_ref);
+    __pyx_v_ref = __pyx_v_faref;
+    goto __pyx_L12;
+  }
+  __pyx_L12:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1026
+ * 
+ *         # check: format fields are defined
+ *         for f in record.format:             # <<<<<<<<<<<<<<
+ *             if f not in self._format: self.error(str(record),self.FORMAT_NOT_DEFINED, f)
+ * 
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
+    __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+    } else {
+      __pyx_t_4 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_4) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_4);
+    }
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1027
+ *         # check: format fields are defined
+ *         for f in record.format:
+ *             if f not in self._format: self.error(str(record),self.FORMAT_NOT_DEFINED, f)             # <<<<<<<<<<<<<<
+ * 
+ *         # check: all filters are defined
+ */
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___format); 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_t_3 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_4, __pyx_v_f))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    if (__pyx_t_3) {
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); 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_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_record);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
+      __Pyx_GIVEREF(__pyx_v_record);
+      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __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_v_self, __pyx_n_s__FORMAT_NOT_DEFINED); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_f);
+      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_f);
+      __Pyx_GIVEREF(__pyx_v_f);
+      __pyx_t_7 = 0;
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      goto __pyx_L16;
+    }
+    __pyx_L16:;
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1030
+ * 
+ *         # check: all filters are defined
+ *         for f in record.filter:             # <<<<<<<<<<<<<<
+ *             if f not in self._filter: self.error(str(record),self.FILTER_NOT_DEFINED, f)
+ * 
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_6 = 0; __pyx_t_5 = __pyx_t_2; __Pyx_INCREF(__pyx_t_5);
+  } else {
+    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
+      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++;
+    } else {
+      __pyx_t_2 = PyIter_Next(__pyx_t_5);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    __Pyx_DECREF(__pyx_v_f);
+    __pyx_v_f = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1031
+ *         # check: all filters are defined
+ *         for f in record.filter:
+ *             if f not in self._filter: self.error(str(record),self.FILTER_NOT_DEFINED, f)             # <<<<<<<<<<<<<<
+ * 
+ *         # convert v3.3 alleles
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_2, __pyx_v_f))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (__pyx_t_3) {
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __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 = 1031; __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);
+      __Pyx_GIVEREF(__pyx_v_record);
+      __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __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__FILTER_NOT_DEFINED); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
+      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      __Pyx_INCREF(__pyx_v_f);
+      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_f);
+      __Pyx_GIVEREF(__pyx_v_f);
+      __pyx_t_4 = 0;
+      __pyx_t_1 = 0;
+      __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __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_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      goto __pyx_L19;
+    }
+    __pyx_L19:;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1034
+ * 
+ *         # convert v3.3 alleles
+ *         if self._version == 33:             # <<<<<<<<<<<<<<
+ *             if len(ref) != 1: self.error(str(record),self.V33_BAD_REF)
+ *             newalts = []
+ */
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___version); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_int_33, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1035
+ *         # convert v3.3 alleles
+ *         if self._version == 33:
+ *             if len(ref) != 1: self.error(str(record),self.V33_BAD_REF)             # <<<<<<<<<<<<<<
+ *             newalts = []
+ *             have_deletions = False
+ */
+    __pyx_t_6 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = (__pyx_t_6 != 1);
+    if (__pyx_t_3) {
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_v_record);
+      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
+      __Pyx_GIVEREF(__pyx_v_record);
+      __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __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_v_self, __pyx_n_s__V33_BAD_REF); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __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);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_5);
+      __pyx_t_7 = 0;
+      __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      goto __pyx_L21;
+    }
+    __pyx_L21:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1036
+ *         if self._version == 33:
+ *             if len(ref) != 1: self.error(str(record),self.V33_BAD_REF)
+ *             newalts = []             # <<<<<<<<<<<<<<
+ *             have_deletions = False
+ *             for a in alt:
+ */
+    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __Pyx_DECREF(((PyObject *)__pyx_v_newalts));
+    __pyx_v_newalts = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1037
+ *             if len(ref) != 1: self.error(str(record),self.V33_BAD_REF)
+ *             newalts = []
+ *             have_deletions = False             # <<<<<<<<<<<<<<
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ */
+    __pyx_v_have_deletions = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1038
+ *             newalts = []
+ *             have_deletions = False
+ *             for a in alt:             # <<<<<<<<<<<<<<
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ */
+    if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+      __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++;
+      __Pyx_DECREF(__pyx_v_a);
+      __pyx_v_a = __pyx_t_2;
+      __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1039
+ *             have_deletions = False
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference             # <<<<<<<<<<<<<<
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ */
+      __pyx_t_8 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = (__pyx_t_8 == 1);
+      if (__pyx_t_3) {
+        __pyx_t_2 = PySequence_GetSlice(__pyx_v_ref, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_1 = PyNumber_Add(__pyx_v_a, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_v_a);
+        __pyx_v_a = __pyx_t_1;
+        __pyx_t_1 = 0;
+        goto __pyx_L24;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1040
+ *             for a in alt:
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference             # <<<<<<<<<<<<<<
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True
+ */
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_n_s__I));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__I));
+      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__I));
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __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 = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (__pyx_t_3) {
+        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_2 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PySequence_GetSlice(__pyx_v_ref, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_v_a);
+        __pyx_v_a = __pyx_t_7;
+        __pyx_t_7 = 0;
+        goto __pyx_L24;
+      }
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1041
+ *                 if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>             # <<<<<<<<<<<<<<
+ *                     have_deletions = True
+ *                     try:
+ */
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__startswith); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __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 = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_INCREF(((PyObject *)__pyx_n_s__D));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__D));
+      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__D));
+      __pyx_t_1 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __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 = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      if (__pyx_t_3) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1042
+ *                 elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True             # <<<<<<<<<<<<<<
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ */
+        __pyx_v_have_deletions = 1;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1043
+ *                 elif a.startswith('D'): # allow D<seq> and D<num>
+ *                     have_deletions = True
+ *                     try:             # <<<<<<<<<<<<<<
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary
+ */
+        {
+          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
+          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
+          __Pyx_XGOTREF(__pyx_save_exc_type);
+          __Pyx_XGOTREF(__pyx_save_exc_value);
+          __Pyx_XGOTREF(__pyx_save_exc_tb);
+          /*try:*/ {
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1044
+ *                     have_deletions = True
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence             # <<<<<<<<<<<<<<
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ */
+            __pyx_t_1 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_GOTREF(__pyx_t_2);
+            PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+            __Pyx_GIVEREF(__pyx_t_1);
+            __pyx_t_1 = 0;
+            __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+            __Pyx_DECREF(__pyx_v_l);
+            __pyx_v_l = __pyx_t_1;
+            __pyx_t_1 = 0;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1045
+ *                     try:
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary             # <<<<<<<<<<<<<<
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns
+ */
+            __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_l, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L25_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 = 1045; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+            if (__pyx_t_3) {
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1046
+ *                         l = int(a[1:])          # throws ValueError if sequence
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)             # <<<<<<<<<<<<<<
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ */
+              __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_2);
+              __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __pyx_t_7 = PyNumber_Add(__pyx_v_pos, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+              __pyx_t_1 = PyNumber_Add(__pyx_v_pos, __pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_4);
+              __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_10);
+              __Pyx_INCREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
+              __Pyx_GIVEREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7);
+              __Pyx_GIVEREF(__pyx_t_7);
+              PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_1);
+              __Pyx_GIVEREF(__pyx_t_1);
+              PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_4);
+              __Pyx_GIVEREF(__pyx_t_4);
+              __pyx_t_7 = 0;
+              __pyx_t_1 = 0;
+              __pyx_t_4 = 0;
+              __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_4);
+              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __Pyx_DECREF(__pyx_v_addns);
+              __pyx_v_addns = __pyx_t_4;
+              __pyx_t_4 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1047
+ *                         if len(ref) < l:        # add to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns             # <<<<<<<<<<<<<<
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ */
+              __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addns); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              __Pyx_GOTREF(__pyx_t_4);
+              __Pyx_DECREF(__pyx_v_ref);
+              __pyx_v_ref = __pyx_t_4;
+              __pyx_t_4 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1048
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns             # <<<<<<<<<<<<<<
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:
+ */
+              __Pyx_INCREF(__pyx_int_0);
+              __pyx_t_4 = __pyx_int_0;
+              if (likely(((PyObject *)__pyx_v_newalts) != Py_None)) {
+                __pyx_t_8 = 0; __pyx_t_10 = ((PyObject *)__pyx_v_newalts); __Pyx_INCREF(__pyx_t_10);
+              } else {
+                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+              }
+              for (;;) {
+                if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_10)) break;
+                __pyx_t_2 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
+                __Pyx_DECREF(__pyx_v_na);
+                __pyx_v_na = __pyx_t_2;
+                __pyx_t_2 = 0;
+                __Pyx_INCREF(__pyx_t_4);
+                __Pyx_DECREF(__pyx_v_i);
+                __pyx_v_i = __pyx_t_4;
+                __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+                __Pyx_GOTREF(__pyx_t_2);
+                __Pyx_DECREF(__pyx_t_4);
+                __pyx_t_4 = __pyx_t_2;
+                __pyx_t_2 = 0;
+                __pyx_t_2 = PyNumber_Add(__pyx_v_na, __pyx_v_addns); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+                __Pyx_GOTREF(__pyx_t_2);
+                if (PyObject_SetItem(((PyObject *)__pyx_v_newalts), __pyx_v_i, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+              }
+              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+              goto __pyx_L33;
+            }
+            __pyx_L33:;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1049
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l             # <<<<<<<<<<<<<<
+ *                     except ValueError:
+ *                         s = a[1:]
+ */
+            __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_l); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __pyx_t_4 = PySequence_GetSlice(__pyx_v_ref, __pyx_t_8, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_DECREF(__pyx_v_a);
+            __pyx_v_a = __pyx_t_4;
+            __pyx_t_4 = 0;
+          }
+          __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
+          __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
+          __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
+          goto __pyx_L32_try_end;
+          __pyx_L25_error:;
+          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
+          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1050
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:             # <<<<<<<<<<<<<<
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ */
+          __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
+          if (__pyx_t_11) {
+            __Pyx_AddTraceback("cvcf.VCF.validate");
+            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_10, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __Pyx_GOTREF(__pyx_t_4);
+            __Pyx_GOTREF(__pyx_t_10);
+            __Pyx_GOTREF(__pyx_t_2);
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1051
+ *                         a = ref[l:]             # new deletion, deleting pos...pos+l
+ *                     except ValueError:
+ *                         s = a[1:]             # <<<<<<<<<<<<<<
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ */
+            __pyx_t_1 = PySequence_GetSlice(__pyx_v_a, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_DECREF(__pyx_v_s);
+            __pyx_v_s = __pyx_t_1;
+            __pyx_t_1 = 0;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1052
+ *                     except ValueError:
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary             # <<<<<<<<<<<<<<
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ */
+            __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __pyx_t_12 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __pyx_t_3 = (__pyx_t_8 < __pyx_t_12);
+            if (__pyx_t_3) {
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1053
+ *                         s = a[1:]
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)             # <<<<<<<<<<<<<<
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(str(record),self.V33_UNMATCHED_DELETION,
+ */
+              __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __pyx_t_12 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __pyx_t_13 = PyNumber_Add(__pyx_v_pos, __pyx_t_7); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_13);
+              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+              __pyx_t_12 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __pyx_t_14 = PyNumber_Add(__pyx_v_pos, __pyx_t_7); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_14);
+              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+              __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_15);
+              __Pyx_INCREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_chrom);
+              __Pyx_GIVEREF(__pyx_v_chrom);
+              PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_13);
+              __Pyx_GIVEREF(__pyx_t_13);
+              PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_14);
+              __Pyx_GIVEREF(__pyx_t_14);
+              PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_7);
+              __Pyx_GIVEREF(__pyx_t_7);
+              __pyx_t_13 = 0;
+              __pyx_t_14 = 0;
+              __pyx_t_7 = 0;
+              __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+              __Pyx_DECREF(__pyx_v_addns);
+              __pyx_v_addns = __pyx_t_7;
+              __pyx_t_7 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1054
+ *                         if len(ref) < len(s):   # add Ns to reference if necessary
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):             # <<<<<<<<<<<<<<
+ *                                 self.error(str(record),self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ */
+              __pyx_t_7 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__endswith); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_7);
+              __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_15);
+              __Pyx_INCREF(__pyx_v_addns);
+              PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_addns);
+              __Pyx_GIVEREF(__pyx_v_addns);
+              __pyx_t_1 = PyObject_Call(__pyx_t_7, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+              __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+              __pyx_t_16 = (!__pyx_t_3);
+              if (__pyx_t_16) {
+                __pyx_t_12 = PyObject_Length(__pyx_v_addns); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                __pyx_t_15 = PyNumber_Multiply(((PyObject *)__pyx_n_s__N), __pyx_t_1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(((PyObject *)__pyx_t_15));
+                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+                __pyx_t_1 = PyObject_RichCompare(__pyx_v_addns, ((PyObject *)__pyx_t_15), Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
+                __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+                __pyx_t_17 = __pyx_t_3;
+              } else {
+                __pyx_t_17 = __pyx_t_16;
+              }
+              if (__pyx_t_17) {
+
+                /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1055
+ *                             addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(str(record),self.V33_UNMATCHED_DELETION,             # <<<<<<<<<<<<<<
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns
+ */
+                __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_15);
+                __Pyx_INCREF(__pyx_v_record);
+                PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_record);
+                __Pyx_GIVEREF(__pyx_v_record);
+                __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_15, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_7);
+                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+                __pyx_t_15 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_65); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_15);
+
+                /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1056
+ *                             if not s.endswith(addns) and addns != 'N'*len(addns):
+ *                                 self.error(str(record),self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))             # <<<<<<<<<<<<<<
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ */
+                __pyx_t_14 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_14);
+                __pyx_t_12 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __pyx_t_13 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_13);
+                __pyx_t_18 = PyNumber_Add(__pyx_v_pos, __pyx_t_13); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_18);
+                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+                __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_13);
+                __pyx_t_19 = PyTuple_New(4); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_19);
+                __Pyx_INCREF(__pyx_v_chrom);
+                PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_chrom);
+                __Pyx_GIVEREF(__pyx_v_chrom);
+                __Pyx_INCREF(__pyx_v_pos);
+                PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_v_pos);
+                __Pyx_GIVEREF(__pyx_v_pos);
+                PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_18);
+                __Pyx_GIVEREF(__pyx_t_18);
+                PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_13);
+                __Pyx_GIVEREF(__pyx_t_13);
+                __pyx_t_18 = 0;
+                __pyx_t_13 = 0;
+                __pyx_t_13 = PyObject_Call(__pyx_t_14, __pyx_t_19, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_13);
+                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+                __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_19);
+                __Pyx_INCREF(__pyx_v_a);
+                PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_v_a);
+                __Pyx_GIVEREF(__pyx_v_a);
+                PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_13);
+                __Pyx_GIVEREF(__pyx_t_13);
+                __pyx_t_13 = 0;
+                __pyx_t_13 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), __pyx_t_19); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(((PyObject *)__pyx_t_13));
+                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+                __pyx_t_19 = PyTuple_New(3); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_19);
+                PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_7);
+                __Pyx_GIVEREF(__pyx_t_7);
+                PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_15);
+                __Pyx_GIVEREF(__pyx_t_15);
+                PyTuple_SET_ITEM(__pyx_t_19, 2, ((PyObject *)__pyx_t_13));
+                __Pyx_GIVEREF(((PyObject *)__pyx_t_13));
+                __pyx_t_7 = 0;
+                __pyx_t_15 = 0;
+                __pyx_t_13 = 0;
+                __pyx_t_13 = PyObject_Call(__pyx_t_1, __pyx_t_19, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_13);
+                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+                goto __pyx_L39;
+              }
+              __pyx_L39:;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1057
+ *                                 self.error(str(record),self.V33_UNMATCHED_DELETION,
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns             # <<<<<<<<<<<<<<
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ */
+              __pyx_t_13 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addns); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              __Pyx_GOTREF(__pyx_t_13);
+              __Pyx_DECREF(__pyx_v_ref);
+              __pyx_v_ref = __pyx_t_13;
+              __pyx_t_13 = 0;
+
+              /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1058
+ *                                            "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns             # <<<<<<<<<<<<<<
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ *                 else:
+ */
+              __Pyx_INCREF(__pyx_int_0);
+              __pyx_t_13 = __pyx_int_0;
+              if (likely(((PyObject *)__pyx_v_newalts) != Py_None)) {
+                __pyx_t_12 = 0; __pyx_t_19 = ((PyObject *)__pyx_v_newalts); __Pyx_INCREF(__pyx_t_19);
+              } else {
+                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+              }
+              for (;;) {
+                if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_19)) break;
+                __pyx_t_1 = PyList_GET_ITEM(__pyx_t_19, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++;
+                __Pyx_DECREF(__pyx_v_na);
+                __pyx_v_na = __pyx_t_1;
+                __pyx_t_1 = 0;
+                __Pyx_INCREF(__pyx_t_13);
+                __Pyx_DECREF(__pyx_v_i);
+                __pyx_v_i = __pyx_t_13;
+                __pyx_t_1 = PyNumber_Add(__pyx_t_13, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                __Pyx_DECREF(__pyx_t_13);
+                __pyx_t_13 = __pyx_t_1;
+                __pyx_t_1 = 0;
+                __pyx_t_1 = PyNumber_Add(__pyx_v_na, __pyx_v_addns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_GOTREF(__pyx_t_1);
+                if (PyObject_SetItem(((PyObject *)__pyx_v_newalts), __pyx_v_i, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+              }
+              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+              goto __pyx_L38;
+            }
+            __pyx_L38:;
+
+            /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1059
+ *                             ref += addns
+ *                             for i,na in enumerate(newalts): newalts[i] = na+addns
+ *                         a = ref[len(s):]        # new deletion, deleting from pos             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     self.error(str(record),self.V33_BAD_ALLELE)
+ */
+            __pyx_t_12 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __pyx_t_13 = PySequence_GetSlice(__pyx_v_ref, __pyx_t_12, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
+            __Pyx_GOTREF(__pyx_t_13);
+            __Pyx_DECREF(__pyx_v_a);
+            __pyx_v_a = __pyx_t_13;
+            __pyx_t_13 = 0;
+            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+            goto __pyx_L26_exception_handled;
+          }
+          __pyx_L27_except_error:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          goto __pyx_L1_error;
+          __pyx_L26_exception_handled:;
+          __Pyx_XGIVEREF(__pyx_save_exc_type);
+          __Pyx_XGIVEREF(__pyx_save_exc_value);
+          __Pyx_XGIVEREF(__pyx_save_exc_tb);
+          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
+          __pyx_L32_try_end:;
+        }
+        goto __pyx_L24;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1061
+ *                         a = ref[len(s):]        # new deletion, deleting from pos
+ *                 else:
+ *                     self.error(str(record),self.V33_BAD_ALLELE)             # <<<<<<<<<<<<<<
+ *                 newalts.append(a)
+ *             alt = newalts
+ */
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_record);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_record);
+        __Pyx_GIVEREF(__pyx_v_record);
+        __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__V33_BAD_ALLELE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        __pyx_t_4 = 0;
+        __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      }
+      __pyx_L24:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1062
+ *                 else:
+ *                     self.error(str(record),self.V33_BAD_ALLELE)
+ *                 newalts.append(a)             # <<<<<<<<<<<<<<
+ *             alt = newalts
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ */
+      if (unlikely(__pyx_v_newalts == Py_None)) {
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      }
+      __pyx_t_11 = PyList_Append(((PyObject *)__pyx_v_newalts), __pyx_v_a); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1063
+ *                     self.error(str(record),self.V33_BAD_ALLELE)
+ *                 newalts.append(a)
+ *             alt = newalts             # <<<<<<<<<<<<<<
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:
+ */
+    __Pyx_INCREF(((PyObject *)__pyx_v_newalts));
+    __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+    __pyx_v_alt = __pyx_v_newalts;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1065
+ *             alt = newalts
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:             # <<<<<<<<<<<<<<
+ *                 if pos == 0:
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ */
+    if (__pyx_v_have_deletions) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1066
+ *             # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+ *             if have_deletions:
+ *                 if pos == 0:             # <<<<<<<<<<<<<<
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ */
+      __pyx_t_5 = PyObject_RichCompare(__pyx_v_pos, __pyx_int_0, Py_EQ); 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_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      if (__pyx_t_17) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1068
+ *                 if pos == 0:
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)             # <<<<<<<<<<<<<<
+ *                     ref += addn
+ *                     alt = [allele+addn for allele in alt]
+ */
+        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_6 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_13 = PyNumber_Add(__pyx_v_pos, __pyx_t_10); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_t_6 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_2 = PyNumber_Add(__pyx_v_pos, __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_t_10 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_INCREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_chrom);
+        __Pyx_GIVEREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_13);
+        __Pyx_GIVEREF(__pyx_t_13);
+        PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_13 = 0;
+        __pyx_t_10 = 0;
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __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_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_v_addn);
+        __pyx_v_addn = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1069
+ *                     # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ *                     ref += addn             # <<<<<<<<<<<<<<
+ *                     alt = [allele+addn for allele in alt]
+ *                 else:
+ */
+        __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_ref, __pyx_v_addn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1070
+ *                     addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+ *                     ref += addn
+ *                     alt = [allele+addn for allele in alt]             # <<<<<<<<<<<<<<
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ */
+        __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+          __pyx_t_6 = 0; __pyx_t_4 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_4);
+        } else {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        for (;;) {
+          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
+          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++;
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_5;
+          __pyx_t_5 = 0;
+          __pyx_t_5 = PyNumber_Add(__pyx_v_allele, __pyx_v_addn); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_2));
+        __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+        __pyx_v_alt = __pyx_t_2;
+        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+        goto __pyx_L43;
+      }
+      /*else*/ {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1072
+ *                     alt = [allele+addn for allele in alt]
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)             # <<<<<<<<<<<<<<
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]
+ */
+        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__get_sequence); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_4 = PyNumber_Subtract(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
+        __Pyx_GIVEREF(__pyx_v_chrom);
+        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        __Pyx_INCREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_pos);
+        __Pyx_GIVEREF(__pyx_v_pos);
+        PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_5);
+        __pyx_t_4 = 0;
+        __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_v_addn);
+        __pyx_v_addn = __pyx_t_5;
+        __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1073
+ *                 else:
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ *                     ref = addn + ref             # <<<<<<<<<<<<<<
+ *                     alt = [addn + allele for allele in alt]
+ *                     pos -= 1
+ */
+        __pyx_t_5 = PyNumber_Add(__pyx_v_addn, __pyx_v_ref); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_5;
+        __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1074
+ *                     addn = get_sequence(chrom,pos-1,pos,self._reference)
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]             # <<<<<<<<<<<<<<
+ *                     pos -= 1
+ *         else:
+ */
+        __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+        if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+          __pyx_t_6 = 0; __pyx_t_10 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_10);
+        } else {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        for (;;) {
+          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_10)) break;
+          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++;
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_2;
+          __pyx_t_2 = 0;
+          __pyx_t_2 = PyNumber_Add(__pyx_v_addn, __pyx_v_allele); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_2);
+          if (unlikely(PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_5));
+        __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+        __pyx_v_alt = __pyx_t_5;
+        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1075
+ *                     ref = addn + ref
+ *                     alt = [addn + allele for allele in alt]
+ *                     pos -= 1             # <<<<<<<<<<<<<<
+ *         else:
+ *             # format v4.0 -- just check for nucleotides
+ */
+        __pyx_t_5 = PyNumber_InPlaceSubtract(__pyx_v_pos, __pyx_int_1); 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_DECREF(__pyx_v_pos);
+        __pyx_v_pos = __pyx_t_5;
+        __pyx_t_5 = 0;
+      }
+      __pyx_L43:;
+      goto __pyx_L42;
+    }
+    __pyx_L42:;
+    goto __pyx_L20;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1078
+ *         else:
+ *             # format v4.0 -- just check for nucleotides
+ *             for allele in alt:             # <<<<<<<<<<<<<<
+ *                 if not alleleRegEx.match(allele):
+ *                     self.error(str(record),self.V40_BAD_ALLELE,allele)
+ */
+    if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+      __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_10 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_10); __pyx_t_6++;
+      __Pyx_DECREF(__pyx_v_allele);
+      __pyx_v_allele = __pyx_t_10;
+      __pyx_t_10 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1079
+ *             # format v4.0 -- just check for nucleotides
+ *             for allele in alt:
+ *                 if not alleleRegEx.match(allele):             # <<<<<<<<<<<<<<
+ *                     self.error(str(record),self.V40_BAD_ALLELE,allele)
+ * 
+ */
+      __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__alleleRegEx); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__match); 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(__pyx_t_10); __pyx_t_10 = 0;
+      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_INCREF(__pyx_v_allele);
+      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_allele);
+      __Pyx_GIVEREF(__pyx_v_allele);
+      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __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_10); __pyx_t_10 = 0;
+      __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_16 = (!__pyx_t_17);
+      if (__pyx_t_16) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1080
+ *             for allele in alt:
+ *                 if not alleleRegEx.match(allele):
+ *                     self.error(str(record),self.V40_BAD_ALLELE,allele)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+        __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_record);
+        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_record);
+        __Pyx_GIVEREF(__pyx_v_record);
+        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__V40_BAD_ALLELE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        __Pyx_INCREF(__pyx_v_allele);
+        PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_allele);
+        __Pyx_GIVEREF(__pyx_v_allele);
+        __pyx_t_2 = 0;
+        __pyx_t_10 = 0;
+        __pyx_t_10 = PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        goto __pyx_L50;
+      }
+      __pyx_L50:;
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  }
+  __pyx_L20:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1084
+ * 
+ *         # check for leading nucleotide in indel calls
+ *         for allele in alt:             # <<<<<<<<<<<<<<
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)
+ */
+  if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+    __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  for (;;) {
+    if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+    __pyx_t_10 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_10); __pyx_t_6++;
+    __Pyx_DECREF(__pyx_v_allele);
+    __pyx_v_allele = __pyx_t_10;
+    __pyx_t_10 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1085
+ *         # check for leading nucleotide in indel calls
+ *         for allele in alt:
+ *             if len(allele) != len(ref):             # <<<<<<<<<<<<<<
+ *                 if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ */
+    __pyx_t_12 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_16 = (__pyx_t_12 != __pyx_t_8);
+    if (__pyx_t_16) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1086
+ *         for allele in alt:
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)             # <<<<<<<<<<<<<<
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ *                     self.error(str(record),self.MISSING_INDEL_ALLELE_REF_BASE)
+ */
+      __pyx_t_8 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_16 = (__pyx_t_8 == 0);
+      if (__pyx_t_16) {
+        __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_INCREF(__pyx_v_record);
+        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_record);
+        __Pyx_GIVEREF(__pyx_v_record);
+        __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_13, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__ZERO_LENGTH_ALLELE); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
+        __Pyx_GIVEREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_13);
+        __Pyx_GIVEREF(__pyx_t_13);
+        __pyx_t_4 = 0;
+        __pyx_t_13 = 0;
+        __pyx_t_13 = PyObject_Call(__pyx_t_10, __pyx_t_2, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        goto __pyx_L54;
+      }
+      __pyx_L54:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1087
+ *             if len(allele) != len(ref):
+ *                 if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():             # <<<<<<<<<<<<<<
+ *                     self.error(str(record),self.MISSING_INDEL_ALLELE_REF_BASE)
+ * 
+ */
+      __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__upper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_allele, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_10 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__upper); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      __pyx_t_10 = PyObject_RichCompare(__pyx_t_13, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      if (__pyx_t_16) {
+        __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_ref, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_allele, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_13 = PyNumber_Add(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__upper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_17 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_13, ((PyObject *)__pyx_n_s__N)))); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_3 = __pyx_t_17;
+      } else {
+        __pyx_t_3 = __pyx_t_16;
+      }
+      if (__pyx_t_3) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1088
+ *                 if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)
+ *                 if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+ *                     self.error(str(record),self.MISSING_INDEL_ALLELE_REF_BASE)             # <<<<<<<<<<<<<<
+ * 
+ *         # trim trailing bases in alleles
+ */
+        __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__error); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_INCREF(__pyx_v_record);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_record);
+        __Pyx_GIVEREF(__pyx_v_record);
+        __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_10);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s_67); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10);
+        __Pyx_GIVEREF(__pyx_t_10);
+        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
+        __Pyx_GIVEREF(__pyx_t_2);
+        __pyx_t_10 = 0;
+        __pyx_t_2 = 0;
+        __pyx_t_2 = PyObject_Call(__pyx_t_13, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        goto __pyx_L55;
+      }
+      __pyx_L55:;
+      goto __pyx_L53;
+    }
+    __pyx_L53:;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1091
+ * 
+ *         # trim trailing bases in alleles
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):             # <<<<<<<<<<<<<<
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break
+ */
+  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_INCREF(__pyx_builtin_len);
+  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_builtin_len);
+  __Pyx_GIVEREF(__pyx_builtin_len);
+  __Pyx_INCREF(((PyObject *)__pyx_v_alt));
+  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_alt));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_alt));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_map, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__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 = 1091; __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);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_min, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_8 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_13 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_LT); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  if (__pyx_t_3) {
+    __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_5 = __pyx_t_2;
+  } else {
+    __pyx_t_13 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_13);
+    __pyx_t_5 = __pyx_t_13;
+    __pyx_t_13 = 0;
+  }
+  __Pyx_DECREF(__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 = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_int_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
+  __Pyx_GIVEREF(__pyx_int_1);
+  __Pyx_INCREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
+    __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_5; __Pyx_INCREF(__pyx_t_2);
+  } else {
+    __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  for (;;) {
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++;
+    } else {
+      __pyx_t_5 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_5) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_5);
+    }
+    __Pyx_DECREF(__pyx_v_i);
+    __pyx_v_i = __pyx_t_5;
+    __pyx_t_5 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1092
+ *         # trim trailing bases in alleles
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():             # <<<<<<<<<<<<<<
+ *                 break
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+ */
+    __pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+      __pyx_t_8 = 0; __pyx_t_13 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_13);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_13)) break;
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++;
+      __Pyx_DECREF(__pyx_8genexpr1__pyx_v_allele);
+      __pyx_8genexpr1__pyx_v_allele = __pyx_t_4;
+      __pyx_t_4 = 0;
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_8genexpr1__pyx_v_allele, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __pyx_t_10 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__upper); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+      if (unlikely(PySet_Add(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+    __pyx_t_8 = PySet_Size(((PyObject *)__pyx_t_5)); 
+    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+    __pyx_t_3 = (__pyx_t_8 > 1);
+    if (!__pyx_t_3) {
+      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_ref, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_13 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__upper); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_13 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_alt), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_13, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_13 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__upper); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_4 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_13 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_17 = __pyx_t_16;
+    } else {
+      __pyx_t_17 = __pyx_t_3;
+    }
+    if (__pyx_t_17) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1093
+ *         for i in range(1,min(len(ref),min(map(len,alt)))):
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break             # <<<<<<<<<<<<<<
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+ * 
+ */
+      goto __pyx_L57_break;
+      goto __pyx_L58;
+    }
+    __pyx_L58:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1094
+ *             if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+ *                 break
+ *             ref, alt = ref[:-1], [allele[:-1] for allele in alt]             # <<<<<<<<<<<<<<
+ * 
+ *         # left-align alleles, if a reference is available
+ */
+    __pyx_t_13 = PySequence_GetSlice(__pyx_v_ref, 0, -1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_13);
+    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+      __pyx_t_8 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+    } else {
+      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    for (;;) {
+      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
+      __pyx_t_10 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++;
+      __Pyx_DECREF(__pyx_v_allele);
+      __pyx_v_allele = __pyx_t_10;
+      __pyx_t_10 = 0;
+      __pyx_t_10 = PySequence_GetSlice(__pyx_v_allele, 0, -1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      if (unlikely(PyList_Append(__pyx_t_4, (PyObject*)__pyx_t_10))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = ((PyObject *)__pyx_t_4);
+    __Pyx_INCREF(__pyx_t_5);
+    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_v_ref);
+    __pyx_v_ref = __pyx_t_13;
+    __pyx_t_13 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+    __pyx_v_alt = ((PyObject *)__pyx_t_5);
+    __pyx_t_5 = 0;
+  }
+  __pyx_L57_break:;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1097
+ * 
+ *         # left-align alleles, if a reference is available
+ *         if self._leftalign and self._reference:             # <<<<<<<<<<<<<<
+ *             while left < pos:
+ *                 movable = True
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___leftalign); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_17) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___reference); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_16 = __pyx_t_3;
+  } else {
+    __pyx_t_16 = __pyx_t_17;
+  }
+  if (__pyx_t_16) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1098
+ *         # left-align alleles, if a reference is available
+ *         if self._leftalign and self._reference:
+ *             while left < pos:             # <<<<<<<<<<<<<<
+ *                 movable = True
+ *                 for allele in alt:
+ */
+    while (1) {
+      __pyx_t_2 = PyObject_RichCompare(__pyx_v_left, __pyx_v_pos, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      if (!__pyx_t_16) break;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1099
+ *         if self._leftalign and self._reference:
+ *             while left < pos:
+ *                 movable = True             # <<<<<<<<<<<<<<
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):
+ */
+      __pyx_v_movable = 1;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1100
+ *             while left < pos:
+ *                 movable = True
+ *                 for allele in alt:             # <<<<<<<<<<<<<<
+ *                     if len(allele) > len(ref):
+ *                         longest, shortest = allele, ref
+ */
+      if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+        __pyx_t_6 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_2);
+      } else {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      for (;;) {
+        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++;
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_5;
+        __pyx_t_5 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1101
+ *                 movable = True
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):             # <<<<<<<<<<<<<<
+ *                         longest, shortest = allele, ref
+ *                     else:
+ */
+        __pyx_t_8 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_16 = (__pyx_t_8 > __pyx_t_12);
+        if (__pyx_t_16) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1102
+ *                 for allele in alt:
+ *                     if len(allele) > len(ref):
+ *                         longest, shortest = allele, ref             # <<<<<<<<<<<<<<
+ *                     else:
+ *                         longest, shortest = ref, allele
+ */
+          __pyx_t_5 = __pyx_v_allele;
+          __Pyx_INCREF(__pyx_t_5);
+          __pyx_t_13 = __pyx_v_ref;
+          __Pyx_INCREF(__pyx_t_13);
+          __Pyx_DECREF(__pyx_v_longest);
+          __pyx_v_longest = __pyx_t_5;
+          __pyx_t_5 = 0;
+          __Pyx_DECREF(__pyx_v_shortest);
+          __pyx_v_shortest = __pyx_t_13;
+          __pyx_t_13 = 0;
+          goto __pyx_L68;
+        }
+        /*else*/ {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1104
+ *                         longest, shortest = allele, ref
+ *                     else:
+ *                         longest, shortest = ref, allele             # <<<<<<<<<<<<<<
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False
+ */
+          __pyx_t_13 = __pyx_v_ref;
+          __Pyx_INCREF(__pyx_t_13);
+          __pyx_t_5 = __pyx_v_allele;
+          __Pyx_INCREF(__pyx_t_5);
+          __Pyx_DECREF(__pyx_v_longest);
+          __pyx_v_longest = __pyx_t_13;
+          __pyx_t_13 = 0;
+          __Pyx_DECREF(__pyx_v_shortest);
+          __pyx_v_shortest = __pyx_t_5;
+          __pyx_t_5 = 0;
+        }
+        __pyx_L68:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1105
+ *                     else:
+ *                         longest, shortest = ref, allele
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():             # <<<<<<<<<<<<<<
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ */
+        __pyx_t_12 = PyObject_Length(__pyx_v_longest); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_16 = (__pyx_t_12 == __pyx_t_8);
+        if (!__pyx_t_16) {
+          __pyx_t_8 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PySequence_GetSlice(__pyx_v_longest, 0, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __pyx_t_13 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__upper); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __pyx_t_5 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __pyx_t_13 = PyObject_GetAttr(__pyx_v_shortest, __pyx_n_s__upper); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __pyx_t_4 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __pyx_t_13 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __pyx_t_3 = __pyx_t_17;
+        } else {
+          __pyx_t_3 = __pyx_t_16;
+        }
+        if (__pyx_t_3) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1106
+ *                         longest, shortest = ref, allele
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False             # <<<<<<<<<<<<<<
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False
+ */
+          __pyx_v_movable = 0;
+          goto __pyx_L69;
+        }
+        __pyx_L69:;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1107
+ *                     if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():             # <<<<<<<<<<<<<<
+ *                         movable = False
+ *                 if not movable:
+ */
+        __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_longest, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __pyx_t_4 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__upper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_13 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_8 = PyObject_Length(__pyx_v_shortest); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = (__pyx_t_8 - 1);
+        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_longest, __pyx_t_12, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__upper); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_RichCompare(__pyx_t_13, __pyx_t_4, Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        if (__pyx_t_3) {
+
+          /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1108
+ *                         movable = False
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False             # <<<<<<<<<<<<<<
+ *                 if not movable:
+ *                     break
+ */
+          __pyx_v_movable = 0;
+          goto __pyx_L70;
+        }
+        __pyx_L70:;
+      }
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1109
+ *                     if longest[-1].upper() != longest[len(shortest)-1].upper():
+ *                         movable = False
+ *                 if not movable:             # <<<<<<<<<<<<<<
+ *                     break
+ *                 ref = ref[:-1]
+ */
+      __pyx_t_3 = (!__pyx_v_movable);
+      if (__pyx_t_3) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1110
+ *                         movable = False
+ *                 if not movable:
+ *                     break             # <<<<<<<<<<<<<<
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]
+ */
+        goto __pyx_L65_break;
+        goto __pyx_L71;
+      }
+      __pyx_L71:;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1111
+ *                 if not movable:
+ *                     break
+ *                 ref = ref[:-1]             # <<<<<<<<<<<<<<
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ */
+      __pyx_t_2 = PySequence_GetSlice(__pyx_v_ref, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_v_ref);
+      __pyx_v_ref = __pyx_t_2;
+      __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1112
+ *                     break
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]             # <<<<<<<<<<<<<<
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ */
+      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+        __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+      } else {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      for (;;) {
+        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_4;
+        __pyx_t_4 = 0;
+        __pyx_t_4 = PySequence_GetSlice(__pyx_v_allele, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      }
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_INCREF(((PyObject *)__pyx_t_2));
+      __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+      __pyx_v_alt = __pyx_t_2;
+      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+
+      /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1113
+ *                 ref = ref[:-1]
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:             # <<<<<<<<<<<<<<
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ */
+      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+        __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+      } else {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      for (;;) {
+        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+        __Pyx_DECREF(__pyx_v_allele);
+        __pyx_v_allele = __pyx_t_4;
+        __pyx_t_4 = 0;
+        __pyx_t_12 = PyObject_Length(__pyx_v_allele); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
+        if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      }
+      __Pyx_DECREF(__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 = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(((PyObject *)__pyx_t_2));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_min, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __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 = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      if (!__pyx_t_3) {
+        __pyx_t_6 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_16 = (__pyx_t_6 == 0);
+        __pyx_t_17 = __pyx_t_16;
+      } else {
+        __pyx_t_17 = __pyx_t_3;
+      }
+      if (__pyx_t_17) {
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1114
+ *                 alt = [allele[:-1] for allele in alt]
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref             # <<<<<<<<<<<<<<
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ *                     pos -= 1
+ */
+        __pyx_t_5 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_5 = PyObject_GetItem(__pyx_v_faref_leftflank, __pyx_t_2); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_v_ref);
+        __pyx_v_ref = __pyx_t_2;
+        __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1115
+ *                 if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]             # <<<<<<<<<<<<<<
+ *                     pos -= 1
+ * 
+ */
+        __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        if (likely(((PyObject *)__pyx_v_alt) != Py_None)) {
+          __pyx_t_6 = 0; __pyx_t_5 = ((PyObject *)__pyx_v_alt); __Pyx_INCREF(__pyx_t_5);
+        } else {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        for (;;) {
+          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++;
+          __Pyx_DECREF(__pyx_v_allele);
+          __pyx_v_allele = __pyx_t_4;
+          __pyx_t_4 = 0;
+          __pyx_t_4 = PyNumber_Subtract(__pyx_v_pos, __pyx_v_left); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_4);
+          __pyx_t_13 = PyNumber_Subtract(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          __pyx_t_4 = PyObject_GetItem(__pyx_v_faref_leftflank, __pyx_t_13); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_4);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+          __pyx_t_13 = PyNumber_Add(__pyx_t_4, __pyx_v_allele); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+          if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_13))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __Pyx_INCREF(((PyObject *)__pyx_t_2));
+        __Pyx_DECREF(((PyObject *)__pyx_v_alt));
+        __pyx_v_alt = __pyx_t_2;
+        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+
+        /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1116
+ *                     ref = faref_leftflank[pos-left-1] + ref
+ *                     alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+ *                     pos -= 1             # <<<<<<<<<<<<<<
+ * 
+ * __all__ = [
+ */
+        __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_v_pos, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        __Pyx_DECREF(__pyx_v_pos);
+        __pyx_v_pos = __pyx_t_2;
+        __pyx_t_2 = 0;
+        goto __pyx_L74;
+      }
+      __pyx_L74:;
+    }
+    __pyx_L65_break:;
+    goto __pyx_L63;
+  }
+  __pyx_L63:;
+
+  __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_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_XDECREF(__pyx_t_18);
+  __Pyx_XDECREF(__pyx_t_19);
+  __Pyx_AddTraceback("cvcf.VCF.validate");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_chrom);
+  __Pyx_DECREF(__pyx_v_pos);
+  __Pyx_DECREF(__pyx_v_ref);
+  __Pyx_DECREF(__pyx_v_c);
+  __Pyx_DECREF(__pyx_v_left);
+  __Pyx_DECREF(__pyx_v_faref_leftflank);
+  __Pyx_DECREF(__pyx_v_faref);
+  __Pyx_DECREF(__pyx_v_f);
+  __Pyx_DECREF(__pyx_v_newalts);
+  __Pyx_DECREF(__pyx_v_a);
+  __Pyx_DECREF(__pyx_v_l);
+  __Pyx_DECREF(__pyx_v_addns);
+  __Pyx_DECREF(__pyx_v_i);
+  __Pyx_DECREF(__pyx_v_na);
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_DECREF(__pyx_v_alt);
+  __Pyx_DECREF(__pyx_v_addn);
+  __Pyx_DECREF(__pyx_v_allele);
+  __Pyx_DECREF(__pyx_v_longest);
+  __Pyx_DECREF(__pyx_v_shortest);
+  __Pyx_DECREF(__pyx_8genexpr1__pyx_v_allele);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static struct __pyx_vtabstruct_4cvcf_VCFRecord __pyx_vtable_4cvcf_VCFRecord;
+
+static PyObject *__pyx_tp_new_4cvcf_VCFRecord(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_4cvcf_VCFRecord *p;
+  PyObject *o = __pyx_ptype_10TabProxies_TupleProxy->tp_new(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_4cvcf_VCFRecord *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10TabProxies_TupleProxy*)__pyx_vtabptr_4cvcf_VCFRecord;
+  p->vcf = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_4cvcf_9VCFRecord___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_4cvcf_VCFRecord(PyObject *o) {
+  struct __pyx_obj_4cvcf_VCFRecord *p = (struct __pyx_obj_4cvcf_VCFRecord *)o;
+  Py_XDECREF(p->vcf);
+  __pyx_ptype_10TabProxies_TupleProxy->tp_dealloc(o);
+}
+
+static int __pyx_tp_traverse_4cvcf_VCFRecord(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_4cvcf_VCFRecord *p = (struct __pyx_obj_4cvcf_VCFRecord *)o;
+  if (__pyx_ptype_10TabProxies_TupleProxy->tp_traverse) {
+    e = __pyx_ptype_10TabProxies_TupleProxy->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->vcf) {
+    e = (*v)(p->vcf, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_4cvcf_VCFRecord(PyObject *o) {
+  struct __pyx_obj_4cvcf_VCFRecord *p = (struct __pyx_obj_4cvcf_VCFRecord *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_10TabProxies_TupleProxy->tp_clear) {
+    __pyx_ptype_10TabProxies_TupleProxy->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->vcf);
+  p->vcf = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+static PyObject *__pyx_sq_item_4cvcf_VCFRecord(PyObject *o, Py_ssize_t i) {
+  PyObject *r;
+  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+  Py_DECREF(x);
+  return r;
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_contig(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_6contig___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_pos(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_3pos___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_id(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_2id___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_ref(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_3ref___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_alt(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_3alt___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_qual(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_4qual___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_filter(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_6filter___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_info(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_4info___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_format(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_6format___get__(o);
+}
+
+static PyObject *__pyx_getprop_4cvcf_9VCFRecord_samples(PyObject *o, void *x) {
+  return __pyx_pf_4cvcf_9VCFRecord_7samples___get__(o);
+}
+
+static PyMethodDef __pyx_methods_4cvcf_VCFRecord[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_4cvcf_VCFRecord[] = {
+  {(char *)"contig", __pyx_getprop_4cvcf_9VCFRecord_contig, 0, 0, 0},
+  {(char *)"pos", __pyx_getprop_4cvcf_9VCFRecord_pos, 0, 0, 0},
+  {(char *)"id", __pyx_getprop_4cvcf_9VCFRecord_id, 0, 0, 0},
+  {(char *)"ref", __pyx_getprop_4cvcf_9VCFRecord_ref, 0, 0, 0},
+  {(char *)"alt", __pyx_getprop_4cvcf_9VCFRecord_alt, 0, 0, 0},
+  {(char *)"qual", __pyx_getprop_4cvcf_9VCFRecord_qual, 0, 0, 0},
+  {(char *)"filter", __pyx_getprop_4cvcf_9VCFRecord_filter, 0, 0, 0},
+  {(char *)"info", __pyx_getprop_4cvcf_9VCFRecord_info, 0, 0, 0},
+  {(char *)"format", __pyx_getprop_4cvcf_9VCFRecord_format, 0, 0, 0},
+  {(char *)"samples", __pyx_getprop_4cvcf_9VCFRecord_samples, 0, 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_VCFRecord = {
+  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_VCFRecord = {
+  __pyx_pf_4cvcf_9VCFRecord___len__, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  __pyx_sq_item_4cvcf_VCFRecord, /*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_VCFRecord = {
+  __pyx_pf_4cvcf_9VCFRecord___len__, /*mp_length*/
+  __pyx_pf_4cvcf_9VCFRecord___getitem__, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_VCFRecord = {
+  #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
+};
+
+PyTypeObject __pyx_type_4cvcf_VCFRecord = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("cvcf.VCFRecord"), /*tp_name*/
+  sizeof(struct __pyx_obj_4cvcf_VCFRecord), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_4cvcf_VCFRecord, /*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_VCFRecord, /*tp_as_number*/
+  &__pyx_tp_as_sequence_VCFRecord, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_VCFRecord, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_VCFRecord, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("vcf record.\n\n    initialized from data and vcf meta \n    "), /*tp_doc*/
+  __pyx_tp_traverse_4cvcf_VCFRecord, /*tp_traverse*/
+  __pyx_tp_clear_4cvcf_VCFRecord, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_4cvcf_VCFRecord, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_4cvcf_VCFRecord, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_4cvcf_9VCFRecord___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_4cvcf_VCFRecord, /*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_4cvcf_asVCFRecord(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_4cvcf_asVCFRecord *p;
+  PyObject *o = __pyx_ptype_6ctabix_Parser->tp_new(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_4cvcf_asVCFRecord *)o);
+  p->vcffile = Py_None; Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_4cvcf_asVCFRecord(PyObject *o) {
+  struct __pyx_obj_4cvcf_asVCFRecord *p = (struct __pyx_obj_4cvcf_asVCFRecord *)o;
+  Py_XDECREF(p->vcffile);
+  __pyx_ptype_6ctabix_Parser->tp_dealloc(o);
+}
+
+static int __pyx_tp_traverse_4cvcf_asVCFRecord(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_4cvcf_asVCFRecord *p = (struct __pyx_obj_4cvcf_asVCFRecord *)o;
+  if (__pyx_ptype_6ctabix_Parser->tp_traverse) {
+    e = __pyx_ptype_6ctabix_Parser->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->vcffile) {
+    e = (*v)(p->vcffile, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_4cvcf_asVCFRecord(PyObject *o) {
+  struct __pyx_obj_4cvcf_asVCFRecord *p = (struct __pyx_obj_4cvcf_asVCFRecord *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_6ctabix_Parser->tp_clear) {
+    __pyx_ptype_6ctabix_Parser->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->vcffile);
+  p->vcffile = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_4cvcf_asVCFRecord[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_asVCFRecord = {
+  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_asVCFRecord = {
+  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_asVCFRecord = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_asVCFRecord = {
+  #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
+};
+
+PyTypeObject __pyx_type_4cvcf_asVCFRecord = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("cvcf.asVCFRecord"), /*tp_name*/
+  sizeof(struct __pyx_obj_4cvcf_asVCFRecord), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_4cvcf_asVCFRecord, /*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_asVCFRecord, /*tp_as_number*/
+  &__pyx_tp_as_sequence_asVCFRecord, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_asVCFRecord, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  __pyx_pf_4cvcf_11asVCFRecord___call__, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_asVCFRecord, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("converts a :term:`tabix row` into a VCF record."), /*tp_doc*/
+  __pyx_tp_traverse_4cvcf_asVCFRecord, /*tp_traverse*/
+  __pyx_tp_clear_4cvcf_asVCFRecord, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_4cvcf_asVCFRecord, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_4cvcf_11asVCFRecord___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_4cvcf_asVCFRecord, /*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 PyMethodDef __pyx_methods[] = {
+  {__Pyx_NAMESTR("get_sequence"), (PyCFunction)__pyx_pf_4cvcf_get_sequence, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
+  {__Pyx_NAMESTR("parse_regions"), (PyCFunction)__pyx_pf_4cvcf_parse_regions, METH_O, __Pyx_DOCSTR(0)},
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+    PyModuleDef_HEAD_INIT,
+    __Pyx_NAMESTR("cvcf"),
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 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_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0},
+  {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
+  {&__pyx_kp_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 0},
+  {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
+  {&__pyx_kp_s_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 1, 0},
+  {&__pyx_kp_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 0},
+  {&__pyx_kp_u_107, __pyx_k_107, sizeof(__pyx_k_107), 0, 1, 0, 0},
+  {&__pyx_kp_u_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 1, 0, 0},
+  {&__pyx_kp_u_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 1, 0, 0},
+  {&__pyx_n_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 1},
+  {&__pyx_kp_u_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 1, 0, 0},
+  {&__pyx_kp_u_111, __pyx_k_111, sizeof(__pyx_k_111), 0, 1, 0, 0},
+  {&__pyx_kp_u_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 1, 0, 0},
+  {&__pyx_kp_u_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 1, 0, 0},
+  {&__pyx_kp_u_114, __pyx_k_114, sizeof(__pyx_k_114), 0, 1, 0, 0},
+  {&__pyx_kp_u_115, __pyx_k_115, sizeof(__pyx_k_115), 0, 1, 0, 0},
+  {&__pyx_kp_u_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 1, 0, 0},
+  {&__pyx_kp_u_117, __pyx_k_117, sizeof(__pyx_k_117), 0, 1, 0, 0},
+  {&__pyx_kp_u_118, __pyx_k_118, sizeof(__pyx_k_118), 0, 1, 0, 0},
+  {&__pyx_kp_u_119, __pyx_k_119, sizeof(__pyx_k_119), 0, 1, 0, 0},
+  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
+  {&__pyx_kp_u_120, __pyx_k_120, sizeof(__pyx_k_120), 0, 1, 0, 0},
+  {&__pyx_kp_u_121, __pyx_k_121, sizeof(__pyx_k_121), 0, 1, 0, 0},
+  {&__pyx_kp_u_122, __pyx_k_122, sizeof(__pyx_k_122), 0, 1, 0, 0},
+  {&__pyx_kp_u_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 1, 0, 0},
+  {&__pyx_kp_u_124, __pyx_k_124, sizeof(__pyx_k_124), 0, 1, 0, 0},
+  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
+  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
+  {&__pyx_n_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 1},
+  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
+  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
+  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
+  {&__pyx_n_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 1},
+  {&__pyx_n_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 1},
+  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
+  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
+  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
+  {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
+  {&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1},
+  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
+  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
+  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
+  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
+  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
+  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 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_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_4, __pyx_k_4, sizeof(__pyx_k_4), 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_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
+  {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
+  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
+  {&__pyx_n_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 1},
+  {&__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_n_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 1},
+  {&__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_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1},
+  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
+  {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
+  {&__pyx_n_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 1},
+  {&__pyx_n_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 1},
+  {&__pyx_kp_b_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 0, 0},
+  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
+  {&__pyx_n_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 1},
+  {&__pyx_n_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 1},
+  {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0},
+  {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
+  {&__pyx_n_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 1},
+  {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
+  {&__pyx_n_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 1},
+  {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0},
+  {&__pyx_n_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 1},
+  {&__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_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 0},
+  {&__pyx_kp_s_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 1, 0},
+  {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
+  {&__pyx_kp_s_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 1, 0},
+  {&__pyx_kp_s_76, __pyx_k_76, sizeof(__pyx_k_76), 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_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
+  {&__pyx_kp_s_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 1, 0},
+  {&__pyx_kp_s_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 1, 0},
+  {&__pyx_kp_s_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 1, 0},
+  {&__pyx_kp_s_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 1, 0},
+  {&__pyx_kp_s_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 1, 0},
+  {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
+  {&__pyx_kp_s_86, __pyx_k_86, sizeof(__pyx_k_86), 0, 0, 1, 0},
+  {&__pyx_kp_s_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 1, 0},
+  {&__pyx_kp_s_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 1, 0},
+  {&__pyx_kp_s_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 1, 0},
+  {&__pyx_n_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 1},
+  {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
+  {&__pyx_kp_s_91, __pyx_k_91, sizeof(__pyx_k_91), 0, 0, 1, 0},
+  {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
+  {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
+  {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
+  {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
+  {&__pyx_kp_s_96, __pyx_k_96, sizeof(__pyx_k_96), 0, 0, 1, 0},
+  {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
+  {&__pyx_kp_s_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 1, 0},
+  {&__pyx_kp_s_99, __pyx_k_99, sizeof(__pyx_k_99), 0, 0, 1, 0},
+  {&__pyx_kp_s__0, __pyx_k__0, sizeof(__pyx_k__0), 0, 0, 1, 0},
+  {&__pyx_n_s__ACGTN, __pyx_k__ACGTN, sizeof(__pyx_k__ACGTN), 0, 0, 1, 1},
+  {&__pyx_n_s__ALT, __pyx_k__ALT, sizeof(__pyx_k__ALT), 0, 0, 1, 1},
+  {&__pyx_n_s__BAD_GENOTYPE, __pyx_k__BAD_GENOTYPE, sizeof(__pyx_k__BAD_GENOTYPE), 0, 0, 1, 1},
+  {&__pyx_n_s__CHROM, __pyx_k__CHROM, sizeof(__pyx_k__CHROM), 0, 0, 1, 1},
+  {&__pyx_n_s__Character, __pyx_k__Character, sizeof(__pyx_k__Character), 0, 0, 1, 1},
+  {&__pyx_n_s__D, __pyx_k__D, sizeof(__pyx_k__D), 0, 0, 1, 1},
+  {&__pyx_n_s__DP, __pyx_k__DP, sizeof(__pyx_k__DP), 0, 0, 1, 1},
+  {&__pyx_n_s__Description, __pyx_k__Description, sizeof(__pyx_k__Description), 0, 0, 1, 1},
+  {&__pyx_n_s__ERROR_INFO_STRING, __pyx_k__ERROR_INFO_STRING, sizeof(__pyx_k__ERROR_INFO_STRING), 0, 0, 1, 1},
+  {&__pyx_n_s__ERROR_TRAILING_DATA, __pyx_k__ERROR_TRAILING_DATA, sizeof(__pyx_k__ERROR_TRAILING_DATA), 0, 0, 1, 1},
+  {&__pyx_n_s__ERROR_UNKNOWN_KEY, __pyx_k__ERROR_UNKNOWN_KEY, sizeof(__pyx_k__ERROR_UNKNOWN_KEY), 0, 0, 1, 1},
+  {&__pyx_n_s__Error, __pyx_k__Error, sizeof(__pyx_k__Error), 0, 0, 1, 1},
+  {&__pyx_n_s__FILTER, __pyx_k__FILTER, sizeof(__pyx_k__FILTER), 0, 0, 1, 1},
+  {&__pyx_n_s__FILTER_NOT_DEFINED, __pyx_k__FILTER_NOT_DEFINED, sizeof(__pyx_k__FILTER_NOT_DEFINED), 0, 0, 1, 1},
+  {&__pyx_n_s__FORMAT, __pyx_k__FORMAT, sizeof(__pyx_k__FORMAT), 0, 0, 1, 1},
+  {&__pyx_n_s__FORMAT_NOT_DEFINED, __pyx_k__FORMAT_NOT_DEFINED, sizeof(__pyx_k__FORMAT_NOT_DEFINED), 0, 0, 1, 1},
+  {&__pyx_n_s__FT, __pyx_k__FT, sizeof(__pyx_k__FT), 0, 0, 1, 1},
+  {&__pyx_n_s__Flag, __pyx_k__Flag, sizeof(__pyx_k__Flag), 0, 0, 1, 1},
+  {&__pyx_n_s__Float, __pyx_k__Float, sizeof(__pyx_k__Float), 0, 0, 1, 1},
+  {&__pyx_n_s__GQ, __pyx_k__GQ, sizeof(__pyx_k__GQ), 0, 0, 1, 1},
+  {&__pyx_n_s__GT, __pyx_k__GT, sizeof(__pyx_k__GT), 0, 0, 1, 1},
+  {&__pyx_n_s__GTdata, __pyx_k__GTdata, sizeof(__pyx_k__GTdata), 0, 0, 1, 1},
+  {&__pyx_n_s__GTstring, __pyx_k__GTstring, sizeof(__pyx_k__GTstring), 0, 0, 1, 1},
+  {&__pyx_n_s__Genotype, __pyx_k__Genotype, sizeof(__pyx_k__Genotype), 0, 0, 1, 1},
+  {&__pyx_n_s__HQ, __pyx_k__HQ, sizeof(__pyx_k__HQ), 0, 0, 1, 1},
+  {&__pyx_n_s__I, __pyx_k__I, sizeof(__pyx_k__I), 0, 0, 1, 1},
+  {&__pyx_n_s__ID, __pyx_k__ID, sizeof(__pyx_k__ID), 0, 0, 1, 1},
+  {&__pyx_n_s__INFO, __pyx_k__INFO, sizeof(__pyx_k__INFO), 0, 0, 1, 1},
+  {&__pyx_n_s__Integer, __pyx_k__Integer, sizeof(__pyx_k__Integer), 0, 0, 1, 1},
+  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
+  {&__pyx_n_s__MISSING_REF, __pyx_k__MISSING_REF, sizeof(__pyx_k__MISSING_REF), 0, 0, 1, 1},
+  {&__pyx_n_s__N, __pyx_k__N, sizeof(__pyx_k__N), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_ALLELES, __pyx_k__NT_ALLELES, sizeof(__pyx_k__NT_ALLELES), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_GENOTYPES, __pyx_k__NT_GENOTYPES, sizeof(__pyx_k__NT_GENOTYPES), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_NR_ALLELES, __pyx_k__NT_NR_ALLELES, sizeof(__pyx_k__NT_NR_ALLELES), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_NUMBER, __pyx_k__NT_NUMBER, sizeof(__pyx_k__NT_NUMBER), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_PHASED_GENOTYPES, __pyx_k__NT_PHASED_GENOTYPES, sizeof(__pyx_k__NT_PHASED_GENOTYPES), 0, 0, 1, 1},
+  {&__pyx_n_s__NT_UNKNOWN, __pyx_k__NT_UNKNOWN, sizeof(__pyx_k__NT_UNKNOWN), 0, 0, 1, 1},
+  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
+  {&__pyx_n_s__Number, __pyx_k__Number, sizeof(__pyx_k__Number), 0, 0, 1, 1},
+  {&__pyx_n_s__PASS, __pyx_k__PASS, sizeof(__pyx_k__PASS), 0, 0, 1, 1},
+  {&__pyx_n_s__POS, __pyx_k__POS, sizeof(__pyx_k__POS), 0, 0, 1, 1},
+  {&__pyx_n_s__POS_NOT_NUMERICAL, __pyx_k__POS_NOT_NUMERICAL, sizeof(__pyx_k__POS_NOT_NUMERICAL), 0, 0, 1, 1},
+  {&__pyx_n_s__POS_NOT_POSITIVE, __pyx_k__POS_NOT_POSITIVE, sizeof(__pyx_k__POS_NOT_POSITIVE), 0, 0, 1, 1},
+  {&__pyx_n_s__QUAL, __pyx_k__QUAL, sizeof(__pyx_k__QUAL), 0, 0, 1, 1},
+  {&__pyx_n_s__QUAL_NOT_NUMERICAL, __pyx_k__QUAL_NOT_NUMERICAL, sizeof(__pyx_k__QUAL_NOT_NUMERICAL), 0, 0, 1, 1},
+  {&__pyx_n_s__REF, __pyx_k__REF, sizeof(__pyx_k__REF), 0, 0, 1, 1},
+  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
+  {&__pyx_n_s__String, __pyx_k__String, sizeof(__pyx_k__String), 0, 0, 1, 1},
+  {&__pyx_n_s__Tabixfile, __pyx_k__Tabixfile, sizeof(__pyx_k__Tabixfile), 0, 0, 1, 1},
+  {&__pyx_n_s__Type, __pyx_k__Type, sizeof(__pyx_k__Type), 0, 0, 1, 1},
+  {&__pyx_n_s__UNKNOWN_CHAR_IN_REF, __pyx_k__UNKNOWN_CHAR_IN_REF, sizeof(__pyx_k__UNKNOWN_CHAR_IN_REF), 0, 0, 1, 1},
+  {&__pyx_n_s__V33_BAD_ALLELE, __pyx_k__V33_BAD_ALLELE, sizeof(__pyx_k__V33_BAD_ALLELE), 0, 0, 1, 1},
+  {&__pyx_n_s__V33_BAD_REF, __pyx_k__V33_BAD_REF, sizeof(__pyx_k__V33_BAD_REF), 0, 0, 1, 1},
+  {&__pyx_n_s__V40_BAD_ALLELE, __pyx_k__V40_BAD_ALLELE, sizeof(__pyx_k__V40_BAD_ALLELE), 0, 0, 1, 1},
+  {&__pyx_n_s__VCF, __pyx_k__VCF, sizeof(__pyx_k__VCF), 0, 0, 1, 1},
+  {&__pyx_n_s__VCFRecord, __pyx_k__VCFRecord, sizeof(__pyx_k__VCFRecord), 0, 0, 1, 1},
+  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
+  {&__pyx_n_s__WRONG_REF, __pyx_k__WRONG_REF, sizeof(__pyx_k__WRONG_REF), 0, 0, 1, 1},
+  {&__pyx_n_s__Warning, __pyx_k__Warning, sizeof(__pyx_k__Warning), 0, 0, 1, 1},
+  {&__pyx_n_s__ZERO_LENGTH_ALLELE, __pyx_k__ZERO_LENGTH_ALLELE, sizeof(__pyx_k__ZERO_LENGTH_ALLELE), 0, 0, 1, 1},
+  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
+  {&__pyx_n_s____dict__, __pyx_k____dict__, sizeof(__pyx_k____dict__), 0, 0, 1, 1},
+  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
+  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
+  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
+  {&__pyx_n_s___add_definition, __pyx_k___add_definition, sizeof(__pyx_k___add_definition), 0, 0, 1, 1},
+  {&__pyx_n_s___copy, __pyx_k___copy, sizeof(__pyx_k___copy), 0, 0, 1, 1},
+  {&__pyx_n_s___errors, __pyx_k___errors, sizeof(__pyx_k___errors), 0, 0, 1, 1},
+  {&__pyx_n_s___filter, __pyx_k___filter, sizeof(__pyx_k___filter), 0, 0, 1, 1},
+  {&__pyx_n_s___format, __pyx_k___format, sizeof(__pyx_k___format), 0, 0, 1, 1},
+  {&__pyx_n_s___header, __pyx_k___header, sizeof(__pyx_k___header), 0, 0, 1, 1},
+  {&__pyx_n_s___ignored_errors, __pyx_k___ignored_errors, sizeof(__pyx_k___ignored_errors), 0, 0, 1, 1},
+  {&__pyx_n_s___info, __pyx_k___info, sizeof(__pyx_k___info), 0, 0, 1, 1},
+  {&__pyx_n_s___leftalign, __pyx_k___leftalign, sizeof(__pyx_k___leftalign), 0, 0, 1, 1},
+  {&__pyx_n_s___line, __pyx_k___line, sizeof(__pyx_k___line), 0, 0, 1, 1},
+  {&__pyx_n_s___lineno, __pyx_k___lineno, sizeof(__pyx_k___lineno), 0, 0, 1, 1},
+  {&__pyx_n_s___lines, __pyx_k___lines, sizeof(__pyx_k___lines), 0, 0, 1, 1},
+  {&__pyx_n_s___parse, __pyx_k___parse, sizeof(__pyx_k___parse), 0, 0, 1, 1},
+  {&__pyx_n_s___parse_header, __pyx_k___parse_header, sizeof(__pyx_k___parse_header), 0, 0, 1, 1},
+  {&__pyx_n_s___reference, __pyx_k___reference, sizeof(__pyx_k___reference), 0, 0, 1, 1},
+  {&__pyx_n_s___regions, __pyx_k___regions, sizeof(__pyx_k___regions), 0, 0, 1, 1},
+  {&__pyx_n_s___required, __pyx_k___required, sizeof(__pyx_k___required), 0, 0, 1, 1},
+  {&__pyx_n_s___sample2column, __pyx_k___sample2column, sizeof(__pyx_k___sample2column), 0, 0, 1, 1},
+  {&__pyx_n_s___samples, __pyx_k___samples, sizeof(__pyx_k___samples), 0, 0, 1, 1},
+  {&__pyx_n_s___version, __pyx_k___version, sizeof(__pyx_k___version), 0, 0, 1, 1},
+  {&__pyx_n_s___warn_errors, __pyx_k___warn_errors, sizeof(__pyx_k___warn_errors), 0, 0, 1, 1},
+  {&__pyx_n_s__add, __pyx_k__add, sizeof(__pyx_k__add), 0, 0, 1, 1},
+  {&__pyx_n_s__alleleRegEx, __pyx_k__alleleRegEx, sizeof(__pyx_k__alleleRegEx), 0, 0, 1, 1},
+  {&__pyx_n_s__alt, __pyx_k__alt, sizeof(__pyx_k__alt), 0, 0, 1, 1},
+  {&__pyx_n_s__alt1, __pyx_k__alt1, sizeof(__pyx_k__alt1), 0, 0, 1, 1},
+  {&__pyx_n_s__alt2, __pyx_k__alt2, sizeof(__pyx_k__alt2), 0, 0, 1, 1},
+  {&__pyx_n_s__bisect, __pyx_k__bisect, sizeof(__pyx_k__bisect), 0, 0, 1, 1},
+  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
+  {&__pyx_n_s__chrom, __pyx_k__chrom, sizeof(__pyx_k__chrom), 0, 0, 1, 1},
+  {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1},
+  {&__pyx_n_s__compare_calls, __pyx_k__compare_calls, sizeof(__pyx_k__compare_calls), 0, 0, 1, 1},
+  {&__pyx_n_s__compile, __pyx_k__compile, sizeof(__pyx_k__compile), 0, 0, 1, 1},
+  {&__pyx_n_s__connect, __pyx_k__connect, sizeof(__pyx_k__connect), 0, 0, 1, 1},
+  {&__pyx_n_s__contig, __pyx_k__contig, sizeof(__pyx_k__contig), 0, 0, 1, 1},
+  {&__pyx_n_s__convertGT, __pyx_k__convertGT, sizeof(__pyx_k__convertGT), 0, 0, 1, 1},
+  {&__pyx_n_s__convertGTback, __pyx_k__convertGTback, sizeof(__pyx_k__convertGTback), 0, 0, 1, 1},
+  {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
+  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
+  {&__pyx_n_s__datagenerator, __pyx_k__datagenerator, sizeof(__pyx_k__datagenerator), 0, 0, 1, 1},
+  {&__pyx_n_s__deepcopy, __pyx_k__deepcopy, sizeof(__pyx_k__deepcopy), 0, 0, 1, 1},
+  {&__pyx_n_s__defaultdict, __pyx_k__defaultdict, sizeof(__pyx_k__defaultdict), 0, 0, 1, 1},
+  {&__pyx_n_s__descr, __pyx_k__descr, sizeof(__pyx_k__descr), 0, 0, 1, 1},
+  {&__pyx_n_s__description, __pyx_k__description, sizeof(__pyx_k__description), 0, 0, 1, 1},
+  {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
+  {&__pyx_n_s__endswith, __pyx_k__endswith, sizeof(__pyx_k__endswith), 0, 0, 1, 1},
+  {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
+  {&__pyx_n_s__error, __pyx_k__error, sizeof(__pyx_k__error), 0, 0, 1, 1},
+  {&__pyx_n_s__errorstring, __pyx_k__errorstring, sizeof(__pyx_k__errorstring), 0, 0, 1, 1},
+  {&__pyx_n_s__fa, __pyx_k__fa, sizeof(__pyx_k__fa), 0, 0, 1, 1},
+  {&__pyx_n_s__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 0, 0, 1, 1},
+  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
+  {&__pyx_n_s__fileformat, __pyx_k__fileformat, sizeof(__pyx_k__fileformat), 0, 0, 1, 1},
+  {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
+  {&__pyx_n_s__filter, __pyx_k__filter, sizeof(__pyx_k__filter), 0, 0, 1, 1},
+  {&__pyx_n_s__find, __pyx_k__find, sizeof(__pyx_k__find), 0, 0, 1, 1},
+  {&__pyx_n_s__fmt, __pyx_k__fmt, sizeof(__pyx_k__fmt), 0, 0, 1, 1},
+  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
+  {&__pyx_n_s__format_format, __pyx_k__format_format, sizeof(__pyx_k__format_format), 0, 0, 1, 1},
+  {&__pyx_n_s__format_formatdata, __pyx_k__format_formatdata, sizeof(__pyx_k__format_formatdata), 0, 0, 1, 1},
+  {&__pyx_n_s__formatdict, __pyx_k__formatdict, sizeof(__pyx_k__formatdict), 0, 0, 1, 1},
+  {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
+  {&__pyx_n_s__get_expected, __pyx_k__get_expected, sizeof(__pyx_k__get_expected), 0, 0, 1, 1},
+  {&__pyx_n_s__get_sequence, __pyx_k__get_sequence, sizeof(__pyx_k__get_sequence), 0, 0, 1, 1},
+  {&__pyx_n_s__getfilter, __pyx_k__getfilter, sizeof(__pyx_k__getfilter), 0, 0, 1, 1},
+  {&__pyx_n_s__getformat, __pyx_k__getformat, sizeof(__pyx_k__getformat), 0, 0, 1, 1},
+  {&__pyx_n_s__getheader, __pyx_k__getheader, sizeof(__pyx_k__getheader), 0, 0, 1, 1},
+  {&__pyx_n_s__getinfo, __pyx_k__getinfo, sizeof(__pyx_k__getinfo), 0, 0, 1, 1},
+  {&__pyx_n_s__getsamples, __pyx_k__getsamples, sizeof(__pyx_k__getsamples), 0, 0, 1, 1},
+  {&__pyx_n_s__gtsRegEx, __pyx_k__gtsRegEx, sizeof(__pyx_k__gtsRegEx), 0, 0, 1, 1},
+  {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1},
+  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
+  {&__pyx_n_s__ignoreerror, __pyx_k__ignoreerror, sizeof(__pyx_k__ignoreerror), 0, 0, 1, 1},
+  {&__pyx_n_s__info, __pyx_k__info, sizeof(__pyx_k__info), 0, 0, 1, 1},
+  {&__pyx_n_s__inregion, __pyx_k__inregion, sizeof(__pyx_k__inregion), 0, 0, 1, 1},
+  {&__pyx_n_s__itemgetter, __pyx_k__itemgetter, sizeof(__pyx_k__itemgetter), 0, 0, 1, 1},
+  {&__pyx_n_s__itervalues, __pyx_k__itervalues, sizeof(__pyx_k__itervalues), 0, 0, 1, 1},
+  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
+  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
+  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
+  {&__pyx_n_s__leftalign, __pyx_k__leftalign, sizeof(__pyx_k__leftalign), 0, 0, 1, 1},
+  {&__pyx_n_s__len, __pyx_k__len, sizeof(__pyx_k__len), 0, 0, 1, 1},
+  {&__pyx_n_s__line, __pyx_k__line, sizeof(__pyx_k__line), 0, 0, 1, 1},
+  {&__pyx_n_s__lineparse, __pyx_k__lineparse, sizeof(__pyx_k__lineparse), 0, 0, 1, 1},
+  {&__pyx_n_s__lines, __pyx_k__lines, sizeof(__pyx_k__lines), 0, 0, 1, 1},
+  {&__pyx_n_s__map, __pyx_k__map, sizeof(__pyx_k__map), 0, 0, 1, 1},
+  {&__pyx_n_s__match, __pyx_k__match, sizeof(__pyx_k__match), 0, 0, 1, 1},
+  {&__pyx_n_s__min, __pyx_k__min, sizeof(__pyx_k__min), 0, 0, 1, 1},
+  {&__pyx_n_s__missing, __pyx_k__missing, sizeof(__pyx_k__missing), 0, 0, 1, 1},
+  {&__pyx_n_s__missingvalue, __pyx_k__missingvalue, sizeof(__pyx_k__missingvalue), 0, 0, 1, 1},
+  {&__pyx_n_s__namedtuple, __pyx_k__namedtuple, sizeof(__pyx_k__namedtuple), 0, 0, 1, 1},
+  {&__pyx_n_s__nfields, __pyx_k__nfields, sizeof(__pyx_k__nfields), 0, 0, 1, 1},
+  {&__pyx_n_s__number, __pyx_k__number, sizeof(__pyx_k__number), 0, 0, 1, 1},
+  {&__pyx_n_s__numbertype, __pyx_k__numbertype, sizeof(__pyx_k__numbertype), 0, 0, 1, 1},
+  {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
+  {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
+  {&__pyx_n_s__operator, __pyx_k__operator, sizeof(__pyx_k__operator), 0, 0, 1, 1},
+  {&__pyx_n_s__opt, __pyx_k__opt, sizeof(__pyx_k__opt), 0, 0, 1, 1},
+  {&__pyx_n_s__parse, __pyx_k__parse, sizeof(__pyx_k__parse), 0, 0, 1, 1},
+  {&__pyx_n_s__parse_data, __pyx_k__parse_data, sizeof(__pyx_k__parse_data), 0, 0, 1, 1},
+  {&__pyx_n_s__parse_format, __pyx_k__parse_format, sizeof(__pyx_k__parse_format), 0, 0, 1, 1},
+  {&__pyx_n_s__parse_formatdata, __pyx_k__parse_formatdata, sizeof(__pyx_k__parse_formatdata), 0, 0, 1, 1},
+  {&__pyx_n_s__parse_header, __pyx_k__parse_header, sizeof(__pyx_k__parse_header), 0, 0, 1, 1},
+  {&__pyx_n_s__parse_heading, __pyx_k__parse_heading, sizeof(__pyx_k__parse_heading), 0, 0, 1, 1},
+  {&__pyx_n_s__parser, __pyx_k__parser, sizeof(__pyx_k__parser), 0, 0, 1, 1},
+  {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
+  {&__pyx_n_s__pos1, __pyx_k__pos1, sizeof(__pyx_k__pos1), 0, 0, 1, 1},
+  {&__pyx_n_s__pos2, __pyx_k__pos2, sizeof(__pyx_k__pos2), 0, 0, 1, 1},
+  {&__pyx_n_s__pysam, __pyx_k__pysam, sizeof(__pyx_k__pysam), 0, 0, 1, 1},
+  {&__pyx_n_s__qual, __pyx_k__qual, sizeof(__pyx_k__qual), 0, 0, 1, 1},
+  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
+  {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1},
+  {&__pyx_n_s__record, __pyx_k__record, sizeof(__pyx_k__record), 0, 0, 1, 1},
+  {&__pyx_n_s__ref, __pyx_k__ref, sizeof(__pyx_k__ref), 0, 0, 1, 1},
+  {&__pyx_n_s__ref1, __pyx_k__ref1, sizeof(__pyx_k__ref1), 0, 0, 1, 1},
+  {&__pyx_n_s__ref2, __pyx_k__ref2, sizeof(__pyx_k__ref2), 0, 0, 1, 1},
+  {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
+  {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
+  {&__pyx_n_s__regions, __pyx_k__regions, sizeof(__pyx_k__regions), 0, 0, 1, 1},
+  {&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1},
+  {&__pyx_n_s__samples, __pyx_k__samples, sizeof(__pyx_k__samples), 0, 0, 1, 1},
+  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
+  {&__pyx_n_s__separator, __pyx_k__separator, sizeof(__pyx_k__separator), 0, 0, 1, 1},
+  {&__pyx_n_s__setfilter, __pyx_k__setfilter, sizeof(__pyx_k__setfilter), 0, 0, 1, 1},
+  {&__pyx_n_s__setformat, __pyx_k__setformat, sizeof(__pyx_k__setformat), 0, 0, 1, 1},
+  {&__pyx_n_s__setheader, __pyx_k__setheader, sizeof(__pyx_k__setheader), 0, 0, 1, 1},
+  {&__pyx_n_s__setinfo, __pyx_k__setinfo, sizeof(__pyx_k__setinfo), 0, 0, 1, 1},
+  {&__pyx_n_s__setreference, __pyx_k__setreference, sizeof(__pyx_k__setreference), 0, 0, 1, 1},
+  {&__pyx_n_s__setregions, __pyx_k__setregions, sizeof(__pyx_k__setregions), 0, 0, 1, 1},
+  {&__pyx_n_s__setsamples, __pyx_k__setsamples, sizeof(__pyx_k__setsamples), 0, 0, 1, 1},
+  {&__pyx_n_s__setversion, __pyx_k__setversion, sizeof(__pyx_k__setversion), 0, 0, 1, 1},
+  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
+  {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
+  {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
+  {&__pyx_n_s__stderr, __pyx_k__stderr, sizeof(__pyx_k__stderr), 0, 0, 1, 1},
+  {&__pyx_n_s__stream, __pyx_k__stream, sizeof(__pyx_k__stream), 0, 0, 1, 1},
+  {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
+  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
+  {&__pyx_n_s__tabixfile, __pyx_k__tabixfile, sizeof(__pyx_k__tabixfile), 0, 0, 1, 1},
+  {&__pyx_n_s__type, __pyx_k__type, sizeof(__pyx_k__type), 0, 0, 1, 1},
+  {&__pyx_n_s__upper, __pyx_k__upper, sizeof(__pyx_k__upper), 0, 0, 1, 1},
+  {&__pyx_n_s__validate, __pyx_k__validate, sizeof(__pyx_k__validate), 0, 0, 1, 1},
+  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
+  {&__pyx_n_s__vcf, __pyx_k__vcf, sizeof(__pyx_k__vcf), 0, 0, 1, 1},
+  {&__pyx_n_s__vcffile, __pyx_k__vcffile, sizeof(__pyx_k__vcffile), 0, 0, 1, 1},
+  {&__pyx_n_s__version, __pyx_k__version, sizeof(__pyx_k__version), 0, 0, 1, 1},
+  {&__pyx_n_s__warnerror, __pyx_k__warnerror, sizeof(__pyx_k__warnerror), 0, 0, 1, 1},
+  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
+  {&__pyx_n_s__write_data, __pyx_k__write_data, sizeof(__pyx_k__write_data), 0, 0, 1, 1},
+  {&__pyx_n_s__write_header, __pyx_k__write_header, sizeof(__pyx_k__write_header), 0, 0, 1, 1},
+  {&__pyx_n_s__write_heading, __pyx_k__write_heading, sizeof(__pyx_k__write_heading), 0, 0, 1, 1},
+  {&__pyx_n_s__writeheader, __pyx_k__writeheader, sizeof(__pyx_k__writeheader), 0, 0, 1, 1},
+  {&__pyx_n_s__zip, __pyx_k__zip, sizeof(__pyx_k__zip), 0, 0, 1, 1},
+  {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 = 232; __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __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 = 455; __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 = 462; __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 = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_len = __Pyx_GetName(__pyx_b, __pyx_n_s__len); if (!__pyx_builtin_len) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __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 = 816; __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 = 870; __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 = 933; __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 = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  #if PY_VERSION_HEX < 0x02040000
+  if (unlikely(__Pyx_Py23SetsImport() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_14 = PyInt_FromLong(14); if (unlikely(!__pyx_int_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_17 = PyInt_FromLong(17); if (unlikely(!__pyx_int_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_18 = PyInt_FromLong(18); if (unlikely(!__pyx_int_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_19 = PyInt_FromLong(19); if (unlikely(!__pyx_int_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_20 = PyInt_FromLong(20); if (unlikely(!__pyx_int_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_21 = PyInt_FromLong(21); if (unlikely(!__pyx_int_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_22 = PyInt_FromLong(22); if (unlikely(!__pyx_int_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_23 = PyInt_FromLong(23); if (unlikely(!__pyx_int_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_24 = PyInt_FromLong(24); if (unlikely(!__pyx_int_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_25 = PyInt_FromLong(25); if (unlikely(!__pyx_int_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_26 = PyInt_FromLong(26); if (unlikely(!__pyx_int_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_27 = PyInt_FromLong(27); if (unlikely(!__pyx_int_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_28 = PyInt_FromLong(28); if (unlikely(!__pyx_int_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_29 = PyInt_FromLong(29); if (unlikely(!__pyx_int_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_30 = PyInt_FromLong(30); if (unlikely(!__pyx_int_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_33 = PyInt_FromLong(33); if (unlikely(!__pyx_int_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_3000000000 = PyInt_FromString((char *)"3000000000", 0, 0); if (unlikely(!__pyx_int_3000000000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initcvcf(void); /*proto*/
+PyMODINIT_FUNC initcvcf(void)
+#else
+PyMODINIT_FUNC PyInit_cvcf(void); /*proto*/
+PyMODINIT_FUNC PyInit_cvcf(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  #if CYTHON_REFNANNY
+  void* __pyx_refnanny = NULL;
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_cvcf(void)", __LINE__, __FILE__);
+  #endif
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __pyx_binding_PyCFunctionType_USED
+  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("cvcf"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  #if PY_MAJOR_VERSION < 3
+  Py_INCREF(__pyx_m);
+  #endif
+  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_module_is_main_cvcf) {
+    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  __pyx_ptype_10TabProxies_TupleProxy = __Pyx_ImportType("TabProxies", "TupleProxy", sizeof(struct __pyx_obj_10TabProxies_TupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_TupleProxy)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_TupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_vtabptr_4cvcf_VCFRecord = &__pyx_vtable_4cvcf_VCFRecord;
+  __pyx_vtable_4cvcf_VCFRecord.__pyx_base = *__pyx_vtabptr_10TabProxies_TupleProxy;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_4cvcf_VCFRecord.__pyx_base.update = (PyObject *(*)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t))__pyx_f_4cvcf_9VCFRecord_update;
+  #else
+  *(void(**)(void))&__pyx_vtable_4cvcf_VCFRecord.__pyx_base.update = (void(*)(void))__pyx_f_4cvcf_9VCFRecord_update;
+  #endif
+  __pyx_type_4cvcf_VCFRecord.tp_base = __pyx_ptype_10TabProxies_TupleProxy;
+  if (PyType_Ready(&__pyx_type_4cvcf_VCFRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_4cvcf_VCFRecord.tp_dict, __pyx_vtabptr_4cvcf_VCFRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "VCFRecord", (PyObject *)&__pyx_type_4cvcf_VCFRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_4cvcf_VCFRecord = &__pyx_type_4cvcf_VCFRecord;
+  __pyx_ptype_6ctabix_Parser = __Pyx_ImportType("ctabix", "Parser", sizeof(struct __pyx_obj_6ctabix_Parser), 1); if (unlikely(!__pyx_ptype_6ctabix_Parser)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_type_4cvcf_asVCFRecord.tp_base = __pyx_ptype_6ctabix_Parser;
+  if (PyType_Ready(&__pyx_type_4cvcf_asVCFRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "asVCFRecord", (PyObject *)&__pyx_type_4cvcf_asVCFRecord) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_4cvcf_asVCFRecord = &__pyx_type_4cvcf_asVCFRecord;
+  /*--- Type import code ---*/
+  __pyx_ptype_6ctabix_Tabixfile = __Pyx_ImportType("ctabix", "Tabixfile", sizeof(struct __pyx_obj_6ctabix_Tabixfile), 1); if (unlikely(!__pyx_ptype_6ctabix_Tabixfile)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_GTFProxy = __Pyx_ImportType("TabProxies", "GTFProxy", sizeof(struct __pyx_obj_10TabProxies_GTFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_GTFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_GTFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_NamedTupleProxy = __Pyx_ImportType("TabProxies", "NamedTupleProxy", sizeof(struct __pyx_obj_10TabProxies_NamedTupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_NamedTupleProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_NamedTupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_BedProxy = __Pyx_ImportType("TabProxies", "BedProxy", sizeof(struct __pyx_obj_10TabProxies_BedProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_BedProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_BedProxy->tp_dict, &__pyx_vtabptr_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_10TabProxies_VCFProxy = __Pyx_ImportType("TabProxies", "VCFProxy", sizeof(struct __pyx_obj_10TabProxies_VCFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_VCFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_VCFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":46
+ * #
+ * 
+ * from collections import namedtuple, defaultdict             # <<<<<<<<<<<<<<
+ * from operator import itemgetter
+ * import sys, re, copy, bisect
+ */
+  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__namedtuple));
+  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__namedtuple));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__namedtuple));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__defaultdict));
+  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__defaultdict));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__defaultdict));
+  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__namedtuple); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__namedtuple, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__defaultdict, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":47
+ * 
+ * from collections import namedtuple, defaultdict
+ * from operator import itemgetter             # <<<<<<<<<<<<<<
+ * import sys, re, copy, bisect
+ * 
+ */
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__itemgetter));
+  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__itemgetter));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__itemgetter));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__operator), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__itemgetter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itemgetter, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":48
+ * from collections import namedtuple, defaultdict
+ * from operator import itemgetter
+ * import sys, re, copy, bisect             # <<<<<<<<<<<<<<
+ * 
+ * cimport ctabix
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__copy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__copy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__bisect), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__bisect, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":52
+ * cimport ctabix
+ * cimport TabProxies
+ * import pysam             # <<<<<<<<<<<<<<
+ * 
+ * gtsRegEx = re.compile("[|/\\\\]")
+ */
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pysam), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pysam, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":54
+ * import pysam
+ * 
+ * gtsRegEx = re.compile("[|/\\\\]")             # <<<<<<<<<<<<<<
+ * alleleRegEx = re.compile('^[ACGTN]+$')
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __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 = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_73));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_73));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_73));
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __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_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gtsRegEx, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":55
+ * 
+ * gtsRegEx = re.compile("[|/\\\\]")
+ * alleleRegEx = re.compile('^[ACGTN]+$')             # <<<<<<<<<<<<<<
+ * 
+ * # Utility function.  Uses 0-based coordinates
+ */
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__compile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_74));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __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_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__alleleRegEx, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":86
+ * 
+ * 
+ * FORMAT = namedtuple('FORMAT','id numbertype number type description missingvalue')             # <<<<<<<<<<<<<<
+ * 
+ * ###########################################################################################################
+ */
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__namedtuple); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __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 = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FORMAT));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__FORMAT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FORMAT));
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_75));
+  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_kp_s_75));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_75));
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __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_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FORMAT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":232
+ *         return r
+ * 
+ * class VCF(object):             # <<<<<<<<<<<<<<
+ * 
+ *     # types
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(__pyx_builtin_object);
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_object);
+  __Pyx_GIVEREF(__pyx_builtin_object);
+  __pyx_t_2 = __Pyx_CreateClass(__pyx_t_3, ((PyObject *)__pyx_t_1), __pyx_n_s__VCF, "cvcf"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":235
+ * 
+ *     # types
+ *     NT_UNKNOWN = 0             # <<<<<<<<<<<<<<
+ *     NT_NUMBER = 1
+ *     NT_ALLELES = 2
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_UNKNOWN, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":236
+ *     # types
+ *     NT_UNKNOWN = 0
+ *     NT_NUMBER = 1             # <<<<<<<<<<<<<<
+ *     NT_ALLELES = 2
+ *     NT_NR_ALLELES = 3
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_NUMBER, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":237
+ *     NT_UNKNOWN = 0
+ *     NT_NUMBER = 1
+ *     NT_ALLELES = 2             # <<<<<<<<<<<<<<
+ *     NT_NR_ALLELES = 3
+ *     NT_GENOTYPES = 4
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_ALLELES, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":238
+ *     NT_NUMBER = 1
+ *     NT_ALLELES = 2
+ *     NT_NR_ALLELES = 3             # <<<<<<<<<<<<<<
+ *     NT_GENOTYPES = 4
+ *     NT_PHASED_GENOTYPES = 5
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_NR_ALLELES, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":239
+ *     NT_ALLELES = 2
+ *     NT_NR_ALLELES = 3
+ *     NT_GENOTYPES = 4             # <<<<<<<<<<<<<<
+ *     NT_PHASED_GENOTYPES = 5
+ * 
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_GENOTYPES, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":240
+ *     NT_NR_ALLELES = 3
+ *     NT_GENOTYPES = 4
+ *     NT_PHASED_GENOTYPES = 5             # <<<<<<<<<<<<<<
+ * 
+ *     _errors = { 0:"UNKNOWN_FORMAT_STRING:Unknown file format identifier",
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__NT_PHASED_GENOTYPES, __pyx_int_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":242
+ *     NT_PHASED_GENOTYPES = 5
+ * 
+ *     _errors = { 0:"UNKNOWN_FORMAT_STRING:Unknown file format identifier",             # <<<<<<<<<<<<<<
+ *                 1:"BADLY_FORMATTED_FORMAT_STRING:Formatting error in the format string",
+ *                 2:"BADLY_FORMATTED_HEADING:Did not find 9 required headings (CHROM, POS, ..., FORMAT) %s",
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_0, ((PyObject *)__pyx_kp_s_76)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, ((PyObject *)__pyx_kp_s_77)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, ((PyObject *)__pyx_kp_s_78)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, ((PyObject *)__pyx_kp_s_79)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_4, ((PyObject *)__pyx_kp_s_80)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_5, ((PyObject *)__pyx_kp_s_81)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_6, ((PyObject *)__pyx_kp_s_82)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_7, ((PyObject *)__pyx_kp_s_83)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_8, ((PyObject *)__pyx_kp_s_84)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_9, ((PyObject *)__pyx_kp_s_85)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_10, ((PyObject *)__pyx_kp_s_86)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_11, ((PyObject *)__pyx_kp_s_87)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_12, ((PyObject *)__pyx_kp_s_88)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_13, ((PyObject *)__pyx_kp_s_89)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_14, ((PyObject *)__pyx_kp_s_90)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_15, ((PyObject *)__pyx_kp_s_91)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_16, ((PyObject *)__pyx_kp_s_92)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_17, ((PyObject *)__pyx_kp_s_93)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_18, ((PyObject *)__pyx_kp_s_94)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_19, ((PyObject *)__pyx_kp_s_95)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_20, ((PyObject *)__pyx_kp_s_96)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_21, ((PyObject *)__pyx_kp_s_97)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_22, ((PyObject *)__pyx_kp_s_98)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_23, ((PyObject *)__pyx_kp_s_99)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_24, ((PyObject *)__pyx_kp_s_100)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_25, ((PyObject *)__pyx_kp_s_101)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_26, ((PyObject *)__pyx_kp_s_102)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_27, ((PyObject *)__pyx_kp_s_103)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_28, ((PyObject *)__pyx_kp_s_104)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_29, ((PyObject *)__pyx_kp_s_105)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, __pyx_int_30, ((PyObject *)__pyx_kp_s_106)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___errors, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":276
+ * 
+ *     # tag-value pairs; tags are not unique; does not include fileformat, INFO, FILTER or FORMAT fields
+ *     _header = []             # <<<<<<<<<<<<<<
+ * 
+ *     # version number; 33=v3.3; 40=v4.0
+ */
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___header, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":279
+ * 
+ *     # version number; 33=v3.3; 40=v4.0
+ *     _version = 40             # <<<<<<<<<<<<<<
+ * 
+ *     # info, filter and format data
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___version, __pyx_int_40) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":282
+ * 
+ *     # info, filter and format data
+ *     _info = {}             # <<<<<<<<<<<<<<
+ *     _filter = {}
+ *     _format = {}
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___info, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":283
+ *     # info, filter and format data
+ *     _info = {}
+ *     _filter = {}             # <<<<<<<<<<<<<<
+ *     _format = {}
+ * 
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___filter, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":284
+ *     _info = {}
+ *     _filter = {}
+ *     _format = {}             # <<<<<<<<<<<<<<
+ * 
+ *     # header; and required columns
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___format, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":287
+ * 
+ *     # header; and required columns
+ *     _required = ["CHROM","POS","ID","REF","ALT","QUAL","FILTER","INFO","FORMAT"]             # <<<<<<<<<<<<<<
+ *     _samples = []
+ * 
+ */
+  __pyx_t_3 = PyList_New(9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__CHROM));
+  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__CHROM));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CHROM));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__POS));
+  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__POS));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__POS));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
+  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__ID));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__REF));
+  PyList_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__REF));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__REF));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ALT));
+  PyList_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__ALT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ALT));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__QUAL));
+  PyList_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__QUAL));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__QUAL));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FILTER));
+  PyList_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__FILTER));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FILTER));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__INFO));
+  PyList_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__INFO));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__INFO));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__FORMAT));
+  PyList_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__FORMAT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FORMAT));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___required, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":288
+ *     # header; and required columns
+ *     _required = ["CHROM","POS","ID","REF","ALT","QUAL","FILTER","INFO","FORMAT"]
+ *     _samples = []             # <<<<<<<<<<<<<<
+ * 
+ *     # control behaviour
+ */
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___samples, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":291
+ * 
+ *     # control behaviour
+ *     _ignored_errors = set([11])   # ERROR_UNKNOWN_KEY             # <<<<<<<<<<<<<<
+ *     _warn_errors = set([])
+ *     _leftalign = False
+ */
+  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_INCREF(__pyx_int_11);
+  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_11);
+  __Pyx_GIVEREF(__pyx_int_11);
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __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(((PyObject *)((PyObject*)&PySet_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___ignored_errors, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":292
+ *     # control behaviour
+ *     _ignored_errors = set([11])   # ERROR_UNKNOWN_KEY
+ *     _warn_errors = set([])             # <<<<<<<<<<<<<<
+ *     _leftalign = False
+ * 
+ */
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __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(((PyObject *)((PyObject*)&PySet_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___warn_errors, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":293
+ *     _ignored_errors = set([11])   # ERROR_UNKNOWN_KEY
+ *     _warn_errors = set([])
+ *     _leftalign = False             # <<<<<<<<<<<<<<
+ * 
+ *     # reference sequence
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___leftalign, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":296
+ * 
+ *     # reference sequence
+ *     _reference = None             # <<<<<<<<<<<<<<
+ * 
+ *     # regions to include; None includes everything
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___reference, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":299
+ * 
+ *     # regions to include; None includes everything
+ *     _regions = None             # <<<<<<<<<<<<<<
+ * 
+ *     # statefull stuff
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___regions, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":302
+ * 
+ *     # statefull stuff
+ *     _lineno = -1             # <<<<<<<<<<<<<<
+ *     _line = None
+ *     _lines = None
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___lineno, __pyx_int_neg_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":303
+ *     # statefull stuff
+ *     _lineno = -1
+ *     _line = None             # <<<<<<<<<<<<<<
+ *     _lines = None
+ * 
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___line, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":304
+ *     _lineno = -1
+ *     _line = None
+ *     _lines = None             # <<<<<<<<<<<<<<
+ * 
+ *     def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):
+ */
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___lines, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":306
+ *     _lines = None
+ * 
+ *     def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):             # <<<<<<<<<<<<<<
+ *         # make error identifiers accessible by name
+ *         for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_13 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF___init__, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":327
+ *         self._lines = lines
+ * 
+ *     def error(self,line,error,opt=None):             # <<<<<<<<<<<<<<
+ *         if error in self._ignored_errors: return
+ *         errorlabel, errorstring = self._errors[error].split(':')
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_error, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__error, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":336
+ *         raise ValueError(errorstring)
+ * 
+ *     def parse_format(self,line,format,filter=False):             # <<<<<<<<<<<<<<
+ *         if self._version == 40:
+ *             if not format.startswith('<'):
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_15 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse_format, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); 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);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse_format, __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;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":398
+ * 
+ * 
+ *     def format_format( self, fmt, filter=False ):             # <<<<<<<<<<<<<<
+ *         values = [('ID',fmt.id)]
+ *         if fmt.number != None and not filter:
+ */
+  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_k_32 = __pyx_t_4;
+  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_format_format, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__format_format, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":418
+ *         return format
+ * 
+ *     def get_expected(self, format, formatdict, alt):             # <<<<<<<<<<<<<<
+ *         fmt = formatdict[format]
+ *         if fmt.numbertype == self.NT_UNKNOWN: return -1
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_get_expected, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__get_expected, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":429
+ * 
+ * 
+ *     def _add_definition(self, formatdict, key, data, line ):             # <<<<<<<<<<<<<<
+ *         if key in formatdict: return
+ *         self.error(line,self.ERROR_UNKNOWN_KEY,key)
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF__add_definition, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___add_definition, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":446
+ * 
+ *     # todo: trim trailing missing values
+ *     def format_formatdata( self, data, format, key=True, value=True, separator=":" ):             # <<<<<<<<<<<<<<
+ *         output, sdata = [], []
+ *         if type(data) == type([]): # for FORMAT field, make data with dummy values
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_36 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_37 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_format_formatdata, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__format_formatdata, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":480
+ * 
+ * 
+ *     def enter_default_format(self):             # <<<<<<<<<<<<<<
+ *         for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+ *                   FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_enter_default_format, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s_69, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":489
+ *                 self._format[f.id] = f
+ * 
+ *     def parse_header( self, line ):             # <<<<<<<<<<<<<<
+ *         assert line.startswith('##')
+ *         elts = line[2:].split('=')
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse_header, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse_header, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":518
+ * 
+ * 
+ *     def write_header( self, stream ):             # <<<<<<<<<<<<<<
+ *         stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+ *         for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_write_header, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__write_header, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":525
+ * 
+ * 
+ *     def parse_heading( self, line ):             # <<<<<<<<<<<<<<
+ *         assert line.startswith('#')
+ *         assert not line.startswith('##')
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse_heading, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse_heading, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":553
+ *         self._sample2column = dict( [(y,x+9) for x,y in enumerate( self._samples ) ] )
+ * 
+ *     def write_heading( self, stream ):             # <<<<<<<<<<<<<<
+ *         stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+ * 
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_write_heading, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__write_heading, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":556
+ *         stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+ * 
+ *     def convertGT(self, GTstring):             # <<<<<<<<<<<<<<
+ *         if GTstring == ".": return ["."]
+ *         try:
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_convertGT, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); 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_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__convertGT, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":569
+ * 
+ * 
+ *     def convertGTback(self, GTdata):             # <<<<<<<<<<<<<<
+ *         return ''.join(map(str,GTdata))
+ * 
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_convertGTback, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); 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_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__convertGTback, __pyx_t_3) < 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;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":572
+ *         return ''.join(map(str,GTdata))
+ * 
+ *     def parse_formatdata( self, key, value, formatdict, line ):             # <<<<<<<<<<<<<<
+ *         # To do: check that the right number of values is present
+ *         f = formatdict.get(key,None)
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse_formatdata, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse_formatdata, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":615
+ * 
+ * 
+ *     def inregion(self, chrom, pos):             # <<<<<<<<<<<<<<
+ *         if not self._regions: return True
+ *         for r in self._regions:
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_inregion, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__inregion, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":622
+ * 
+ * 
+ *     def parse_data( self, line, lineparse=False ):             # <<<<<<<<<<<<<<
+ *         cols = line.split('\t')
+ *         if len(cols) != len(self._samples)+9:
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_61 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse_data, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse_data, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":822
+ * 
+ * 
+ *     def write_data(self, stream, data):             # <<<<<<<<<<<<<<
+ *         required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+ *         for k in required:
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_write_data, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__write_data, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":851
+ *         stream.write( "\t".join(output) + "\n" )
+ * 
+ *     def _parse_header(self, stream):             # <<<<<<<<<<<<<<
+ *         self._lineno = 0
+ *         for line in stream:
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF__parse_header, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___parse_header, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":864
+ *         return line
+ * 
+ *     def _parse(self, line, stream):             # <<<<<<<<<<<<<<
+ *         if len(line.strip()) > 0:
+ *             d = self.parse_data( line.strip() )
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF__parse, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s___parse, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":880
+ *     ######################################################################################################
+ * 
+ *     def getsamples(self):             # <<<<<<<<<<<<<<
+ *         """ List of samples in VCF file """
+ *         return self._samples
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_getsamples, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__getsamples, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":884
+ *         return self._samples
+ * 
+ *     def setsamples(self,samples):             # <<<<<<<<<<<<<<
+ *         """ List of samples in VCF file """
+ *         self._samples = samples
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setsamples, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setsamples, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":888
+ *         self._samples = samples
+ * 
+ *     def getheader(self):             # <<<<<<<<<<<<<<
+ *         """ List of header key-value pairs (strings) """
+ *         return self._header
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_getheader, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__getheader, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":892
+ *         return self._header
+ * 
+ *     def setheader(self,header):             # <<<<<<<<<<<<<<
+ *         """ List of header key-value pairs (strings) """
+ *         self._header = header
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setheader, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setheader, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":896
+ *         self._header = header
+ * 
+ *     def getinfo(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         return self._info
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_getinfo, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__getinfo, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":900
+ *         return self._info
+ * 
+ *     def setinfo(self,info):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+ *         self._info = info
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setinfo, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setinfo, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":904
+ *         self._info = info
+ * 
+ *     def getformat(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         return self._format
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_getformat, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__getformat, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":908
+ *         return self._format
+ * 
+ *     def setformat(self,format):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+ *         self._format = format
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setformat, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setformat, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":912
+ *         self._format = format
+ * 
+ *     def getfilter(self):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         return self._filter
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_getfilter, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__getfilter, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":916
+ *         return self._filter
+ * 
+ *     def setfilter(self,filter):             # <<<<<<<<<<<<<<
+ *         """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+ *         self._filter = filter
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setfilter, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setfilter, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":920
+ *         self._filter = filter
+ * 
+ *     def setversion(self, version):             # <<<<<<<<<<<<<<
+ *         if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")
+ *         self._version = version
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setversion, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setversion, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":924
+ *         self._version = version
+ * 
+ *     def setregions(self, regions):             # <<<<<<<<<<<<<<
+ *         self._regions = regions
+ * 
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setregions, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setregions, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":927
+ *         self._regions = regions
+ * 
+ *     def setreference(self, ref):             # <<<<<<<<<<<<<<
+ *         """ Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile """
+ *         self._reference = ref
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_setreference, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__setreference, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":931
+ *         self._reference = ref
+ * 
+ *     def ignoreerror(self, errorstring):             # <<<<<<<<<<<<<<
+ *         try:             self._ignored_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_ignoreerror, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__ignoreerror, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":935
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ *     def warnerror(self, errorstring):             # <<<<<<<<<<<<<<
+ *         try:             self._warn_errors.add(self.__dict__[errorstring])
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_warnerror, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__warnerror, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":939
+ *         except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+ * 
+ *     def parse(self, stream):             # <<<<<<<<<<<<<<
+ *         """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+ *         last_line = self._parse_header(stream)
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_parse, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__parse, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":946
+ *         return self._parse(last_line, stream)
+ * 
+ *     def write(self, stream, datagenerator):             # <<<<<<<<<<<<<<
+ *         """ Writes a VCF file to a stream, using a data generator (or list) """
+ *         self.write_header(stream)
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_write, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__write, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":952
+ *         for data in datagenerator: self.write_data(stream,data)
+ * 
+ *     def writeheader(self, stream):             # <<<<<<<<<<<<<<
+ *         """ Writes a VCF header """
+ *         self.write_header(stream)
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_writeheader, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__writeheader, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":957
+ *         self.write_heading(stream)
+ * 
+ *     def compare_calls(self, pos1, ref1, alt1, pos2, ref2, alt2):             # <<<<<<<<<<<<<<
+ *         """ Utility function: compares two calls for equality """
+ *         # a variant should always be assigned to a unique position, one base before
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_compare_calls, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__compare_calls, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":979
+ * ###########################################################################################################
+ * 
+ *     def connect( self, filename ):             # <<<<<<<<<<<<<<
+ *         '''connect to tabix file.'''
+ *         self.tabixfile = pysam.Tabixfile( filename )
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_connect, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__connect, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":984
+ *         self._parse_header(self.tabixfile.header)
+ * 
+ *     def fetch(self,             # <<<<<<<<<<<<<<
+ *               reference = None,
+ *               start = None,
+ */
+  __pyx_t_3 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_fetch, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__fetch, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":993
+ *         return self.tabixfile.fetch( reference, start, end, region, parser = asVCFRecord( self ) )
+ * 
+ *     def validate( self, record ):             # <<<<<<<<<<<<<<
+ *         '''validate vcf record.
+ * 
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_4cvcf_3VCF_validate, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__validate, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VCF, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1118
+ *                     pos -= 1
+ * 
+ * __all__ = [             # <<<<<<<<<<<<<<
+ *     "VCF", "VCFRecord", ]
+ * 
+ */
+  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__VCF));
+  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__VCF));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VCF));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__VCFRecord));
+  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__VCFRecord));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VCFRecord));
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/cvcf.pyx":1
+ * #             # <<<<<<<<<<<<<<
+ * # Code to read, write and edit VCF files
+ * #
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getsamples); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_107), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setsamples); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_108), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getheader); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_109), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setheader); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_110), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_111), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_112), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getformat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_113), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setformat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_114), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getfilter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_115), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setfilter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_116), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setreference); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_117), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__parse); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_118), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_119), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__writeheader); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_120), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__compare_calls); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_121), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__connect); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_122), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fetch); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_123), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__VCF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__validate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_124), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "pysam/ctabix.pxd":2
+ * 
+ * cdef extern from "string.h":             # <<<<<<<<<<<<<<
+ *   ctypedef int size_t
+ *   void *memcpy(void *dst,void *src,size_t len)
+ */
+  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);
+  if (__pyx_m) {
+    __Pyx_AddTraceback("init cvcf");
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init cvcf");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* Runtime support code */
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+    PyObject *result;
+    result = PyObject_GetAttr(dict, name);
+    if (!result)
+        PyErr_SetObject(PyExc_NameError, name);
+    return result;
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AS_STRING(kw_name));
+        #endif
+}
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *number, *more_or_less;
+
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    number = (num_expected == 1) ? "" : "s";
+    PyErr_Format(PyExc_TypeError,
+        #if PY_VERSION_HEX < 0x02050000
+            "%s() takes %s %d positional argument%s (%d given)",
+        #else
+            "%s() takes %s %zd positional argument%s (%zd given)",
+        #endif
+        func_name, more_or_less, num_expected, number, num_found);
+}
+
+static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+        } else {
+            #if PY_MAJOR_VERSION < 3
+            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
+            #else
+            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
+            #endif
+                goto invalid_keyword_type;
+            } else {
+                for (name = first_kw_arg; *name; name++) {
+                    #if PY_MAJOR_VERSION >= 3
+                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
+                        PyUnicode_Compare(**name, key) == 0) break;
+                    #else
+                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
+                        _PyString_Eq(**name, key)) break;
+                    #endif
+                }
+                if (*name) {
+                    values[name-argnames] = value;
+                } else {
+                    /* unexpected keyword found */
+                    for (name=argnames; name != first_kw_arg; name++) {
+                        if (**name == key) goto arg_passed_twice;
+                        #if PY_MAJOR_VERSION >= 3
+                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
+                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
+                        #else
+                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
+                            _PyString_Eq(**name, key)) goto arg_passed_twice;
+                        #endif
+                    }
+                    if (kwds2) {
+                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+                    } else {
+                        goto invalid_keyword;
+                    }
+                }
+            }
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%s() got an unexpected keyword argument '%s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
+    PyObject *local_type, *local_value, *local_tb;
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+    local_type = tstate->curexc_type;
+    local_value = tstate->curexc_value;
+    local_tb = tstate->curexc_traceback;
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
+    if (unlikely(tstate->curexc_type))
+        goto bad;
+    #if PY_MAJOR_VERSION >= 3
+    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
+        goto bad;
+    #endif
+    *type = local_type;
+    *value = local_value;
+    *tb = local_tb;
+    Py_INCREF(local_type);
+    Py_INCREF(local_value);
+    Py_INCREF(local_tb);
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = local_type;
+    tstate->exc_value = local_value;
+    tstate->exc_traceback = local_tb;
+    /* Make sure tstate is in a consistent state when we XDECREF
+       these objects (XDECREF may run arbitrary code). */
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+    return 0;
+bad:
+    *type = 0;
+    *value = 0;
+    *tb = 0;
+    Py_XDECREF(local_type);
+    Py_XDECREF(local_value);
+    Py_XDECREF(local_tb);
+    return -1;
+}
+
+
+static double __Pyx__PyObject_AsDouble(PyObject* obj) {
+    PyObject* float_value;
+    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
+        return PyFloat_AsDouble(obj);
+    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
+#if PY_MAJOR_VERSION >= 3
+        float_value = PyFloat_FromString(obj);
+#else
+        float_value = PyFloat_FromString(obj, 0);
+#endif
+    } else {
+        PyObject* args = PyTuple_New(1);
+        if (unlikely(!args)) goto bad;
+        PyTuple_SET_ITEM(args, 0, obj);
+        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
+        PyTuple_SET_ITEM(args, 0, 0);
+        Py_DECREF(args);
+    }
+    if (likely(float_value)) {
+        double value = PyFloat_AS_DOUBLE(float_value);
+        Py_DECREF(float_value);
+        return value;
+    }
+bad:
+    return (double)-1;
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
+    PyErr_Format(PyExc_ValueError,
+        #if PY_VERSION_HEX < 0x02050000
+                 "need more than %d value%s to unpack", (int)index,
+        #else
+                 "need more than %zd value%s to unpack", index,
+        #endif
+                 (index == 1) ? "" : "s");
+}
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+    PyErr_Format(PyExc_ValueError,
+        #if PY_VERSION_HEX < 0x02050000
+            "too many values to unpack (expected %d)", (int)expected);
+        #else
+            "too many values to unpack (expected %zd)", expected);
+        #endif
+}
+
+static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
+    PyObject *item;
+    if (!(item = PyIter_Next(iter))) {
+        if (!PyErr_Occurred()) {
+            __Pyx_RaiseNeedMoreValuesError(index);
+        }
+    }
+    return item;
+}
+
+static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
+    PyObject *item;
+    if ((item = PyIter_Next(iter))) {
+        Py_DECREF(item);
+        __Pyx_RaiseTooManyValuesError(expected);
+        return -1;
+    }
+    else if (!PyErr_Occurred())
+        return 0;
+    else
+        return -1;
+}
+
+static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
+    Py_ssize_t q = a / b;
+    Py_ssize_t r = a - q*b;
+    q -= ((r != 0) & ((r ^ b) < 0));
+    return q;
+}
+
+
+static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->exc_type;
+    *value = tstate->exc_value;
+    *tb = tstate->exc_traceback;
+    Py_XINCREF(*type);
+    Py_XINCREF(*value);
+    Py_XINCREF(*tb);
+}
+
+static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = type;
+    tstate->exc_value = value;
+    tstate->exc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
+    PyObject *py_import = 0;
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+    if (!py_import)
+        goto bad;
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    module = PyObject_CallFunctionObjArgs(py_import,
+        name, global_dict, empty_dict, list, NULL);
+bad:
+    Py_XDECREF(empty_list);
+    Py_XDECREF(py_import);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+static PyObject *__Pyx_CreateClass(
+    PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
+{
+    PyObject *py_modname;
+    PyObject *result = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_modname = PyString_FromString(modname);
+    #else
+    py_modname = PyUnicode_FromString(modname);
+    #endif
+    if (!py_modname)
+        goto bad;
+    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
+        goto bad;
+    #if PY_MAJOR_VERSION < 3
+    result = PyClass_New(bases, dict, name);
+    #else
+    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
+    #endif
+bad:
+    Py_XDECREF(py_modname);
+    return result;
+}
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+}
+
+
+#if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    #if PY_VERSION_HEX < 0x02050000
+    if (!PyClass_Check(type))
+    #else
+    if (!PyType_Check(type))
+    #endif
+    {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        /* Normalize to raise <class>, <instance> */
+        Py_DECREF(value);
+        value = type;
+        #if PY_VERSION_HEX < 0x02050000
+            if (PyInstance_Check(type)) {
+                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+                Py_INCREF(type);
+            }
+            else {
+                type = 0;
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception must be an old-style class or instance");
+                goto raise_error;
+            }
+        #else
+            type = (PyObject*) Py_TYPE(type);
+            Py_INCREF(type);
+            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception class must be a subclass of BaseException");
+                goto raise_error;
+            }
+        #endif
+    }
+
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+#else /* Python 3+ */
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (!PyExceptionClass_Check(type)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+
+    PyErr_SetObject(type, value);
+
+    if (tb) {
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+    }
+
+bad:
+    return;
+}
+#endif
+
+static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
+    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
+    const int is_unsigned = const_zero < neg_one;
+    if ((sizeof(uint32_t) == sizeof(char))  ||
+        (sizeof(uint32_t) == sizeof(short))) {
+        return PyInt_FromLong((long)val);
+    } else if ((sizeof(uint32_t) == sizeof(int)) ||
+               (sizeof(uint32_t) == sizeof(long))) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLong((unsigned long)val);
+        else
+            return PyInt_FromLong((long)val);
+    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
+        else
+            return PyLong_FromLongLong((PY_LONG_LONG)val);
+    } else {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&val;
+        return _PyLong_FromByteArray(bytes, sizeof(uint32_t), 
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
+    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned char" :
+                    "value too large to convert to unsigned char");
+            }
+            return (unsigned char)-1;
+        }
+        return (unsigned char)val;
+    }
+    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
+    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned short" :
+                    "value too large to convert to unsigned short");
+            }
+            return (unsigned short)-1;
+        }
+        return (unsigned short)val;
+    }
+    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
+    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(unsigned int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(unsigned int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to unsigned int" :
+                    "value too large to convert to unsigned int");
+            }
+            return (unsigned int)-1;
+        }
+        return (unsigned int)val;
+    }
+    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
+}
+
+static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
+    const char neg_one = (char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to char" :
+                    "value too large to convert to char");
+            }
+            return (char)-1;
+        }
+        return (char)val;
+    }
+    return (char)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
+    const short neg_one = (short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to short" :
+                    "value too large to convert to short");
+            }
+            return (short)-1;
+        }
+        return (short)val;
+    }
+    return (short)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
+    const int neg_one = (int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to int" :
+                    "value too large to convert to int");
+            }
+            return (int)-1;
+        }
+        return (int)val;
+    }
+    return (int)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
+    const signed char neg_one = (signed char)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed char) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed char)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed char" :
+                    "value too large to convert to signed char");
+            }
+            return (signed char)-1;
+        }
+        return (signed char)val;
+    }
+    return (signed char)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
+    const signed short neg_one = (signed short)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed short) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed short)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed short" :
+                    "value too large to convert to signed short");
+            }
+            return (signed short)-1;
+        }
+        return (signed short)val;
+    }
+    return (signed short)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
+    const signed int neg_one = (signed int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(signed int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(signed int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to signed int" :
+                    "value too large to convert to signed int");
+            }
+            return (signed int)-1;
+        }
+        return (signed int)val;
+    }
+    return (signed int)__Pyx_PyInt_AsSignedLong(x);
+}
+
+static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
+    const int neg_one = (int)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (sizeof(int) < sizeof(long)) {
+        long val = __Pyx_PyInt_AsLong(x);
+        if (unlikely(val != (long)(int)val)) {
+            if (!unlikely(val == -1 && PyErr_Occurred())) {
+                PyErr_SetString(PyExc_OverflowError,
+                    (is_unsigned && unlikely(val < 0)) ?
+                    "can't convert negative value to int" :
+                    "value too large to convert to int");
+            }
+            return (int)-1;
+        }
+        return (int)val;
+    }
+    return (int)__Pyx_PyInt_AsLong(x);
+}
+
+static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
+    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to unsigned long");
+            return (unsigned long)-1;
+        }
+        return (unsigned long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to unsigned long");
+                return (unsigned long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        unsigned long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (unsigned long)-1;
+        val = __Pyx_PyInt_AsUnsignedLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
+    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to unsigned PY_LONG_LONG");
+            return (unsigned PY_LONG_LONG)-1;
+        }
+        return (unsigned PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to unsigned PY_LONG_LONG");
+                return (unsigned PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        unsigned PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (unsigned PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
+    const long neg_one = (long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to long");
+            return (long)-1;
+        }
+        return (long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to long");
+                return (long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (long)-1;
+        val = __Pyx_PyInt_AsLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
+    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to PY_LONG_LONG");
+            return (PY_LONG_LONG)-1;
+        }
+        return (PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to PY_LONG_LONG");
+                return (PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
+    const signed long neg_one = (signed long)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to signed long");
+            return (signed long)-1;
+        }
+        return (signed long)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to signed long");
+                return (signed long)-1;
+            }
+            return PyLong_AsUnsignedLong(x);
+        } else {
+            return PyLong_AsLong(x);
+        }
+    } else {
+        signed long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (signed long)-1;
+        val = __Pyx_PyInt_AsSignedLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
+    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_VERSION_HEX < 0x03000000
+    if (likely(PyInt_Check(x))) {
+        long val = PyInt_AS_LONG(x);
+        if (is_unsigned && unlikely(val < 0)) {
+            PyErr_SetString(PyExc_OverflowError,
+                            "can't convert negative value to signed PY_LONG_LONG");
+            return (signed PY_LONG_LONG)-1;
+        }
+        return (signed PY_LONG_LONG)val;
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to signed PY_LONG_LONG");
+                return (signed PY_LONG_LONG)-1;
+            }
+            return PyLong_AsUnsignedLongLong(x);
+        } else {
+            return PyLong_AsLongLong(x);
+        }
+    } else {
+        signed PY_LONG_LONG val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (signed PY_LONG_LONG)-1;
+        val = __Pyx_PyInt_AsSignedLongLong(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+    long size, int strict)
+{
+    PyObject *py_module = 0;
+    PyObject *result = 0;
+    PyObject *py_name = 0;
+    char warning[200];
+
+    py_module = __Pyx_ImportModule(module_name);
+    if (!py_module)
+        goto bad;
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(class_name);
+    #else
+    py_name = PyUnicode_FromString(class_name);
+    #endif
+    if (!py_name)
+        goto bad;
+    result = PyObject_GetAttr(py_module, py_name);
+    Py_DECREF(py_name);
+    py_name = 0;
+    Py_DECREF(py_module);
+    py_module = 0;
+    if (!result)
+        goto bad;
+    if (!PyType_Check(result)) {
+        PyErr_Format(PyExc_TypeError, 
+            "%s.%s is not a type object",
+            module_name, class_name);
+        goto bad;
+    }
+    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
+        PyOS_snprintf(warning, sizeof(warning), 
+            "%s.%s size changed, may indicate binary incompatibility",
+            module_name, class_name);
+        #if PY_VERSION_HEX < 0x02050000
+        PyErr_Warn(NULL, warning);
+        #else
+        PyErr_WarnEx(NULL, warning, 0);
+        #endif
+    }
+    else if (((PyTypeObject *)result)->tp_basicsize != size) {
+        PyErr_Format(PyExc_ValueError, 
+            "%s.%s has the wrong size, try recompiling",
+            module_name, class_name);
+        goto bad;
+    }
+    return (PyTypeObject *)result;
+bad:
+    Py_XDECREF(py_module);
+    Py_XDECREF(result);
+    return 0;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+    PyObject *py_name = 0;
+    PyObject *py_module = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_name = PyString_FromString(name);
+    #else
+    py_name = PyUnicode_FromString(name);
+    #endif
+    if (!py_name)
+        goto bad;
+    py_module = PyImport_Import(py_name);
+    Py_DECREF(py_name);
+    return py_module;
+bad:
+    Py_XDECREF(py_name);
+    return 0;
+}
+#endif
+
+static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
+    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
+    if (!ob)
+        goto bad;
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+    *(void **)vtabptr = PyCapsule_GetPointer(ob, 0);
+#else
+    *(void **)vtabptr = PyCObject_AsVoidPtr(ob);
+#endif
+    if (!*(void **)vtabptr)
+        goto bad;
+    Py_DECREF(ob);
+    return 0;
+bad:
+    Py_XDECREF(ob);
+    return -1;
+}
+
+static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+    PyObject *ob = PyCapsule_New(vtable, 0, 0);
+#else
+    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
+#endif
+    if (!ob)
+        goto bad;
+    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
+        goto bad;
+    Py_DECREF(ob);
+    return 0;
+bad:
+    Py_XDECREF(ob);
+    return -1;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(const char *funcname) {
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    PyObject *py_globals = 0;
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(__pyx_filename);
+    #else
+    py_srcfile = PyUnicode_FromString(__pyx_filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (__pyx_clineno) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    py_code = PyCode_New(
+        0,            /*int argcount,*/
+        #if PY_MAJOR_VERSION >= 3
+        0,            /*int kwonlyargcount,*/
+        #endif
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple,  /*PyObject *consts,*/
+        __pyx_empty_tuple,  /*PyObject *names,*/
+        __pyx_empty_tuple,  /*PyObject *varnames,*/
+        __pyx_empty_tuple,  /*PyObject *freevars,*/
+        __pyx_empty_tuple,  /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        __pyx_lineno,   /*int firstlineno,*/
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    if (!py_code) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = __pyx_lineno;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else  /* Python 3+ has unicode identifiers */
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+/* Type Conversion Functions */
+
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
+  PyNumberMethods *m;
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_VERSION_HEX < 0x03000000
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return Py_INCREF(x), x;
+  m = Py_TYPE(x)->tp_as_number;
+#if PY_VERSION_HEX < 0x03000000
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+#else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+#endif
+  if (res) {
+#if PY_VERSION_HEX < 0x03000000
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%s__ returned non-%s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject* x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+#if PY_VERSION_HEX < 0x02050000
+   if (ival <= LONG_MAX)
+       return PyInt_FromLong((long)ival);
+   else {
+       unsigned char *bytes = (unsigned char *) &ival;
+       int one = 1; int little = (int)*(unsigned char*)&one;
+       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
+   }
+#else
+   return PyInt_FromSize_t(ival);
+#endif
+}
+
+static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
+   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
+   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
+       return (size_t)-1;
+   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
+       PyErr_SetString(PyExc_OverflowError,
+                       "value too large to convert to size_t");
+       return (size_t)-1;
+   }
+   return (size_t)val;
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/pysam/cvcf.pxd b/pysam/cvcf.pxd
new file mode 100644 (file)
index 0000000..477e0fa
--- /dev/null
@@ -0,0 +1,41 @@
+cdef extern from "stdlib.h":
+    void free(void *)
+    void *malloc(size_t)       
+    void *calloc(size_t,size_t)
+    void *realloc(void *,size_t)
+    int c_abs "abs" (int)  
+    int c_abs "abs" (int)
+    int atoi( char *nptr)
+    long atol( char *nptr)
+    double atof( char *nptr)
+
+cdef extern from "Python.h":
+    ctypedef struct FILE
+    FILE* PyFile_AsFile(object)
+    char *fgets(char *str, int size, FILE *ifile)
+    int feof(FILE *stream)
+    size_t strlen(char *s)
+    size_t getline(char **lineptr, size_t *n, FILE *stream)
+    char *strstr(char *, char *)
+    char *strchr(char *string, int c)
+    int fileno(FILE *stream)
+
+cdef extern from "string.h":
+  int strcmp(char *s1, char *s2)
+  int strncmp(char *s1,char *s2,size_t len)
+  char *strcpy(char *dest,char *src)
+  char *strncpy(char *dest,char *src, size_t len)
+  char *strdup(char *)
+  char *strcat(char *,char *)
+  size_t strlen(char *s)
+  int memcmp( void * s1, void *s2, size_t len )
+  void *memcpy(void *dest, void *src, size_t n)
+  void *memchr(void *s, int c, size_t n)
+
+cdef extern from "stdint.h":
+  ctypedef int int64_t
+  ctypedef int int32_t
+  ctypedef int uint32_t
+  ctypedef int uint8_t
+  ctypedef int uint64_t
+
diff --git a/pysam/cvcf.pyx b/pysam/cvcf.pyx
new file mode 100644 (file)
index 0000000..d3f92d3
--- /dev/null
@@ -0,0 +1,1121 @@
+#
+# Code to read, write and edit VCF files
+#
+# VCF lines are encoded as a dictionary with these keys (note: all lowercase):
+# 'chrom':  string
+# 'pos':    integer
+# 'id':     string
+# 'ref':    string
+# 'alt':    list of strings
+# 'qual':   integer
+# 'filter': None (missing value), or list of keys (strings); empty list parsed as ["PASS"]
+# 'info':   dictionary of values (see below)
+# 'format': list of keys (strings)
+# sample keys: dictionary of values (see below)
+#
+# The sample keys are accessible through vcf.getsamples()
+#
+# A dictionary of values contains value keys (defined in ##INFO or ##FORMAT lines) which map
+# to a list, containign integers, floats, strings, or characters.  Missing values are replaced 
+# by a particular value, often -1 or .
+#
+# Genotypes are not stored as a string, but as a list of 1 or 3 elements (for haploid and diploid samples),
+# the first (and last) the integer representing an allele, and the second the separation character.
+# Note that there is just one genotype per sample, but for consistency the single element is stored in a list.
+#
+# Header lines other than ##INFO, ##FORMAT and ##FILTER are stored as (key, value) pairs and are accessible
+# through getheader()
+#
+# The VCF class can be instantiated with a 'regions' variable consisting of tuples (chrom,start,end) encoding
+# 0-based half-open segments.  Only variants with a position inside the segment will be parsed.  A regions
+# parser is available under parse_regions.
+#
+# When instantiated, a reference can be passed to the VCF class.  This may be any class that supports a
+# fetch(chrom, start, end) method.
+#
+#
+#
+# NOTE: the position that is returned to Python is 0-based, NOT 1-based as in the VCF file.
+#
+#
+#
+# TODO:
+#  only v4.0 writing is complete; alleles are not converted to v3.3 format
+#
+
+from collections import namedtuple, defaultdict
+from operator import itemgetter
+import sys, re, copy, bisect
+
+cimport ctabix
+cimport TabProxies
+import pysam
+
+gtsRegEx = re.compile("[|/\\\\]")
+alleleRegEx = re.compile('^[ACGTN]+$')
+
+# Utility function.  Uses 0-based coordinates
+def get_sequence(chrom, start, end, fa):
+    # obtain sequence from .fa file, without truncation
+    if end<=start: return ""
+    if not fa: return "N"*(end-start)
+    if start<0: return "N"*(-start) + get_sequence(chrom, 0, end, fa).upper()
+    sequence = fa.fetch(chrom, start, end).upper()
+    if len(sequence) < end-start: sequence += "N"*(end-start-len(sequence))
+    return sequence
+
+# Utility function.  Parses a region string
+def parse_regions( string ):
+    result = []
+    for r in string.split(','):
+        elts = r.split(':')
+        chrom, start, end = elts[0], 0, 3000000000
+        if len(elts)==1: pass
+        elif len(elts)==2:
+            if len(elts[1])>0:
+                ielts = elts[1].split('-')
+                if len(ielts) != 2: ValueError("Don't understand region string '%s'" % r)
+                try:    start, end = int(ielts[0])-1, int(ielts[1])
+                except: raise ValueError("Don't understand region string '%s'" % r)
+        else:
+            raise ValueError("Don't understand region string '%s'" % r)
+        result.append( (chrom,start,end) )
+    return result
+            
+
+FORMAT = namedtuple('FORMAT','id numbertype number type description missingvalue')
+
+###########################################################################################################
+# 
+# New class
+# 
+###########################################################################################################
+
+cdef class VCFRecord( TabProxies.TupleProxy):
+    '''vcf record.
+
+    initialized from data and vcf meta 
+    '''
+    
+    cdef vcf
+    cdef char * contig
+    cdef uint32_t pos
+
+    def __init__(self, vcf):
+        self.vcf = vcf
+        # if len(data) != len(self.vcf._samples):
+        #     self.error(str(data),
+        #                self.BAD_NUMBER_OF_COLUMNS, 
+        #                "expected %s for %s samples (%s), got %s" % \
+        #                    (len(self.vcf._samples), 
+        #                     len(self.vcf._samples), 
+        #                     self.vcf._samples, 
+        #                     len(data)))
+    
+    def __cinit__(self, vcf ): 
+        # start indexed access at genotypes
+        self.offset = 9
+        
+        self.vcf = vcf
+    
+    cdef update( self, char * buffer, size_t nbytes ):
+        '''update internal data.
+        
+        nbytes does not include the terminal '\0'.
+        '''
+        TabProxies.TupleProxy.update( self, buffer, nbytes )
+
+        self.contig = self.fields[0]
+        # vcf counts from 1 - correct here
+        self.pos = atoi( self.fields[1] ) - 1
+
+    def __len__(self):
+        return max(0, self.nfields - 9)
+
+    property contig:
+        def __get__(self): return self.contig
+
+    property pos:
+        def __get__(self): return self.pos
+
+    property id:
+        def __get__(self): return self.fields[2]
+
+    property ref:
+        def __get__(self): return self.fields[3]
+
+    property alt:
+        def __get__(self):
+            # convert v3.3 to v4.0 alleles below
+            alt = self.fields[4] 
+            if alt == ".": alt = []
+            else: alt = alt.upper().split(',')
+            return alt
+
+    property qual:
+        def __get__(self):
+            qual = self.fields[5]
+            if qual == b".": qual = -1
+            else: 
+                try:    qual = float(qual)
+                except: self.vcf.error(str(self),self.QUAL_NOT_NUMERICAL)
+
+    property filter:
+        def __get__(self):
+            f = self.fields[6]
+            # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+            if f == b"." or f == b"PASS" or f == b"0": return []
+            else: return f.split(';')
+
+    property info:
+        def __get__(self):
+            col = self.fields[7]
+            # dictionary of keys, and list of values
+            info = {}
+            if col != b".":
+                for blurp in col.split(';'):
+                    elts = blurp.split('=')
+                    if len(elts) == 1: v = None
+                    elif len(elts) == 2: v = elts[1]
+                    else: self.vcf.error(str(self),self.ERROR_INFO_STRING)
+                    info[elts[0]] = self.vcf.parse_formatdata(elts[0], v, self.vcf._info, str(self))
+            return info
+
+    property format:
+         def __get__(self):
+             return self.fields[8].split(':')
+
+    property samples:
+        def __get__(self):
+            return self.vcf._samples
+
+    def __getitem__(self, key):
+        
+        # parse sample columns
+        values = self.fields[self.vcf._sample2column[key]].split(':')
+        alt = self.alt
+        format = self.format
+
+        if len(values) > len(format):
+            self.error(str(self.line),self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" %\
+                           (len(values),key,len(format)))
+
+        result = {}
+        for idx in range(len(format)):
+            expected = self.vcf.get_expected(format[idx], self.vcf._format, alt)
+            if idx < len(values): value = values[idx]
+            else:
+                if expected == -1: value = "."
+                else: value = ",".join(["."]*expected)
+
+            result[format[idx]] = self.vcf.parse_formatdata(format[idx], value, self.vcf._format, str(self.data))
+            if expected != -1 and len(result[format[idx]]) != expected:
+                self.error(str(self.data),self.BAD_NUMBER_OF_PARAMETERS,
+                           "id=%s, expected %s parameters, got %s" % (format[idx],expected,result[format[idx]]))
+                if len(result[format[idx]] ) < expected: result[format[idx]] += [result[format[idx]][-1]]*(expected-len(result[format[idx]]))
+                result[format[idx]] = result[format[idx]][:expected]
+
+        return result
+
+cdef class asVCFRecord( ctabix.Parser ): 
+    '''converts a :term:`tabix row` into a VCF record.'''
+    cdef vcffile
+    def __init__(self, vcffile ):
+        self.vcffile = vcffile
+    def __call__(self, char * buffer, int len ):
+        cdef VCFRecord r
+        r = VCFRecord( self.vcffile )
+        r.copy( buffer, len )
+        return r
+
+class VCF(object):
+
+    # types
+    NT_UNKNOWN = 0
+    NT_NUMBER = 1
+    NT_ALLELES = 2
+    NT_NR_ALLELES = 3
+    NT_GENOTYPES = 4
+    NT_PHASED_GENOTYPES = 5
+
+    _errors = { 0:"UNKNOWN_FORMAT_STRING:Unknown file format identifier",
+                1:"BADLY_FORMATTED_FORMAT_STRING:Formatting error in the format string",
+                2:"BADLY_FORMATTED_HEADING:Did not find 9 required headings (CHROM, POS, ..., FORMAT) %s",
+                3:"BAD_NUMBER_OF_COLUMNS:Wrong number of columns found (%s)",
+                4:"POS_NOT_NUMERICAL:Position column is not numerical",
+                5:"UNKNOWN_CHAR_IN_REF:Unknown character in reference field",
+                6:"V33_BAD_REF:Reference should be single-character in v3.3 VCF",
+                7:"V33_BAD_ALLELE:Cannot interpret allele for v3.3 VCF",
+                8:"POS_NOT_POSITIVE:Position field must be >0",
+                9:"QUAL_NOT_NUMERICAL:Quality field must be numerical, or '.'",
+               10:"ERROR_INFO_STRING:Error while parsing info field",
+               11:"ERROR_UNKNOWN_KEY:Unknown key (%s) found in formatted field (info; format; or filter)",
+               12:"ERROR_FORMAT_NOT_NUMERICAL:Expected integer or float in formatted field; got %s",
+               13:"ERROR_FORMAT_NOT_CHAR:Eexpected character in formatted field; got string",
+               14:"FILTER_NOT_DEFINED:Identifier (%s) in filter found which was not defined in header",
+               15:"FORMAT_NOT_DEFINED:Identifier (%s) in format found which was not defined in header",
+               16:"BAD_NUMBER_OF_VALUES:Found too many of values in sample column (%s)",
+               17:"BAD_NUMBER_OF_PARAMETERS:Found unexpected number of parameters (%s)",
+               18:"BAD_GENOTYPE:Cannot parse genotype (%s)",
+               19:"V40_BAD_ALLELE:Bad allele found for v4.0 VCF (%s)",
+               20:"MISSING_REF:Reference allele missing",
+               21:"V33_UNMATCHED_DELETION:Deleted sequence does not match reference (%s)",
+               22:"V40_MISSING_ANGLE_BRACKETS:Format definition is not deliminted by angular brackets",
+               23:"FORMAT_MISSING_QUOTES:Description field in format definition is not surrounded by quotes",
+               24:"V40_FORMAT_MUST_HAVE_NAMED_FIELDS:Fields in v4.0 VCF format definition must have named fields",
+               25:"HEADING_NOT_SEPARATED_BY_TABS:Heading line appears separated by spaces, not tabs",
+               26:"WRONG_REF:Wrong reference %s",
+               27:"ERROR_TRAILING_DATA:Numerical field ('%s') has semicolon-separated trailing data",
+               28:"BAD_CHR_TAG:Error calculating chr tag for %s",
+               29:"ZERO_LENGTH_ALLELE:Found zero-length allele",
+               30:"MISSING_INDEL_ALLELE_REF_BASE:Indel alleles must begin with single reference base"
+                }
+
+    # tag-value pairs; tags are not unique; does not include fileformat, INFO, FILTER or FORMAT fields
+    _header = []
+
+    # version number; 33=v3.3; 40=v4.0
+    _version = 40
+
+    # info, filter and format data
+    _info = {}
+    _filter = {}
+    _format = {}
+
+    # header; and required columns
+    _required = ["CHROM","POS","ID","REF","ALT","QUAL","FILTER","INFO","FORMAT"]
+    _samples = []
+
+    # control behaviour
+    _ignored_errors = set([11])   # ERROR_UNKNOWN_KEY
+    _warn_errors = set([])
+    _leftalign = False
+
+    # reference sequence
+    _reference = None
+
+    # regions to include; None includes everything
+    _regions = None
+
+    # statefull stuff
+    _lineno = -1
+    _line = None
+    _lines = None
+
+    def __init__(self, _copy=None, reference=None, regions=None, lines=None, leftalign=False):
+        # make error identifiers accessible by name
+        for id in self._errors.keys(): self.__dict__[self._errors[id].split(':')[0]] = id
+        if _copy != None:
+            self._leftalign = _copy._leftalign
+            self._header = _copy._header[:]
+            self._version = _copy._version
+            self._info = copy.deepcopy(_copy._info)
+            self._filter = copy.deepcopy(_copy._filter)
+            self._format = copy.deepcopy(_copy._format)
+            self._samples = _copy._samples[:]
+            self._sample2column = copy.deepcopy(_copy._sample2column)
+            self._ignored_errors = copy.deepcopy(_copy._ignored_errors)
+            self._warn_errors = copy.deepcopy(_copy._warn_errors)
+            self._reference = _copy._reference
+            self._regions = _copy._regions
+        if reference: self._reference = reference
+        if regions: self._regions = regions
+        if leftalign: self._leftalign = leftalign
+        self._lines = lines
+
+    def error(self,line,error,opt=None):
+        if error in self._ignored_errors: return
+        errorlabel, errorstring = self._errors[error].split(':')
+        if opt: errorstring = errorstring % opt
+        errwarn = ["Error","Warning"][error in self._warn_errors]
+        sys.stderr.write("Line %s: '%s'\n%s %s: %s\n" % (self._lineno,line,errwarn,errorlabel,errorstring))
+        if error in self._warn_errors: return
+        raise ValueError(errorstring)
+
+    def parse_format(self,line,format,filter=False):
+        if self._version == 40:
+            if not format.startswith('<'): 
+                self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+                format = "<"+format
+            if not format.endswith('>'): 
+                self.error(line,self.V40_MISSING_ANGLE_BRACKETS)
+                format += ">"
+            format = format[1:-1]
+        data = {'id':None,'number':None,'type':None,'descr':None}
+        idx = 0
+        while len(format.strip())>0:
+            elts = format.strip().split(',')
+            first, rest = elts[0], ','.join(elts[1:])
+            if first.find('=') == -1 or (first.find('"')>=0 and first.find('=') > first.find('"')):
+                if self._version == 40: self.error(line,self.V40_FORMAT_MUST_HAVE_NAMED_FIELDS)
+                if idx == 4: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+                first = ["ID=","Number=","Type=","Description="][idx] + first
+            if first.startswith('ID='):            data['id'] = first.split('=')[1]
+            elif first.startswith('Number='):      data['number'] = first.split('=')[1]
+            elif first.startswith('Type='):        data['type'] = first.split('=')[1]
+            elif first.startswith('Description='):
+                elts = format.split('"')
+                if len(elts)<3: 
+                    self.error(line,self.FORMAT_MISSING_QUOTES)
+                    elts = first.split('=') + [rest] 
+                data['descr'] = elts[1]
+                rest = '"'.join(elts[2:])
+                if rest.startswith(','): rest = rest[1:]
+            else:
+                self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+            format = rest
+            idx += 1
+            if filter and idx==1: idx=3  # skip number and type fields for FILTER format strings
+        if not data['id']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        if not data['descr']: 
+            self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+            data['descr'] = '<none>'
+        if not data['type'] and not data['number']:
+            # fine, ##filter format
+            return FORMAT(data['id'],self.NT_NUMBER,0,"Flag",data['descr'],'.')
+        if not data['type'] in ["Integer","Float","Character","String","Flag"]:
+            self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        # I would like a missing-value field, but it isn't there
+        if data['type'] in ['Integer','Float']: data['missing'] = None    # Do NOT use arbitrary int/float as missing value
+        else:                                   data['missing'] = '.'
+        if not data['number']: self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        try:
+            n = int(data['number'])
+            t = self.NT_NUMBER
+        except ValueError:
+            n = -1
+            if data['number'] == '.':                   t = self.NT_UNKNOWN
+            elif data['number'] == '#alleles':          t = self.NT_ALLELES
+            elif data['number'] == '#nonref_alleles':   t = self.NT_NR_ALLELES
+            elif data['number'] == '#genotypes':        t = self.NT_GENOTYPES
+            elif data['number'] == '#phased_genotypes': t = self.NT_PHASED_GENOTYPES
+            else:
+                self.error(line,self.BADLY_FORMATTED_FORMAT_STRING)
+        return FORMAT(data['id'],t,n,data['type'],data['descr'],data['missing'])
+    
+
+    def format_format( self, fmt, filter=False ):
+        values = [('ID',fmt.id)]
+        if fmt.number != None and not filter:
+            if fmt.numbertype == self.NT_UNKNOWN: nmb = "."
+            elif fmt.numbertype == self.NT_NUMBER: nmb = str(fmt.number)
+            elif fmt.numbertype == self.NT_ALLELES: nmb = "#alleles"
+            elif fmt.numbertype == self.NT_NR_ALLELES: nmb = "#nonref_alleles"
+            elif fmt.numbertype == self.NT_GENOTYPES: nmb = "#genotypes"
+            elif fmt.numbertype == self.NT_PHASED_GENOTYPES: nmb = "#phased_genotypes"
+            else:
+                raise ValueError("Unknown number type encountered: %s" % fmt.numbertype)
+            values.append( ('Number',nmb) )
+            values.append( ('Type', fmt.type) )
+        values.append( ('Description', '"' + fmt.description + '"') )
+        if self._version == 33:
+            format = ",".join([v for k,v in values])
+        else:
+            format = "<" + (",".join( ["%s=%s" % (k,v) for (k,v) in values] )) + ">"
+        return format
+
+    def get_expected(self, format, formatdict, alt):
+        fmt = formatdict[format]
+        if fmt.numbertype == self.NT_UNKNOWN: return -1
+        if fmt.numbertype == self.NT_NUMBER: return fmt.number
+        if fmt.numbertype == self.NT_ALLELES: return len(alt)+1
+        if fmt.numbertype == self.NT_NR_ALLELES: return len(alt)
+        if fmt.numbertype == self.NT_GENOTYPES: return ((len(alt)+1)*(len(alt)+2)) // 2
+        if fmt.numbertype == self.NT_PHASED_GENOTYPES: return (len(alt)+1)*(len(alt)+1)
+        return 0
+
+
+    def _add_definition(self, formatdict, key, data, line ):
+        if key in formatdict: return
+        self.error(line,self.ERROR_UNKNOWN_KEY,key)
+        if data == None:
+            formatdict[key] = FORMAT(key,self.NT_NUMBER,0,"Flag","(Undefined tag)",".")
+            return
+        if data == []: data = [""]             # unsure what type -- say string
+        if type(data[0]) == type(0.0):
+            formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Float","(Undefined tag)",None)
+            return
+        if type(data[0]) == type(0):
+            formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"Integer","(Undefined tag)",None)
+            return
+        formatdict[key] = FORMAT(key,self.NT_UNKNOWN,-1,"String","(Undefined tag)",".")
+
+
+    # todo: trim trailing missing values
+    def format_formatdata( self, data, format, key=True, value=True, separator=":" ):
+        output, sdata = [], []
+        if type(data) == type([]): # for FORMAT field, make data with dummy values
+            d = {}
+            for k in data: d[k] = []
+            data = d
+        # convert missing values; and silently add definitions if required
+        for k in data:
+            self._add_definition( format, k, data[k], "(output)" )
+            for idx,v in enumerate(data[k]):
+                if v == format[k].missingvalue: data[k][idx] = "."
+        # make sure GT comes first; and ensure fixed ordering; also convert GT data back to string
+        for k in data: 
+            if k != 'GT': sdata.append( (k,data[k]) )
+        sdata.sort()
+        if 'GT' in data:
+            sdata = [('GT',map(self.convertGTback,data['GT']))] + sdata
+        for k,v in sdata:
+            if v == []: v = None
+            if key and value:
+                if v != None: output.append( k+"="+','.join(map(str,v)) )
+                else: output.append( k )
+            elif key: output.append(k)
+            elif value:
+                if v != None: output.append( ','.join(map(str,v)) )
+                else: output.append( "." )                    # should not happen
+        # snip off trailing missing data
+        while len(output) > 1:
+            last = output[-1].replace(',','').replace('.','')
+            if len(last)>0: break
+            output = output[:-1]
+        return separator.join(output)
+
+
+    def enter_default_format(self):
+        for f in [FORMAT('GT',self.NT_NUMBER,1,'String','Genotype','.'),
+                  FORMAT('GQ',self.NT_NUMBER,1,'Integer','Genotype Quality',-1),
+                  FORMAT('DP',self.NT_NUMBER,1,'Integer','Read depth at this position for this sample',-1),
+                  FORMAT('HQ',self.NT_UNKNOWN,-1,'Integer','Haplotype Quality',-1),    # unknown number, since may be haploid
+                  FORMAT('FT',self.NT_NUMBER,1,'String','Sample Genotype Filter','.')]:
+            if f.id not in self._format:
+                self._format[f.id] = f
+
+    def parse_header( self, line ):
+        assert line.startswith('##')
+        elts = line[2:].split('=')
+        key = elts[0].strip()
+        value = '='.join(elts[1:]).strip()
+        if key == "fileformat":
+            if value == "VCFv3.3":
+                self._version = 33
+            elif value == "VCFv4.0":
+                self._version = 40
+            elif value == "VCFv4.1":
+                # AH - for testing
+                self._version = 40
+            else:
+                self.error(line,self.UNKNOWN_FORMAT_STRING)
+        elif key == "INFO":
+            f = self.parse_format(line, value)
+            self._info[ f.id ] = f
+        elif key == "FILTER":
+            f = self.parse_format(line, value, filter=True)
+            self._filter[ f.id ] = f
+        elif key == "FORMAT":
+            f = self.parse_format(line, value)
+            self._format[ f.id ] = f
+        else:
+            # keep other keys in the header field
+            self._header.append( (key,value) )
+
+
+    def write_header( self, stream ):
+        stream.write("##fileformat=VCFv%s.%s\n" % (self._version // 10, self._version % 10))
+        for key,value in self._header: stream.write("##%s=%s\n" % (key,value))
+        for var,label in [(self._info,"INFO"),(self._filter,"FILTER"),(self._format,"FORMAT")]:
+            for f in var.itervalues(): stream.write("##%s=%s\n" % (label,self.format_format(f,filter=(label=="FILTER"))))
+        
+
+    def parse_heading( self, line ):
+        assert line.startswith('#')
+        assert not line.startswith('##')
+        headings = line[1:].split('\t')
+        if len(headings)==1 and len(line[1:].split()) >= 9:
+            self.error(line,self.HEADING_NOT_SEPARATED_BY_TABS)
+            headings = line[1:].split()
+
+        for i,s in enumerate(self._required):
+
+            if len(headings)<=i or headings[i] != s:
+
+                if len(headings) <= i: 
+                    err = "(%sth entry not found)" % (i+1)
+                else:
+                    err = "(found %s, expected %s)" % (headings[i],s)
+
+                #self.error(line,self.BADLY_FORMATTED_HEADING,err)
+
+                # allow FORMAT column to be absent
+                if len(headings) == 8:
+                    headings.append("FORMAT")
+                else:
+                    self.error(line,self.BADLY_FORMATTED_HEADING,err)
+
+        self._samples = headings[9:]
+        self._sample2column = dict( [(y,x+9) for x,y in enumerate( self._samples ) ] )
+                           
+    def write_heading( self, stream ):
+        stream.write("#" + "\t".join(self._required + self._samples) + "\n")
+
+    def convertGT(self, GTstring):
+        if GTstring == ".": return ["."]
+        try:
+            gts = gtsRegEx.split(GTstring)
+            if len(gts) == 1: return [int(gts[0])]
+            if len(gts) != 2: raise ValueError()
+            if gts[0] == "." and gts[1] == ".": return [gts[0],GTstring[len(gts[0]):-len(gts[1])],gts[1]]
+            return [int(gts[0]),GTstring[len(gts[0]):-len(gts[1])],int(gts[1])]
+        except ValueError:
+            self.error(self._line,self.BAD_GENOTYPE,GTstring)
+            return [".","|","."]
+
+
+    def convertGTback(self, GTdata):
+        return ''.join(map(str,GTdata))
+
+    def parse_formatdata( self, key, value, formatdict, line ):
+        # To do: check that the right number of values is present
+        f = formatdict.get(key,None)
+        if f == None:
+            self._add_definition(formatdict, key, value, line )
+            f = formatdict[key]
+        if f.type == "Flag":
+            if value is not None: self.error(line,self.ERROR_FLAG_HAS_VALUE)
+            return []
+        values = value.split(',')
+        # deal with trailing data in some early VCF files
+        if f.type in ["Float","Integer"] and len(values)>0 and values[-1].find(';') > -1:
+            self.error(line,self.ERROR_TRAILING_DATA,values[-1])
+            values[-1] = values[-1].split(';')[0]
+        if f.type == "Integer": 
+            for idx,v in enumerate(values):
+                try:
+                    if v == ".": values[idx] = f.missingvalue
+                    else:        values[idx] = int(v)
+                except: 
+                    self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+                    return [0] * len(values)
+            return values
+        elif f.type == "String":
+            self._line = line
+            if f.id == "GT": values = map( self.convertGT, values )
+            return values
+        elif f.type == "Character":
+            for v in values: 
+                if len(v) != 1: self.error(line,self.ERROR_FORMAT_NOT_CHAR)
+            return values
+        elif f.type == "Float":
+            for idx,v in enumerate(values):
+                if v == ".": values[idx] = f.missingvalue
+            try: return map(float,values)
+            except:
+                self.error(line,self.ERROR_FORMAT_NOT_NUMERICAL,values)
+                return [0.0] * len(values)
+        else:
+            # can't happen
+            self.error(line,self.ERROR_INFO_STRING)
+
+
+    def inregion(self, chrom, pos):
+        if not self._regions: return True
+        for r in self._regions:
+            if r[0] == chrom and r[1] <= pos < r[2]: return True
+        return False
+        
+
+    def parse_data( self, line, lineparse=False ):
+        cols = line.split('\t')
+        if len(cols) != len(self._samples)+9:
+            # gracefully deal with absent FORMAT column
+            if len(cols) == 8 and len(self._samples)==0:
+                cols.append("")
+            else:
+                self.error(line,
+                           self.BAD_NUMBER_OF_COLUMNS, 
+                           "expected %s for %s samples (%s), got %s" % (len(self._samples)+9, len(self._samples), self._samples, len(cols)))
+
+        chrom = cols[0]
+
+        # get 0-based position
+        try:    pos = int(cols[1])-1
+        except: self.error(line,self.POS_NOT_NUMERICAL)
+        if pos < 0: self.error(line,self.POS_NOT_POSITIVE)
+
+        # implement filtering
+        if not self.inregion(chrom,pos): return None
+
+        # end of first-pass parse for sortedVCF
+        if lineparse: return chrom, pos, line
+        
+        id = cols[2]
+
+        ref = cols[3].upper()
+        if ref == ".":
+            self.error(line,self.MISSING_REF)
+            if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+            else:                   ref = ""
+        else:
+            for c in ref:
+                if c not in "ACGTN": self.error(line,self.UNKNOWN_CHAR_IN_REF)
+            if "N" in ref: ref = get_sequence(chrom,pos,pos+len(ref),self._reference)
+
+        # make sure reference is sane
+        if self._reference:
+            left = max(0,pos-100)
+            faref_leftflank = get_sequence(chrom,left,pos+len(ref),self._reference)
+            faref = faref_leftflank[pos-left:]
+            if faref != ref: self.error(line,self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+            ref = faref
+
+        # convert v3.3 to v4.0 alleles below
+        if cols[4] == ".": alt = []
+        else: alt = cols[4].upper().split(',')
+
+        if cols[5] == ".": qual = -1
+        else: 
+            try:    qual = float(cols[5])
+            except: self.error(line,self.QUAL_NOT_NUMERICAL)
+
+        # postpone checking that filters exist.  Encode missing filter or no filtering as empty list
+        if cols[6] == "." or cols[6] == "PASS" or cols[6] == "0": filter = []
+        else: filter = cols[6].split(';')
+
+        # dictionary of keys, and list of values
+        info = {}
+        if cols[7] != ".":
+            for blurp in cols[7].split(';'):
+                elts = blurp.split('=')
+                if len(elts) == 1: v = None
+                elif len(elts) == 2: v = elts[1]
+                else: self.error(line,self.ERROR_INFO_STRING)
+                info[elts[0]] = self.parse_formatdata(elts[0], v, self._info, line)
+
+        # Gracefully deal with absent FORMAT column
+        if cols[8] == "": format = []
+        else: format = cols[8].split(':')
+
+        # check: all filters are defined
+        for f in filter:
+            if f not in self._filter: self.error(line,self.FILTER_NOT_DEFINED, f)
+            
+        # check: format fields are defined
+        for f in format:
+            if f not in self._format: self.error(line,self.FORMAT_NOT_DEFINED, f)
+
+        # convert v3.3 alleles
+        if self._version == 33:
+            if len(ref) != 1: self.error(line,self.V33_BAD_REF)
+            newalts = []
+            have_deletions = False
+            for a in alt:
+                if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+                elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+                elif a.startswith('D'): # allow D<seq> and D<num>
+                    have_deletions = True
+                    try:
+                        l = int(a[1:])          # throws ValueError if sequence
+                        if len(ref) < l:        # add to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[l:]             # new deletion, deleting pos...pos+l
+                    except ValueError:
+                        s = a[1:]
+                        if len(ref) < len(s):   # add Ns to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+                            if not s.endswith(addns) and addns != 'N'*len(addns):
+                                self.error(line,self.V33_UNMATCHED_DELETION,
+                                           "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[len(s):]        # new deletion, deleting from pos
+                else:
+                    self.error(line,self.V33_BAD_ALLELE)
+                newalts.append(a)
+            alt = newalts
+            # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+            if have_deletions:
+                if pos == 0:
+                    # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+                    addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+                    ref += addn
+                    alt = [allele+addn for allele in alt]
+                else:
+                    addn = get_sequence(chrom,pos-1,pos,self._reference)
+                    ref = addn + ref
+                    alt = [addn + allele for allele in alt]
+                    pos -= 1
+        else:
+            # format v4.0 -- just check for nucleotides
+            for allele in alt:
+                if not alleleRegEx.match(allele):
+                    self.error(line,self.V40_BAD_ALLELE,allele)
+
+        # check for leading nucleotide in indel calls
+        for allele in alt:
+            if len(allele) != len(ref):
+                if len(allele) == 0: self.error(line,self.ZERO_LENGTH_ALLELE)
+                if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+                    self.error(line,self.MISSING_INDEL_ALLELE_REF_BASE)
+
+        # trim trailing bases in alleles
+        for i in range(1,min(len(ref),min(map(len,alt)))):
+            if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+                break
+            ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+
+        # left-align alleles, if a reference is available
+        if self._leftalign and self._reference:
+            while left < pos:
+                movable = True
+                for allele in alt:
+                    if len(allele) > len(ref):
+                        longest, shortest = allele, ref
+                    else:
+                        longest, shortest = ref, allele
+                    if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+                        movable = False
+                    if longest[-1].upper() != longest[len(shortest)-1].upper():
+                        movable = False
+                if not movable:
+                    break
+                ref = ref[:-1]
+                alt = [allele[:-1] for allele in alt]
+                if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+                    ref = faref_leftflank[pos-left-1] + ref
+                    alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+                    pos -= 1
+
+        # parse sample columns
+        samples = []
+        for sample in cols[9:]:
+            dict = {}
+            values = sample.split(':')
+            if len(values) > len(format):
+                self.error(line,self.BAD_NUMBER_OF_VALUES,"(found %s values in element %s; expected %s)" % (len(values),sample,len(format)))
+            for idx in range(len(format)):
+                expected = self.get_expected(format[idx], self._format, alt)
+                if idx < len(values): value = values[idx]
+                else:
+                    if expected == -1: value = "."
+                    else: value = ",".join(["."]*expected)
+                dict[format[idx]] = self.parse_formatdata(format[idx], value, self._format, line)
+                if expected != -1 and len(dict[format[idx]]) != expected:
+                    self.error(line,self.BAD_NUMBER_OF_PARAMETERS,
+                               "id=%s, expected %s parameters, got %s" % (format[idx],expected,dict[format[idx]]))
+                    if len(dict[format[idx]] ) < expected: dict[format[idx]] += [dict[format[idx]][-1]]*(expected-len(dict[format[idx]]))
+                    dict[format[idx]] = dict[format[idx]][:expected]
+            samples.append( dict )
+
+        # done
+        d = {'chrom':chrom,
+             'pos':pos,      # return 0-based position
+             'id':id,
+             'ref':ref,
+             'alt':alt,
+             'qual':qual,
+             'filter':filter,
+             'info':info,
+             'format':format}
+        for key,value in zip(self._samples,samples):
+            d[key] = value
+        
+        return d
+
+
+    def write_data(self, stream, data):
+        required = ['chrom','pos','id','ref','alt','qual','filter','info','format'] + self._samples
+        for k in required:
+            if k not in data: raise ValueError("Required key %s not found in data" % str(k))
+        if data['alt'] == []: alt = "."
+        else: alt = ",".join(data['alt'])
+        if data['filter'] == None: filter = "."
+        elif data['filter'] == []: 
+            if self._version == 33: filter = "0"
+            else: filter = "PASS"
+        else: filter = ';'.join(data['filter'])
+        if data['qual'] == -1: qual = "."
+        else: qual = str(data['qual'])
+
+        output = [data['chrom'], 
+                  str(data['pos']+1),   # change to 1-based position
+                  data['id'],
+                  data['ref'],
+                  alt,
+                  qual,
+                  filter,
+                  self.format_formatdata( data['info'], self._info, separator=";" ),
+                  self.format_formatdata( data['format'], self._format, value=False ) ]
+        
+        for s in self._samples:
+            output.append( self.format_formatdata( data[s], self._format, key=False ) )
+        
+        stream.write( "\t".join(output) + "\n" )
+
+    def _parse_header(self, stream):
+        self._lineno = 0
+        for line in stream:
+            self._lineno += 1
+            if line.startswith('##'):
+                self.parse_header( line.strip() )
+            elif line.startswith('#'):
+                self.parse_heading( line.strip() )
+                self.enter_default_format()
+            else:
+                break
+        return line
+
+    def _parse(self, line, stream):
+        if len(line.strip()) > 0:
+            d = self.parse_data( line.strip() )
+            #if d: yield d
+        for line in stream:
+            self._lineno += 1
+            if self._lines and self._lineno > self._lines: raise StopIteration
+            d = self.parse_data( line.strip() )
+            #if d: yield d
+
+    ######################################################################################################
+    #
+    # API follows
+    #
+    ######################################################################################################
+
+    def getsamples(self):
+        """ List of samples in VCF file """
+        return self._samples
+
+    def setsamples(self,samples):
+        """ List of samples in VCF file """
+        self._samples = samples
+
+    def getheader(self):
+        """ List of header key-value pairs (strings) """
+        return self._header
+
+    def setheader(self,header):
+        """ List of header key-value pairs (strings) """
+        self._header = header
+
+    def getinfo(self):
+        """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+        return self._info
+
+    def setinfo(self,info):
+        """ Dictionary of ##INFO tags, as VCF.FORMAT values """
+        self._info = info
+
+    def getformat(self):
+        """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+        return self._format
+
+    def setformat(self,format):
+        """ Dictionary of ##FORMAT tags, as VCF.FORMAT values """
+        self._format = format
+
+    def getfilter(self):
+        """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+        return self._filter
+
+    def setfilter(self,filter):
+        """ Dictionary of ##FILTER tags, as VCF.FORMAT values """
+        self._filter = filter
+
+    def setversion(self, version):
+        if version != 33 and version != 40: raise ValueError("Can only handle v3.3 and v4.0 VCF files")
+        self._version = version
+
+    def setregions(self, regions):
+        self._regions = regions
+
+    def setreference(self, ref):
+        """ Provide a reference sequence; a Python class supporting a fetch(chromosome, start, end) method, e.g. PySam.FastaFile """
+        self._reference = ref
+
+    def ignoreerror(self, errorstring):
+        try:             self._ignored_errors.add(self.__dict__[errorstring])
+        except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+
+    def warnerror(self, errorstring):
+        try:             self._warn_errors.add(self.__dict__[errorstring])
+        except KeyError: raise ValueError("Invalid error string: %s" % errorstring)
+
+    def parse(self, stream):
+        """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+        last_line = self._parse_header(stream)
+        # now return a generator that does the actual work.  In this way the pre-processing is done
+        # before the first piece of data is yielded
+        return self._parse(last_line, stream)
+
+    def write(self, stream, datagenerator):
+        """ Writes a VCF file to a stream, using a data generator (or list) """
+        self.write_header(stream)
+        self.write_heading(stream)
+        for data in datagenerator: self.write_data(stream,data)
+
+    def writeheader(self, stream):
+        """ Writes a VCF header """
+        self.write_header(stream)
+        self.write_heading(stream)
+
+    def compare_calls(self, pos1, ref1, alt1, pos2, ref2, alt2):
+        """ Utility function: compares two calls for equality """
+        # a variant should always be assigned to a unique position, one base before
+        # the leftmost position of the alignment gap.  If this rule is implemented
+        # correctly, the two positions must be equal for the calls to be identical.
+        if pos1 != pos2: return False
+        # from both calls, trim rightmost bases when identical.  Do this safely, i.e.
+        # only when the reference bases are not Ns
+        while len(ref1)>0 and len(alt1)>0 and ref1[-1] == alt1[-1]:
+            ref1 = ref1[:-1]
+            alt1 = alt1[:-1]
+        while len(ref2)>0 and len(alt2)>0 and ref2[-1] == alt2[-1]:
+            ref2 = ref2[:-1]
+            alt2 = alt2[:-1]
+        # now, the alternative alleles must be identical
+        return alt1 == alt2
+
+###########################################################################################################
+###########################################################################################################
+## API functions added by Andreas
+###########################################################################################################
+
+    def connect( self, filename ):
+        '''connect to tabix file.'''
+        self.tabixfile = pysam.Tabixfile( filename )
+        self._parse_header(self.tabixfile.header)
+        
+    def fetch(self,
+              reference = None,
+              start = None, 
+              end = None, 
+              region = None ):
+        """ Parse a stream of VCF-formatted lines.  Initializes class instance and return generator """
+
+        return self.tabixfile.fetch( reference, start, end, region, parser = asVCFRecord( self ) )
+
+    def validate( self, record ):
+        '''validate vcf record.
+
+        returns a validated record.
+        '''
+        
+        raise NotImplementedError( "needs to be checked" )
+
+        chrom, pos = record.chrom, record.pos
+
+        # check reference
+        ref = record.ref
+        if ref == ".":
+            self.error(str(record),self.MISSING_REF)
+            if self._version == 33: ref = get_sequence(chrom,pos,pos+1,self._reference)
+            else:                   ref = ""
+        else:
+            for c in ref:
+                if c not in "ACGTN": self.error(str(record),self.UNKNOWN_CHAR_IN_REF)
+                if "N" in ref: ref = get_sequence(chrom,
+                                                  pos,
+                                                  pos+len(ref),
+                                                  self._reference)
+
+        # make sure reference is sane
+        if self._reference:
+            left = max(0,self.pos-100)
+            faref_leftflank = get_sequence(chrom,left,self.pos+len(ref),self._reference)
+            faref = faref_leftflank[pos-left:]
+            if faref != ref: self.error(str(record),self.WRONG_REF,"(reference is %s, VCF says %s)" % (faref,ref))
+            ref = faref
+            
+        # check: format fields are defined
+        for f in record.format:
+            if f not in self._format: self.error(str(record),self.FORMAT_NOT_DEFINED, f)
+            
+        # check: all filters are defined
+        for f in record.filter:
+            if f not in self._filter: self.error(str(record),self.FILTER_NOT_DEFINED, f)
+
+        # convert v3.3 alleles
+        if self._version == 33:
+            if len(ref) != 1: self.error(str(record),self.V33_BAD_REF)
+            newalts = []
+            have_deletions = False
+            for a in alt:
+                if len(a) == 1: a = a + ref[1:]                       # SNP; add trailing reference
+                elif a.startswith('I'): a = ref[0] + a[1:] + ref[1:]  # insertion just beyond pos; add first and trailing reference
+                elif a.startswith('D'): # allow D<seq> and D<num>
+                    have_deletions = True
+                    try:
+                        l = int(a[1:])          # throws ValueError if sequence
+                        if len(ref) < l:        # add to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+l,self._reference)
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[l:]             # new deletion, deleting pos...pos+l
+                    except ValueError:
+                        s = a[1:]
+                        if len(ref) < len(s):   # add Ns to reference if necessary
+                            addns = get_sequence(chrom,pos+len(ref),pos+len(s),self._reference)
+                            if not s.endswith(addns) and addns != 'N'*len(addns):
+                                self.error(str(record),self.V33_UNMATCHED_DELETION,
+                                           "(deletion is %s, reference is %s)" % (a,get_sequence(chrom,pos,pos+len(s),self._reference)))
+                            ref += addns
+                            for i,na in enumerate(newalts): newalts[i] = na+addns
+                        a = ref[len(s):]        # new deletion, deleting from pos
+                else:
+                    self.error(str(record),self.V33_BAD_ALLELE)
+                newalts.append(a)
+            alt = newalts
+            # deletion alleles exist, add dummy 1st reference allele, and account for leading base
+            if have_deletions:
+                if pos == 0:
+                    # Petr Danacek's: we can't have a leading nucleotide at (1-based) position 1
+                    addn = get_sequence(chrom,pos+len(ref),pos+len(ref)+1,self._reference)
+                    ref += addn
+                    alt = [allele+addn for allele in alt]
+                else:
+                    addn = get_sequence(chrom,pos-1,pos,self._reference)
+                    ref = addn + ref
+                    alt = [addn + allele for allele in alt]
+                    pos -= 1
+        else:
+            # format v4.0 -- just check for nucleotides
+            for allele in alt:
+                if not alleleRegEx.match(allele):
+                    self.error(str(record),self.V40_BAD_ALLELE,allele)
+                    
+
+        # check for leading nucleotide in indel calls
+        for allele in alt:
+            if len(allele) != len(ref):
+                if len(allele) == 0: self.error(str(record),self.ZERO_LENGTH_ALLELE)
+                if ref[0].upper() != allele[0].upper() and "N" not in (ref[0]+allele[0]).upper():
+                    self.error(str(record),self.MISSING_INDEL_ALLELE_REF_BASE)
+
+        # trim trailing bases in alleles
+        for i in range(1,min(len(ref),min(map(len,alt)))):
+            if len(set(allele[-1].upper() for allele in alt)) > 1 or ref[-1].upper() != alt[0][-1].upper():
+                break
+            ref, alt = ref[:-1], [allele[:-1] for allele in alt]
+
+        # left-align alleles, if a reference is available
+        if self._leftalign and self._reference:
+            while left < pos:
+                movable = True
+                for allele in alt:
+                    if len(allele) > len(ref):
+                        longest, shortest = allele, ref
+                    else:
+                        longest, shortest = ref, allele
+                    if len(longest) == len(shortest) or longest[:len(shortest)].upper() != shortest.upper():
+                        movable = False
+                    if longest[-1].upper() != longest[len(shortest)-1].upper():
+                        movable = False
+                if not movable:
+                    break
+                ref = ref[:-1]
+                alt = [allele[:-1] for allele in alt]
+                if min([len(allele) for allele in alt]) == 0 or len(ref) == 0:
+                    ref = faref_leftflank[pos-left-1] + ref
+                    alt = [faref_leftflank[pos-left-1] + allele for allele in alt]
+                    pos -= 1
+
+__all__ = [
+    "VCF", "VCFRecord", ]
+
+
index 6b554d09e7e5b47a623d25323da97a43fa07f05d..c9d4543eea72bd3aa193dfff3c7c0f9f5edfac91 100644 (file)
@@ -8,6 +8,10 @@
 #include "pysam_util.h"
 #include "errmod.h" // for pysam_dump 
 
+#ifndef inline
+#define inline __inline
+#endif
+
 // Definition of pysamerr
 #include "stdio.h"
 FILE * pysamerr = NULL;
@@ -191,6 +195,7 @@ uint32_t pysam_glf_depth( glf1_t * g )
 
 void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
 {
+  int x = 0;
   fprintf(stderr,
          "glf: ref_base=%i, max_mapQ=%i, min_lk=%i, depth=%i",
          g->ref_base,
@@ -198,7 +203,6 @@ void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
          g->min_lk,
          g->depth );
 
-  int x = 0;
   for (x = 0; x < 10; ++x) 
     fprintf(stderr, ", lk%x=%i, ", x, g->lk[x]);
 
@@ -249,7 +253,7 @@ extern int bam_fillmd(int argc, char *argv[]);
 
 int pysam_dispatch(int argc, char *argv[] )
 {
-
+  extern int optind;
 #ifdef _WIN32
   setmode(fileno(stdout), O_BINARY);
   setmode(fileno(stdin),  O_BINARY);
@@ -257,8 +261,6 @@ int pysam_dispatch(int argc, char *argv[] )
   knet_win32_init();
 #endif
 #endif
-
-  extern int optind;
   
   // reset getop
   optind = 1;
@@ -312,12 +314,14 @@ bam1_t * pysam_bam_update( bam1_t * b,
                           uint8_t * pos )
 {
   int d = nbytes_new-nbytes_old;
+  int new_size;
+  size_t offset;
 
   // no change
   if (d == 0) return b;
 
-  int new_size = d + b->data_len;
-  size_t offset = pos - b->data;
+  new_size = d + b->data_len;
+  offset = pos - b->data;
 
   //printf("d=%i, old=%i, new=%i, old_size=%i, new_size=%i\n",
   // d, nbytes_old, nbytes_new, b->data_len, new_size);
index 4116fe65d225751b25ce7d22418e9efbb682b736..34937f454fc74fddbb2e45de4b851ebac731a3d1 100644 (file)
@@ -1,7 +1,7 @@
 # pysam versioning information
 
-__version__ = "0.4.1"
+__version__ = "0.5"
 
-__samtools_version__ = "0.1.12a"
+__samtools_version__ = "0.1.16"
 
-__tabix_version__ = "0.2.3"
+__tabix_version__ = "0.2.5"
index c20597721596c67d49c12141d691b77fc7d11446..28cdbd74b0d751246c6726f5f88a1499eb87a30f 100644 (file)
@@ -9,7 +9,7 @@
 #include "kstring.h"
 #include "sam_header.h"
 
-int bam_is_be = 0;
+int bam_is_be = 0, bam_verbose = 2;
 char *bam_flag2char_table = "pPuUrR12sfd\0\0\0\0\0";
 
 /**************************
@@ -81,7 +81,7 @@ bam_header_t *bam_header_read(bamFile fp)
                // with ESPIPE.  Suppress the error message in this case.
                if (errno != ESPIPE) perror("[bam_header_read] bgzf_check_EOF");
        }
-       else if (i == 0) fprintf(pysamerr, "[bam_header_read] EOF marker is absent.\n");
+       else if (i == 0) fprintf(pysamerr, "[bam_header_read] EOF marker is absent. The input is probably truncated.\n");
        // read "BAM1"
        magic_len = bam_read(fp, buf, 4);
        if (magic_len != 4 || strncmp(buf, "BAM\001", 4) != 0) {
@@ -162,6 +162,19 @@ static void swap_endian_data(const bam1_core_t *c, int data_len, uint8_t *data)
                else if (type == 'I' || type == 'F') { bam_swap_endian_4p(s); s += 4; }
                else if (type == 'D') { bam_swap_endian_8p(s); s += 8; }
                else if (type == 'Z' || type == 'H') { while (*s) ++s; ++s; }
+               else if (type == 'B') {
+                       int32_t n, Bsize = bam_aux_type2size(*s);
+                       memcpy(&n, s + 1, 4);
+                       if (1 == Bsize) {
+                       } else if (2 == Bsize) {
+                               for (i = 0; i < n; i += 2)
+                                       bam_swap_endian_2p(s + 5 + i);
+                       } else if (4 == Bsize) {
+                               for (i = 0; i < n; i += 4)
+                                       bam_swap_endian_4p(s + 5 + i);
+                       }
+                       bam_swap_endian_4p(s+1); 
+               }
        }
 }
 
@@ -291,6 +304,23 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of)
                else if (type == 'f') { ksprintf(&str, "f:%g", *(float*)s); s += 4; }
                else if (type == 'd') { ksprintf(&str, "d:%lg", *(double*)s); s += 8; }
                else if (type == 'Z' || type == 'H') { kputc(type, &str); kputc(':', &str); while (*s) kputc(*s++, &str); ++s; }
+               else if (type == 'B') {
+                       uint8_t sub_type = *(s++);
+                       int32_t n;
+                       memcpy(&n, s, 4);
+                       s += 4; // no point to the start of the array
+                       kputc(type, &str); kputc(':', &str); kputc(sub_type, &str); // write the typing
+                       for (i = 0; i < n; ++i) {
+                               kputc(',', &str);
+                               if ('c' == sub_type || 'c' == sub_type) { kputw(*(int8_t*)s, &str); ++s; }
+                               else if ('C' == sub_type) { kputw(*(uint8_t*)s, &str); ++s; }
+                               else if ('s' == sub_type) { kputw(*(int16_t*)s, &str); s += 2; }
+                               else if ('S' == sub_type) { kputw(*(uint16_t*)s, &str); s += 2; }
+                               else if ('i' == sub_type) { kputw(*(int32_t*)s, &str); s += 4; }
+                               else if ('I' == sub_type) { kputuw(*(uint32_t*)s, &str); s += 4; }
+                               else if ('f' == sub_type) { ksprintf(&str, "%g", *(float*)s); s += 4; }
+                       }
+               }
        }
        return str.s;
 }
index eef2ea9853f25966c5a40c45a86272b78a507fb2..e7360bb8ef2fc2ff245a716ccfaf22d827ed3f96 100644 (file)
 
   BAM library provides I/O and various operations on manipulating files
   in the BAM (Binary Alignment/Mapping) or SAM (Sequence Alignment/Map)
-  format. It now supports importing from or exporting to TAM, sorting,
+  format. It now supports importing from or exporting to SAM, sorting,
   merging, generating pileup, and quickly retrieval of reads overlapped
   with a specified region.
 
   @copyright Genome Research Ltd.
  */
 
+#define BAM_VERSION "0.1.16 (r963:234)"
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -262,6 +264,12 @@ typedef struct __bam_iter_t *bam_iter_t;
  */
 extern int bam_is_be;
 
+/*!
+  @abstract Verbose level between 0 and 3; 0 is supposed to disable all
+  debugging information, though this may not have been implemented.
+ */
+extern int bam_verbose;
+
 /*! @abstract Table for converting a nucleotide character to the 4-bit encoding. */
 extern unsigned char bam_nt16_table[256];
 
@@ -738,4 +746,13 @@ static inline bam1_t *bam_dup1(const bam1_t *src)
        return b;
 }
 
+static inline int bam_aux_type2size(int x)
+{
+       if (x == 'C' || x == 'c' || x == 'A') return 1;
+       else if (x == 'S' || x == 's') return 2;
+       else if (x == 'I' || x == 'i' || x == 'f') return 4;
+       else return 0;
+}
+
+
 #endif
index 066e0ac21be7dad0240f977a06e620928c2d6c86..06f85998d432012ac9baa56fa2f8ded3ae68ec5e 100644 (file)
@@ -13,6 +13,7 @@ extern        void ks_introsort_uint32_t(size_t n, uint32_t a[]);
 #define CALL_ETA 0.03f
 #define CALL_MAX 256
 #define CALL_DEFTHETA 0.83f
+#define DEF_MAPQ 20
 
 #define CAP_DIST 25
 
@@ -25,6 +26,8 @@ bcf_callaux_t *bcf_call_init(double theta, int min_baseQ)
        bca->openQ = 40; bca->extQ = 20; bca->tandemQ = 100;
        bca->min_baseQ = min_baseQ;
        bca->e = errmod_init(1. - theta);
+       bca->min_frac = 0.002;
+       bca->min_support = 1;
        return bca;
 }
 
@@ -63,7 +66,8 @@ int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t
                seqQ = is_indel? (p->aux>>8&0xff) : 99;
                if (q < bca->min_baseQ) continue;
                if (q > seqQ) q = seqQ;
-               mapQ = p->b->core.qual < bca->capQ? p->b->core.qual : bca->capQ;
+               mapQ = p->b->core.qual < 255? p->b->core.qual : DEF_MAPQ; // special case for mapQ==255
+               mapQ = mapQ < bca->capQ? mapQ : bca->capQ;
                if (q > mapQ) q = mapQ;
                if (q > 63) q = 63;
                if (q < 4) q = 4;
@@ -77,7 +81,7 @@ int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t
                }
                bca->bases[n++] = q<<5 | (int)bam1_strand(p->b)<<4 | b;
                // collect annotations
-               r->qsum[b] += q;
+               if (b < 4) r->qsum[b] += q;
                ++r->anno[0<<2|is_diff<<1|bam1_strand(p->b)];
                min_dist = p->b->core.l_qseq - 1 - p->qpos;
                if (min_dist > p->qpos) min_dist = p->qpos;
@@ -142,8 +146,8 @@ int bcf_call_combine(int n, const bcf_callret1_t *calls, int ref_base /*4-bit*/,
                x = call->n_alleles * (call->n_alleles + 1) / 2;
                // get the possible genotypes
                for (i = z = 0; i < call->n_alleles; ++i)
-                       for (j = i; j < call->n_alleles; ++j)
-                               g[z++] = call->a[i] * 5 + call->a[j];
+                       for (j = 0; j <= i; ++j)
+                               g[z++] = call->a[j] * 5 + call->a[i];
                for (i = 0; i < n; ++i) {
                        uint8_t *PL = call->PL + x * i;
                        const bcf_callret1_t *r = calls + i;
index 26b022c08e89e3597bd6e400690d42bd7ecabe38..958567241936a4c54feae501c725ad77a6e3f1be 100644 (file)
@@ -9,7 +9,9 @@
 
 typedef struct __bcf_callaux_t {
        int capQ, min_baseQ;
-       int openQ, extQ, tandemQ;
+       int openQ, extQ, tandemQ; // for indels
+       int min_support; // for collecting indel candidates
+       double min_frac; // for collecting indel candidates
        // for internal uses
        int max_bases;
        int indel_types[4];
index 7205688ef2453b3ab0da51112d853899a4add53f..b72864845374b07be7d9c0fb1ffb3ecd4c91b7cb 100644 (file)
@@ -13,7 +13,6 @@ KHASH_SET_INIT_STR(rg)
 
 #define MINUS_CONST 0x10000000
 #define INDEL_WINDOW_SIZE 50
-#define MIN_SUPPORT_COEF 500
 
 void *bcf_call_add_rg(void *_hash, const char *hdtext, const char *list)
 {
@@ -116,7 +115,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
        extern void ks_introsort_uint32_t(int, uint32_t*);
        int i, s, j, k, t, n_types, *types, max_rd_len, left, right, max_ins, *score1, *score2, max_ref2;
        int N, K, l_run, ref_type, n_alt;
-       char *inscns = 0, *ref2, *query;
+       char *inscns = 0, *ref2, *query, **ref_sample;
        khash_t(rg) *hash = (khash_t(rg)*)rghash;
        if (ref == 0 || bca == 0) return -1;
        // mark filtered reads
@@ -167,7 +166,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                // squeeze out identical types
                for (i = 1, n_types = 1; i < m; ++i)
                        if (aux[i] != aux[i-1]) ++n_types;
-               if (n_types == 1 || n_alt * MIN_SUPPORT_COEF < n_tot) { // no indels or too few supporting reads
+               if (n_types == 1 || (double)n_alt / n_tot < bca->min_frac || n_alt < bca->min_support) { // then skip
                        free(aux); return -1;
                }
                types = (int*)calloc(n_types, sizeof(int));
@@ -191,6 +190,58 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                        if (ref[i] == 0) break;
                right = i;
        }
+       /* The following block fixes a long-existing flaw in the INDEL
+        * calling model: the interference of nearby SNPs. However, it also
+        * reduces the power because sometimes, substitutions caused by
+        * indels are not distinguishable from true mutations. Multiple
+        * sequence realignment helps to increase the power.
+        */
+       { // construct per-sample consensus
+               int L = right - left + 1, max_i, max2_i;
+               uint32_t *cns, max, max2;
+               char *ref0, *r;
+               ref_sample = calloc(n, sizeof(void*));
+               cns = calloc(L, 4);
+               ref0 = calloc(L, 1);
+               for (i = 0; i < right - left; ++i)
+                       ref0[i] = bam_nt16_table[(int)ref[i+left]];
+               for (s = 0; s < n; ++s) {
+                       r = ref_sample[s] = calloc(L, 1);
+                       memset(cns, 0, sizeof(int) * L);
+                       // collect ref and non-ref counts
+                       for (i = 0; i < n_plp[s]; ++i) {
+                               bam_pileup1_t *p = plp[s] + i;
+                               bam1_t *b = p->b;
+                               uint32_t *cigar = bam1_cigar(b);
+                               uint8_t *seq = bam1_seq(b);
+                               int x = b->core.pos, y = 0;
+                               for (k = 0; k < b->core.n_cigar; ++k) {
+                                       int op = cigar[k]&0xf;
+                                       int j, l = cigar[k]>>4;
+                                       if (op == BAM_CMATCH) {
+                                               for (j = 0; j < l; ++j)
+                                                       if (x + j >= left && x + j < right)
+                                                               cns[x+j-left] += (bam1_seqi(seq, y+j) == ref0[x+j-left])? 1 : 0x10000;
+                                               x += l; y += l;
+                                       } else if (op == BAM_CDEL || op == BAM_CREF_SKIP) x += l;
+                                       else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) y += l;
+                               }
+                       }
+                       // determine the consensus
+                       for (i = 0; i < right - left; ++i) r[i] = ref0[i];
+                       max = max2 = 0; max_i = max2_i = -1;
+                       for (i = 0; i < right - left; ++i) {
+                               if (cns[i]>>16 >= max>>16) max2 = max, max2_i = max_i, max = cns[i], max_i = i;
+                               else if (cns[i]>>16 >= max2>>16) max2 = cns[i], max2_i = i;
+                       }
+                       if ((double)(max&0xffff) / ((max&0xffff) + (max>>16)) >= 0.7) max_i = -1;
+                       if ((double)(max2&0xffff) / ((max2&0xffff) + (max2>>16)) >= 0.7) max2_i = -1;
+                       if (max_i >= 0) r[max_i] = 15;
+                       if (max2_i >= 0) r[max2_i] = 15;
+//                     for (i = 0; i < right - left; ++i) fputc("=ACMGRSVTWYHKDBN"[(int)r[i]], pysamerr); fputc('\n', pysamerr);
+               }
+               free(ref0); free(cns);
+       }
        { // the length of the homopolymer run around the current position
                int c = bam_nt16_table[(int)ref[pos + 1]];
                if (c == 15) l_run = 1;
@@ -254,27 +305,29 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                else ir = est_indelreg(pos, ref, -types[t], 0);
                if (ir > bca->indelreg) bca->indelreg = ir;
 //             fprintf(pysamerr, "%d, %d, %d\n", pos, types[t], ir);
-               // write ref2
-               for (k = 0, j = left; j <= pos; ++j)
-                       ref2[k++] = bam_nt16_nt4_table[bam_nt16_table[(int)ref[j]]];
-               if (types[t] <= 0) j += -types[t];
-               else for (l = 0; l < types[t]; ++l)
-                                ref2[k++] = inscns[t*max_ins + l];
-               if (types[0] < 0) { // mask deleted sequences to avoid a particular error in the model.
-                       int jj, tmp = types[t] >= 0? -types[0] : -types[0] + types[t];
-                       for (jj = 0; jj < tmp && j < right && ref[j]; ++jj, ++j)
-                               ref2[k++] = 4;
-               }
-               for (; j < right && ref[j]; ++j)
-                       ref2[k++] = bam_nt16_nt4_table[bam_nt16_table[(int)ref[j]]];
-               for (; k < max_ref2; ++k) ref2[k] = 4;
-               if (j < right) right = j;
-               // align each read to ref2
+               // realignment
                for (s = K = 0; s < n; ++s) {
+                       // write ref2
+                       for (k = 0, j = left; j <= pos; ++j)
+                               ref2[k++] = bam_nt16_nt4_table[(int)ref_sample[s][j-left]];
+                       if (types[t] <= 0) j += -types[t];
+                       else for (l = 0; l < types[t]; ++l)
+                                        ref2[k++] = inscns[t*max_ins + l];
+                       for (; j < right && ref[j]; ++j)
+                               ref2[k++] = bam_nt16_nt4_table[(int)ref_sample[s][j-left]];
+                       for (; k < max_ref2; ++k) ref2[k] = 4;
+                       if (j < right) right = j;
+                       // align each read to ref2
                        for (i = 0; i < n_plp[s]; ++i, ++K) {
                                bam_pileup1_t *p = plp[s] + i;
-                               int qbeg, qend, tbeg, tend, sc;
+                               int qbeg, qend, tbeg, tend, sc, kk;
                                uint8_t *seq = bam1_seq(p->b);
+                               uint32_t *cigar = bam1_cigar(p->b);
+                               if (p->b->core.flag&4) continue; // unmapped reads
+                               // FIXME: the following loop should be better moved outside; nonetheless, realignment should be much slower anyway.
+                               for (kk = 0; kk < p->b->core.n_cigar; ++kk)
+                                       if ((cigar[kk]&BAM_CIGAR_MASK) == BAM_CREF_SKIP) break;
+                               if (kk < p->b->core.n_cigar) continue;
                                // FIXME: the following skips soft clips, but using them may be more sensitive.
                                // determine the start and end of sequences for alignment
                                qbeg = tpos2qpos(&p->b->core, bam1_cigar(p->b), left,  0, &tbeg);
@@ -369,9 +422,11 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                                indelQ2 = tmp > 111? 0 : (int)((1. - tmp/111.) * indelQ2 + .499);
                                // pick the smaller between indelQ1 and indelQ2
                                indelQ = indelQ1 < indelQ2? indelQ1 : indelQ2;
-                               p->aux = (sc[0]&0x3f)<<16 | seqQ<<8 | indelQ;
+                               if (indelQ > 255) indelQ = 255;
+                               if (seqQ > 255) seqQ = 255;
+                               p->aux = (sc[0]&0x3f)<<16 | seqQ<<8 | indelQ; // use 22 bits in total
                                sumq[sc[0]&0x3f] += indelQ < seqQ? indelQ : seqQ;
-//                             fprintf(pysamerr, "pos=%d read=%d:%d name=%s call=%d q=%d\n", pos, s, i, bam1_qname(p->b), types[sc[0]&0x3f], indelQ);
+//                             fprintf(pysamerr, "pos=%d read=%d:%d name=%s call=%d indelQ=%d seqQ=%d\n", pos, s, i, bam1_qname(p->b), types[sc[0]&0x3f], indelQ, seqQ);
                        }
                }
                // determine bca->indel_types[] and bca->inscns
@@ -409,6 +464,8 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
        }
        free(score1); free(score2);
        // free
+       for (i = 0; i < n; ++i) free(ref_sample[i]);
+       free(ref_sample);
        free(types); free(inscns);
        return n_alt > 0? 0 : -1;
 }
diff --git a/samtools/bam2depth.c.pysam.c b/samtools/bam2depth.c.pysam.c
new file mode 100644 (file)
index 0000000..d22837e
--- /dev/null
@@ -0,0 +1,114 @@
+#include "pysam.h"
+
+/* This program demonstrates how to generate pileup from multiple BAMs
+ * simutaneously, to achieve random access and to use the BED interface.
+ * To compile this program separately, you may:
+ *
+ *   gcc -g -O2 -Wall -o bam2depth -D_MAIN_BAM2DEPTH bam2depth.c -L. -lbam -lz
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "bam.h"
+
+typedef struct {     // auxiliary data structure
+       bamFile fp;      // the file handler
+       bam_iter_t iter; // NULL if a region not specified
+       int min_mapQ;    // mapQ filter
+} aux_t;
+
+void *bed_read(const char *fn); // read a BED or position list file
+void bed_destroy(void *_h);     // destroy the BED data structure
+int bed_overlap(const void *_h, const char *chr, int beg, int end); // test if chr:beg-end overlaps
+
+// This function reads a BAM alignment from one BAM file.
+static int read_bam(void *data, bam1_t *b) // read level filters better go here to avoid pileup
+{
+       aux_t *aux = (aux_t*)data; // data in fact is a pointer to an auxiliary structure
+       int ret = aux->iter? bam_iter_read(aux->fp, aux->iter, b) : bam_read1(aux->fp, b);
+       if ((int)b->core.qual < aux->min_mapQ) b->core.flag |= BAM_FUNMAP;
+       return ret;
+}
+
+#ifdef _MAIN_BAM2DEPTH
+int main(int argc, char *argv[])
+#else
+int main_depth(int argc, char *argv[])
+#endif
+{
+       int i, n, tid, beg, end, pos, *n_plp, baseQ = 0, mapQ = 0;
+       const bam_pileup1_t **plp;
+       char *reg = 0; // specified region
+       void *bed = 0; // BED data structure
+       bam_header_t *h = 0; // BAM header of the 1st input
+       aux_t **data;
+       bam_mplp_t mplp;
+
+       // parse the command line
+       while ((n = getopt(argc, argv, "r:b:q:Q:")) >= 0) {
+               switch (n) {
+                       case 'r': reg = strdup(optarg); break;   // parsing a region requires a BAM header
+                       case 'b': bed = bed_read(optarg); break; // BED or position list file can be parsed now
+                       case 'q': baseQ = atoi(optarg); break;   // base quality threshold
+                       case 'Q': mapQ = atoi(optarg); break;    // mapping quality threshold
+               }
+       }
+       if (optind == argc) {
+               fprintf(pysamerr, "Usage: bam2depth [-r reg] [-q baseQthres] [-Q mapQthres] [-b in.bed] <in1.bam> [...]\n");
+               return 1;
+       }
+
+       // initialize the auxiliary data structures
+       n = argc - optind; // the number of BAMs on the command line
+       data = calloc(n, sizeof(void*)); // data[i] for the i-th input
+       beg = 0; end = 1<<30; tid = -1;  // set the default region
+       for (i = 0; i < n; ++i) {
+               bam_header_t *htmp;
+               data[i] = calloc(1, sizeof(aux_t));
+               data[i]->fp = bam_open(argv[optind+i], "r"); // open BAM
+               data[i]->min_mapQ = mapQ;                    // set the mapQ filter
+               htmp = bam_header_read(data[i]->fp);         // read the BAM header
+               if (i == 0) {
+                       h = htmp; // keep the header of the 1st BAM
+                       if (reg) bam_parse_region(h, reg, &tid, &beg, &end); // also parse the region
+               } else bam_header_destroy(htmp); // if not the 1st BAM, trash the header
+               if (tid >= 0) { // if a region is specified and parsed successfully
+                       bam_index_t *idx = bam_index_load(argv[optind+i]);  // load the index
+                       data[i]->iter = bam_iter_query(idx, tid, beg, end); // set the iterator
+                       bam_index_destroy(idx); // the index is not needed any more; phase out of the memory
+               }
+       }
+
+       // the core multi-pileup loop
+       mplp = bam_mplp_init(n, read_bam, (void**)data); // initialization
+       n_plp = calloc(n, sizeof(int)); // n_plp[i] is the number of covering reads from the i-th BAM
+       plp = calloc(n, sizeof(void*)); // plp[i] points to the array of covering reads (internal in mplp)
+       while (bam_mplp_auto(mplp, &tid, &pos, n_plp, plp) > 0) { // come to the next covered position
+               if (pos < beg || pos >= end) continue; // out of range; skip
+               if (bed && bed_overlap(bed, h->target_name[tid], pos, pos + 1) == 0) continue; // not in BED; skip
+               fputs(h->target_name[tid], stdout); printf("\t%d", pos+1); // a customized printf() would be faster
+               for (i = 0; i < n; ++i) { // base level filters have to go here
+                       int j, m = 0;
+                       for (j = 0; j < n_plp[i]; ++j) {
+                               const bam_pileup1_t *p = plp[i] + j; // DON'T modfity plp[][] unless you really know
+                               if (p->is_del || p->is_refskip) ++m; // having dels or refskips at tid:pos
+                               else if (bam1_qual(p->b)[p->qpos] < baseQ) ++m; // low base quality
+                       }
+                       printf("\t%d", n_plp[i] - m); // this the depth to output
+               }
+               putchar('\n');
+       }
+       free(n_plp); free(plp);
+       bam_mplp_destroy(mplp);
+
+       bam_header_destroy(h);
+       for (i = 0; i < n; ++i) {
+               bam_close(data[i]->fp);
+               if (data[i]->iter) bam_iter_destroy(data[i]->iter);
+               free(data[i]);
+       }
+       free(data); free(reg);
+       if (bed) bed_destroy(bed);
+       return 0;
+}
index d02621d5289fedefaba3ad419dbf700657124b28..a1c1890e26eb85ebb2f3b53bb554aa64119a4652 100644 (file)
@@ -28,14 +28,12 @@ uint8_t *bam_aux_get_core(bam1_t *b, const char tag[2])
 }
 
 #define __skip_tag(s) do { \
-               int type = toupper(*(s));                                                                               \
-               ++(s);                                                                                                                  \
-               if (type == 'C' || type == 'A') ++(s);                                                  \
-               else if (type == 'S') (s) += 2;                                                                 \
-               else if (type == 'I' || type == 'F') (s) += 4;                                  \
-               else if (type == 'D') (s) += 8;                                                                 \
-               else if (type == 'Z' || type == 'H') { while (*(s)) ++(s); ++(s); } \
-       } while (0)
+               int type = toupper(*(s)); \
+               ++(s); \
+               if (type == 'Z' || type == 'H') { while (*(s)) ++(s); ++(s); } \
+               else if (type == 'B') (s) += 5 + bam_aux_type2size(*(s)) * (*(int32_t*)((s)+1)); \
+               else (s) += bam_aux_type2size(type); \
+       } while(0)
 
 uint8_t *bam_aux_get(const bam1_t *b, const char tag[2])
 {
@@ -182,3 +180,10 @@ char *bam_aux2Z(const uint8_t *s)
        if (type == 'Z' || type == 'H') return (char*)s;
        else return 0;
 }
+
+#ifdef _WIN32
+double drand48()
+{
+       return (double)rand() / RAND_MAX;
+}
+#endif
diff --git a/samtools/bam_cat.c.pysam.c b/samtools/bam_cat.c.pysam.c
new file mode 100644 (file)
index 0000000..0cc1167
--- /dev/null
@@ -0,0 +1,186 @@
+#include "pysam.h"
+
+/*\r
+\r
+bam_cat -- efficiently concatenates bam files\r
+\r
+bam_cat can be used to concatenate BAM files. Under special\r
+circumstances, it can be used as an alternative to 'samtools merge' to\r
+concatenate multiple sorted files into a single sorted file. For this\r
+to work each file must be sorted, and the sorted files must be given\r
+as command line arguments in order such that the final read in file i\r
+is less than or equal to the first read in file i+1.\r
+\r
+This code is derived from the bam_reheader function in samtools 0.1.8\r
+and modified to perform concatenation by Chris Saunders on behalf of\r
+Illumina.\r
+\r
+\r
+########## License:\r
+\r
+The MIT License\r
+\r
+Original SAMtools work copyright (c) 2008-2009 Genome Research Ltd.\r
+Modified SAMtools work copyright (c) 2010 Illumina, Inc.\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+*/\r
+\r
+\r
+/*\r
+makefile:\r
+"""\r
+CC=gcc\r
+CFLAGS+=-g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I$(SAMTOOLS_DIR)\r
+LDFLAGS+=-L$(SAMTOOLS_DIR)\r
+LDLIBS+=-lbam -lz\r
+\r
+all:bam_cat\r
+"""\r
+*/\r
+\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+\r
+#include "bgzf.h"\r
+#include "bam.h"\r
+\r
+#define BUF_SIZE 0x10000\r
+\r
+#define GZIPID1 31\r
+#define GZIPID2 139\r
+\r
+#define BGZF_EMPTY_BLOCK_SIZE 28\r
+\r
+\r
+int bam_cat(int nfn, char * const *fn, const bam_header_t *h, const char* outbam)\r
+{\r
+    BGZF *fp;\r
+    FILE* fp_file;\r
+    uint8_t *buf;\r
+    uint8_t ebuf[BGZF_EMPTY_BLOCK_SIZE];\r
+    const int es=BGZF_EMPTY_BLOCK_SIZE;\r
+    int i;\r
+    \r
+    fp = strcmp(outbam, "-")? bgzf_open(outbam, "w") : bgzf_fdopen(fileno(stdout), "w");\r
+    if (fp == 0) {\r
+        fprintf(pysamerr, "[%s] ERROR: fail to open output file '%s'.\n", __func__, outbam);\r
+        return 1;\r
+    }\r
+    if (h) bam_header_write(fp, h);\r
+    \r
+    buf = (uint8_t*) malloc(BUF_SIZE);\r
+    for(i = 0; i < nfn; ++i){\r
+        BGZF *in;\r
+        bam_header_t *old;\r
+        int len,j;\r
+        \r
+        in = strcmp(fn[i], "-")? bam_open(fn[i], "r") : bam_dopen(fileno(stdin), "r");\r
+        if (in == 0) {\r
+            fprintf(pysamerr, "[%s] ERROR: fail to open file '%s'.\n", __func__, fn[i]);\r
+            return -1;\r
+        }\r
+        if (in->open_mode != 'r') return -1;\r
+        \r
+        old = bam_header_read(in);\r
+               if (h == 0 && i == 0) bam_header_write(fp, old);\r
+        \r
+        if (in->block_offset < in->block_length) {\r
+            bgzf_write(fp, in->uncompressed_block + in->block_offset, in->block_length - in->block_offset);\r
+            bgzf_flush(fp);\r
+        }\r
+        \r
+        j=0;\r
+#ifdef _USE_KNETFILE\r
+        fp_file=fp->x.fpw;\r
+        while ((len = knet_read(in->x.fpr, buf, BUF_SIZE)) > 0) {\r
+#else  \r
+        fp_file=fp->file;\r
+        while (!feof(in->file) && (len = fread(buf, 1, BUF_SIZE, in->file)) > 0) {\r
+#endif\r
+            if(len<es){\r
+                int diff=es-len;\r
+                if(j==0) {\r
+                    fprintf(pysamerr, "[%s] ERROR: truncated file?: '%s'.\n", __func__, fn[i]);\r
+                    return -1;\r
+                }\r
+                fwrite(ebuf, 1, len, fp_file);\r
+                memcpy(ebuf,ebuf+len,diff);\r
+                memcpy(ebuf+diff,buf,len);\r
+            } else {\r
+                if(j!=0) fwrite(ebuf, 1, es, fp_file);\r
+                len-= es;\r
+                memcpy(ebuf,buf+len,es);\r
+                fwrite(buf, 1, len, fp_file);\r
+            }\r
+            j=1;\r
+        }\r
+\r
+        /* check final gzip block */\r
+        {\r
+            const uint8_t gzip1=ebuf[0];\r
+            const uint8_t gzip2=ebuf[1];\r
+            const uint32_t isize=*((uint32_t*)(ebuf+es-4));\r
+            if(((gzip1!=GZIPID1) || (gzip2!=GZIPID2)) || (isize!=0)) {\r
+                fprintf(pysamerr, "[%s] WARNING: Unexpected block structure in file '%s'.", __func__, fn[i]);\r
+                fprintf(pysamerr, " Possible output corruption.\n");\r
+                fwrite(ebuf, 1, es, fp_file);\r
+            }\r
+        }\r
+        bam_header_destroy(old);\r
+        bgzf_close(in);\r
+    }\r
+    free(buf);\r
+    bgzf_close(fp);\r
+    return 0;\r
+}\r
+\r
+\r
+\r
+int main_cat(int argc, char *argv[])\r
+{\r
+    bam_header_t *h = 0;\r
+       char *outfn = 0;\r
+       int c, ret;\r
+       while ((c = getopt(argc, argv, "h:o:")) >= 0) {\r
+               switch (c) {\r
+                       case 'h': {\r
+                       tamFile fph = sam_open(optarg);\r
+                       if (fph == 0) {\r
+                       fprintf(pysamerr, "[%s] ERROR: fail to read the header from '%s'.\n", __func__, argv[1]);\r
+                           return 1;\r
+                       }\r
+                   h = sam_header_read(fph);\r
+               sam_close(fph);\r
+                               break;\r
+                       }\r
+                       case 'o': outfn = strdup(optarg); break;\r
+               }\r
+       }\r
+       if (argc - optind < 2) {\r
+        fprintf(pysamerr, "Usage: samtools cat [-h header.sam] [-o out.bam] <in1.bam> <in2.bam> [...]\n");\r
+        return 1;\r
+    }\r
+    ret = bam_cat(argc - optind, argv + optind, h, outfn? outfn : "-");\r
+       free(outfn);\r
+       return ret;\r
+}\r
index 238b05bd56aafae6dabbcbf66a353c7f1c4b8f4d..da25f036504eb75f2617ea0d837f3f3df73c796d 100644 (file)
@@ -429,6 +429,27 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b)
                                memcpy(s, str->s + 5, str->l - 5);
                                s[str->l - 5] = 0;
                                doff += size;
+                       } else if (type == 'B') {
+                               int32_t n = 0, Bsize, k = 0, size;
+                               char *p;
+                               if (str->l < 8) parse_error(fp->n_lines, "too few values in aux type B");
+                               Bsize = bam_aux_type2size(str->s[5]); // the size of each element
+                               for (p = (char*)str->s + 6; *p; ++p) // count the number of elements in the array
+                                       if (*p == ',') ++n;
+                               p = str->s + 7; // now p points to the first number in the array
+                               size = 6 + Bsize * n; // total number of bytes allocated to this tag
+                               s = alloc_data(b, doff + 6 * Bsize * n) + doff; // allocate memory
+                               *s++ = 'B'; *s++ = str->s[5];
+                               memcpy(s, &n, 4); s += 4; // write the number of elements
+                               if (str->s[5] == 'c')      while (p < str->s + str->l) ((int8_t*)s)[k++]   = (int8_t)strtol(p, &p, 0),   ++p;
+                               else if (str->s[5] == 'C') while (p < str->s + str->l) ((uint8_t*)s)[k++]  = (uint8_t)strtol(p, &p, 0),  ++p;
+                               else if (str->s[5] == 's') while (p < str->s + str->l) ((int16_t*)s)[k++]  = (int16_t)strtol(p, &p, 0),  ++p; // FIXME: avoid unaligned memory
+                               else if (str->s[5] == 'S') while (p < str->s + str->l) ((uint16_t*)s)[k++] = (uint16_t)strtol(p, &p, 0), ++p;
+                               else if (str->s[5] == 'i') while (p < str->s + str->l) ((int32_t*)s)[k++]  = (int32_t)strtol(p, &p, 0),  ++p;
+                               else if (str->s[5] == 'I') while (p < str->s + str->l) ((uint32_t*)s)[k++] = (uint32_t)strtol(p, &p, 0), ++p;
+                               else if (str->s[5] == 'f') while (p < str->s + str->l) ((float*)s)[k++]    = (float)strtof(p, &p),       ++p;
+                               else parse_error(fp->n_lines, "unrecognized array type");
+                               s += Bsize * n; doff += size;
                        } else parse_error(fp->n_lines, "unrecognized type");
                        if (dret == '\n' || dret == '\r') break;
                }
index 1e942753875131e9740341df62c8ddda282f34c4..e6c90bdc2d23cb47466e3ed103f820fa92a11356 100644 (file)
@@ -219,8 +219,15 @@ bam_index_t *bam_index_core(bamFile fp)
        }
        merge_chunks(idx);
        fill_missing(idx);
-       if (ret >= 0)
-               while ((ret = bam_read1(fp, b)) >= 0) ++n_no_coor;
+       if (ret >= 0) {
+               while ((ret = bam_read1(fp, b)) >= 0) {
+                       ++n_no_coor;
+                       if (c->tid >= 0 && n_no_coor) {
+                               fprintf(pysamerr, "[bam_index_core] the alignment is not sorted: reads without coordinates prior to reads with coordinates.\n");
+                               exit(1);
+                       }
+               }
+       }
        if (ret < -1) fprintf(pysamerr, "[bam_index_core] truncated file? Continue anyway. (%d)\n", ret);
        free(b->data); free(b);
        idx->n_no_coor = n_no_coor;
index afc3a9dcf2e34086d9b4124ca2d3f73063576e42..513a25113ddfd3a94536fba9c11e89c5365cd5c1 100644 (file)
@@ -24,8 +24,6 @@ typedef struct {
        uint32_t c[4];
 } glf_call_aux_t;
 
-char bam_nt16_nt4_table[] = { 4, 0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4 };
-
 /*
   P(<b1,b2>) = \theta \sum_{i=1}^{N-1} 1/i
   P(D|<b1,b2>) = \sum_{k=1}^{N-1} p_k 1/2 [(k/N)^n_2(1-k/N)^n_1 + (k/N)^n1(1-k/N)^n_2]
index 75e8f6e4f42758ed152841e356f7d5e87c6610d9..c6568b770200f4744b4255fc0fc14451c51a001a 100644 (file)
@@ -11,6 +11,8 @@
 #include "kaln.h"
 #include "kprobaln.h"
 
+char bam_nt16_nt4_table[] = { 4, 0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4 };
+
 void bam_fillmd1_core(bam1_t *b, char *ref, int is_equal, int max_nm)
 {
        uint8_t *seq = bam1_seq(b);
@@ -164,14 +166,14 @@ int bam_cap_mapQ(bam1_t *b, char *ref, int thres)
        return (int)(t + .499);
 }
 
-int bam_prob_realn_core(bam1_t *b, const char *ref, int apply_baq)
+int bam_prob_realn_core(bam1_t *b, const char *ref, int flag)
 {
-       int k, i, bw, x, y, yb, ye, xb, xe;
+       int k, i, bw, x, y, yb, ye, xb, xe, apply_baq = flag&1, extend_baq = flag>>1&1;
        uint32_t *cigar = bam1_cigar(b);
        bam1_core_t *c = &b->core;
        kpa_par_t conf = kpa_par_def;
        uint8_t *bq = 0, *zq = 0, *qual = bam1_qual(b);
-       if (c->flag & BAM_FUNMAP) return -1; // do nothing
+       if ((c->flag & BAM_FUNMAP) || b->core.l_qseq == 0) return -1; // do nothing
        // test if BQ or ZQ is present
        if ((bq = bam_aux_get(b, "BQ")) != 0) ++bq;
        if ((zq = bam_aux_get(b, "ZQ")) != 0 && *zq == 'Z') ++zq;
@@ -223,23 +225,47 @@ int bam_prob_realn_core(bam1_t *b, const char *ref, int apply_baq)
                s = calloc(c->l_qseq, 1);
                for (i = 0; i < c->l_qseq; ++i) s[i] = bam_nt16_nt4_table[bam1_seqi(seq, i)];
                r = calloc(xe - xb, 1);
-               for (i = xb; i < xe; ++i)
+               for (i = xb; i < xe; ++i) {
+                       if (ref[i] == 0) { xe = i; break; }
                        r[i-xb] = bam_nt16_nt4_table[bam_nt16_table[(int)ref[i]]];
+               }
                state = calloc(c->l_qseq, sizeof(int));
                q = calloc(c->l_qseq, 1);
                kpa_glocal(r, xe-xb, s, c->l_qseq, qual, &conf, state, q);
-               for (k = 0, x = c->pos, y = 0; k < c->n_cigar; ++k) {
-                       int op = cigar[k]&0xf, l = cigar[k]>>4;
-                       if (op == BAM_CMATCH) {
-                               for (i = y; i < y + l; ++i) {
-                                       if ((state[i]&3) != 0 || state[i]>>2 != x - xb + (i - y)) bq[i] = 0;
-                                       else bq[i] = bq[i] < q[i]? bq[i] : q[i];
-                               }
-                               x += l; y += l;
-                       } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) y += l;
-                       else if (op == BAM_CDEL) x += l;
+               if (!extend_baq) { // in this block, bq[] is capped by base quality qual[]
+                       for (k = 0, x = c->pos, y = 0; k < c->n_cigar; ++k) {
+                               int op = cigar[k]&0xf, l = cigar[k]>>4;
+                               if (op == BAM_CMATCH) {
+                                       for (i = y; i < y + l; ++i) {
+                                               if ((state[i]&3) != 0 || state[i]>>2 != x - xb + (i - y)) bq[i] = 0;
+                                               else bq[i] = bq[i] < q[i]? bq[i] : q[i];
+                                       }
+                                       x += l; y += l;
+                               } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) y += l;
+                               else if (op == BAM_CDEL) x += l;
+                       }
+                       for (i = 0; i < c->l_qseq; ++i) bq[i] = qual[i] - bq[i] + 64; // finalize BQ
+               } else { // in this block, bq[] is BAQ that can be larger than qual[] (different from the above!)
+                       uint8_t *left, *rght;
+                       left = calloc(c->l_qseq, 1); rght = calloc(c->l_qseq, 1);
+                       for (k = 0, x = c->pos, y = 0; k < c->n_cigar; ++k) {
+                               int op = cigar[k]&0xf, l = cigar[k]>>4;
+                               if (op == BAM_CMATCH) {
+                                       for (i = y; i < y + l; ++i)
+                                               bq[i] = ((state[i]&3) != 0 || state[i]>>2 != x - xb + (i - y))? 0 : q[i];
+                                       for (left[y] = bq[y], i = y + 1; i < y + l; ++i)
+                                               left[i] = bq[i] > left[i-1]? bq[i] : left[i-1];
+                                       for (rght[y+l-1] = bq[y+l-1], i = y + l - 2; i >= y; --i)
+                                               rght[i] = bq[i] > rght[i+1]? bq[i] : rght[i+1];
+                                       for (i = y; i < y + l; ++i)
+                                               bq[i] = left[i] < rght[i]? left[i] : rght[i];
+                                       x += l; y += l;
+                               } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) y += l;
+                               else if (op == BAM_CDEL) x += l;
+                       }
+                       for (i = 0; i < c->l_qseq; ++i) bq[i] = 64 + (qual[i] <= bq[i]? 0 : qual[i] - bq[i]); // finalize BQ
+                       free(left); free(rght);
                }
-               for (i = 0; i < c->l_qseq; ++i) bq[i] = qual[i] - bq[i] + 64; // finalize BQ
                if (apply_baq) {
                        for (i = 0; i < c->l_qseq; ++i) qual[i] -= bq[i] - 64; // modify qual
                        bam_aux_append(b, "ZQ", 'Z', c->l_qseq + 1, bq);
@@ -256,16 +282,16 @@ int bam_prob_realn(bam1_t *b, const char *ref)
 
 int bam_fillmd(int argc, char *argv[])
 {
-       int c, is_equal, tid = -2, ret, len, is_bam_out, is_sam_in, is_uncompressed, max_nm, is_realn, capQ, apply_baq;
+       int c, is_equal, tid = -2, ret, len, is_bam_out, is_sam_in, is_uncompressed, max_nm, is_realn, capQ, baq_flag;
        samfile_t *fp, *fpout = 0;
        faidx_t *fai;
        char *ref = 0, mode_w[8], mode_r[8];
        bam1_t *b;
 
-       is_equal = is_bam_out = is_sam_in = is_uncompressed = is_realn = max_nm = apply_baq = capQ = 0;
+       is_equal = is_bam_out = is_sam_in = is_uncompressed = is_realn = max_nm = capQ = baq_flag = 0;
        mode_w[0] = mode_r[0] = 0;
        strcpy(mode_r, "r"); strcpy(mode_w, "w");
-       while ((c = getopt(argc, argv, "reubSC:n:A")) >= 0) {
+       while ((c = getopt(argc, argv, "EreubSC:n:A")) >= 0) {
                switch (c) {
                case 'r': is_realn = 1; break;
                case 'e': is_equal = 1; break;
@@ -274,7 +300,8 @@ int bam_fillmd(int argc, char *argv[])
                case 'S': is_sam_in = 1; break;
                case 'n': max_nm = atoi(optarg); break;
                case 'C': capQ = atoi(optarg); break;
-               case 'A': apply_baq = 1; break;
+               case 'A': baq_flag |= 1; break;
+               case 'E': baq_flag |= 2; break;
                default: fprintf(pysamerr, "[bam_fillmd] unrecognized option '-%c'\n", c); return 1;
                }
        }
@@ -290,7 +317,8 @@ int bam_fillmd(int argc, char *argv[])
                fprintf(pysamerr, "         -b       compressed BAM output\n");
                fprintf(pysamerr, "         -S       the input is SAM with header\n");
                fprintf(pysamerr, "         -A       modify the quality string\n");
-               fprintf(pysamerr, "         -r       read-independent local realignment\n\n");
+               fprintf(pysamerr, "         -r       compute the BQ tag (without -A) or cap baseQ by BAQ (with -A)\n");
+               fprintf(pysamerr, "         -E       extended BAQ for better sensitivity but lower specificity\n\n");
                return 1;
        }
        fp = samopen(argv[optind], mode_r, 0);
@@ -313,7 +341,7 @@ int bam_fillmd(int argc, char *argv[])
                                        fprintf(pysamerr, "[bam_fillmd] fail to find sequence '%s' in the reference.\n",
                                                        fp->header->target_name[tid]);
                        }
-                       if (is_realn) bam_prob_realn_core(b, ref, apply_baq);
+                       if (is_realn) bam_prob_realn_core(b, ref, baq_flag);
                        if (capQ > 10) {
                                int q = bam_cap_mapQ(b, ref, capQ);
                                if (b->core.qual > q) b->core.qual = q;
index 1137b8d5137a33375280a2f02be7a27a5c1aeb48..93b729db2388b9ef14ba093c2eef7b31dee52663 100644 (file)
@@ -273,7 +273,6 @@ static int pileup_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *p
         if (proposed_indels) // the first element gives the size of the array
             r = bam_maqindel(m, pos, d->ido, pu, d->ref, proposed_indels[0], proposed_indels+1);
         else r = bam_maqindel(m, pos, d->ido, pu, d->ref, 0, 0);
-       
        }
        // when only variant sites are asked for, test if the site is a variant
        if ((d->format & BAM_PLF_CNS) && (d->format & BAM_PLF_VAR_ONLY)) {
@@ -372,7 +371,7 @@ int bam_pileup(int argc, char *argv[])
        int c, is_SAM = 0;
        char *fn_list = 0, *fn_fa = 0, *fn_pos = 0;
        pu_data_t *d = (pu_data_t*)calloc(1, sizeof(pu_data_t));
-        d->max_depth = 1024; d->tid = -1; d->mask = BAM_DEF_MASK; d->min_baseQ = 13;
+    d->max_depth = 1024; d->tid = -1; d->mask = BAM_DEF_MASK; d->min_baseQ = 13;
        d->c = bam_maqcns_init();
        d->c->errmod = BAM_ERRMOD_MAQ2; // change the default model
        d->ido = bam_maqindel_opt_init();
@@ -440,6 +439,7 @@ int bam_pileup(int argc, char *argv[])
                fprintf(pysamerr, "        -G FLOAT  prior of an indel between two haplotypes (for -c) [%.4g]\n", d->ido->r_indel);
                fprintf(pysamerr, "        -I INT    phred prob. of an indel in sequencing/prep. (for -c) [%d]\n", d->ido->q_indel);
                fprintf(pysamerr, "\n");
+               fprintf(pysamerr, "Warning: Please use the `mpileup' command instead `pileup'. `Pileup' is deprecated!\n\n");
                free(fn_list); free(fn_fa); free(d);
                return 1;
        }
@@ -536,20 +536,29 @@ int bam_pileup(int argc, char *argv[])
 #define MPLP_FMT_DP 0x100
 #define MPLP_FMT_SP 0x200
 #define MPLP_NO_INDEL 0x400
+#define MPLP_EXT_BAQ 0x800
+#define MPLP_ILLUMINA13 0x1000
+
+void *bed_read(const char *fn);
+void bed_destroy(void *_h);
+int bed_overlap(const void *_h, const char *chr, int beg, int end);
 
 typedef struct {
-       int max_mq, min_mq, flag, min_baseQ, capQ_thres, max_depth;
-       int openQ, extQ, tandemQ;
-       char *reg, *fn_pos, *pl_list;
+       int max_mq, min_mq, flag, min_baseQ, capQ_thres, max_depth, max_indel_depth;
+       int openQ, extQ, tandemQ, min_support; // for indels
+       double min_frac; // for indels
+       char *reg, *pl_list;
        faidx_t *fai;
-       kh_64_t *hash;
+       void *bed, *rghash;
 } mplp_conf_t;
 
 typedef struct {
        bamFile fp;
        bam_iter_t iter;
-       int min_mq, flag, ref_id, capQ_thres;
+       bam_header_t *h;
+       int ref_id;
        char *ref;
+       const mplp_conf_t *conf;
 } mplp_aux_t;
 
 typedef struct {
@@ -569,16 +578,35 @@ static int mplp_func(void *data, bam1_t *b)
                int has_ref;
                ret = ma->iter? bam_iter_read(ma->fp, ma->iter, b) : bam_read1(ma->fp, b);
                if (ret < 0) break;
+               if (b->core.tid < 0 || (b->core.flag&BAM_FUNMAP)) { // exclude unmapped reads
+                       skip = 1;
+                       continue;
+               }
+               if (ma->conf->bed) { // test overlap
+                       skip = !bed_overlap(ma->conf->bed, ma->h->target_name[b->core.tid], b->core.pos, bam_calend(&b->core, bam1_cigar(b)));
+                       if (skip) continue;
+               }
+               if (ma->conf->rghash) { // exclude read groups
+                       uint8_t *rg = bam_aux_get(b, "RG");
+                       skip = (rg && bcf_str2id(ma->conf->rghash, (const char*)(rg+1)) >= 0);
+                       if (skip) continue;
+               }
+               if (ma->conf->flag & MPLP_ILLUMINA13) {
+                       int i;
+                       uint8_t *qual = bam1_qual(b);
+                       for (i = 0; i < b->core.l_qseq; ++i)
+                               qual[i] = qual[i] > 31? qual[i] - 31 : 0;
+               }
                has_ref = (ma->ref && ma->ref_id == b->core.tid)? 1 : 0;
                skip = 0;
-               if (has_ref && (ma->flag&MPLP_REALN)) bam_prob_realn_core(b, ma->ref, 1);
-               if (has_ref && ma->capQ_thres > 10) {
-                       int q = bam_cap_mapQ(b, ma->ref, ma->capQ_thres);
+               if (has_ref && (ma->conf->flag&MPLP_REALN)) bam_prob_realn_core(b, ma->ref, (ma->conf->flag & MPLP_EXT_BAQ)? 3 : 1);
+               if (has_ref && ma->conf->capQ_thres > 10) {
+                       int q = bam_cap_mapQ(b, ma->ref, ma->conf->capQ_thres);
                        if (q < 0) skip = 1;
                        else if (b->core.qual > q) b->core.qual = q;
-               } else if (b->core.flag&BAM_FUNMAP) skip = 1;
-               else if (b->core.qual < ma->min_mq) skip = 1; 
-               else if ((ma->flag&MPLP_NO_ORPHAN) && (b->core.flag&1) && !(b->core.flag&2)) skip = 1;
+               }
+               else if (b->core.qual < ma->conf->min_mq) skip = 1; 
+               else if ((ma->conf->flag&MPLP_NO_ORPHAN) && (b->core.flag&1) && !(b->core.flag&2)) skip = 1;
        } while (skip);
        return ret;
 }
@@ -596,7 +624,11 @@ static void group_smpl(mplp_pileup_t *m, bam_sample_t *sm, kstring_t *buf,
                        q = bam_aux_get(p->b, "RG");
                        if (q) id = bam_smpl_rg2smid(sm, fn[i], (char*)q+1, buf);
                        if (id < 0) id = bam_smpl_rg2smid(sm, fn[i], 0, buf);
-                       assert(id >= 0 && id < m->n);
+                       if (id < 0 || id >= m->n) {
+                               assert(q); // otherwise a bug
+                               fprintf(pysamerr, "[%s] Read group %s used in file %s but absent from the header or an alignment missing read group.\n", __func__, (char*)q+1, fn[i]);
+                               exit(1);
+                       }
                        if (m->n_plp[id] == m->m_plp[id]) {
                                m->m_plp[id] = m->m_plp[id]? m->m_plp[id]<<1 : 8;
                                m->plp[id] = realloc(m->plp[id], sizeof(bam_pileup1_t) * m->m_plp[id]);
@@ -611,12 +643,11 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
        extern void *bcf_call_add_rg(void *rghash, const char *hdtext, const char *list);
        extern void bcf_call_del_rghash(void *rghash);
        mplp_aux_t **data;
-       int i, tid, pos, *n_plp, beg0 = 0, end0 = 1u<<29, ref_len, ref_tid, max_depth;
+       int i, tid, pos, *n_plp, beg0 = 0, end0 = 1u<<29, ref_len, ref_tid, max_depth, max_indel_depth;
        const bam_pileup1_t **plp;
        bam_mplp_t iter;
        bam_header_t *h = 0;
        char *ref;
-       khash_t(64) *hash = 0;
        void *rghash = 0;
 
        bcf_callaux_t *bca = 0;
@@ -641,11 +672,10 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
        for (i = 0; i < n; ++i) {
                bam_header_t *h_tmp;
                data[i] = calloc(1, sizeof(mplp_aux_t));
-               data[i]->min_mq = conf->min_mq;
-               data[i]->flag = conf->flag;
-               data[i]->capQ_thres = conf->capQ_thres;
                data[i]->fp = strcmp(fn[i], "-") == 0? bam_dopen(fileno(stdin), "r") : bam_open(fn[i], "r");
+               data[i]->conf = conf;
                h_tmp = bam_header_read(data[i]->fp);
+               data[i]->h = i? h : h_tmp; // for i==0, "h" has not been set yet
                bam_smpl_add(sm, fn[i], h_tmp->text);
                rghash = bcf_call_add_rg(rghash, h_tmp->text, conf->pl_list);
                if (conf->reg) {
@@ -676,7 +706,6 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
        gplp.plp = calloc(sm->n, sizeof(void*));
 
        fprintf(pysamerr, "[%s] %d samples in %d input files\n", __func__, sm->n, n);
-       if (conf->fn_pos) hash = load_pos(conf->fn_pos, h);
        // write the VCF header
        if (conf->flag & MPLP_GLF) {
                kstring_t s;
@@ -697,7 +726,8 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                bh->l_smpl = s.l;
                bh->sname = malloc(s.l);
                memcpy(bh->sname, s.s, s.l);
-               bh->l_txt = 0;
+               bh->txt = malloc(strlen(BAM_VERSION) + 64);
+               bh->l_txt = 1 + sprintf(bh->txt, "##samtoolsVersion=%s\n", BAM_VERSION);
                free(s.s);
                bcf_hdr_sync(bh);
                bcf_hdr_write(bp, bh);
@@ -705,6 +735,8 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                bcr = calloc(sm->n, sizeof(bcf_callret1_t));
                bca->rghash = rghash;
                bca->openQ = conf->openQ, bca->extQ = conf->extQ, bca->tandemQ = conf->tandemQ;
+               bca->min_frac = conf->min_frac;
+               bca->min_support = conf->min_support;
        }
        ref_tid = -1; ref = 0;
        iter = bam_mplp_init(n, mplp_func, (void**)data);
@@ -713,16 +745,13 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                fprintf(pysamerr, "(%s) Max depth is above 1M. Potential memory hog!\n", __func__);
        if (max_depth * sm->n < 8000) {
                max_depth = 8000 / sm->n;
-               fprintf(pysamerr, "<%s> Set max per-sample depth to %d\n", __func__, max_depth);
+               fprintf(pysamerr, "<%s> Set max per-file depth to %d\n", __func__, max_depth);
        }
+       max_indel_depth = conf->max_indel_depth * sm->n;
        bam_mplp_set_maxcnt(iter, max_depth);
        while (bam_mplp_auto(iter, &tid, &pos, n_plp, plp) > 0) {
                if (conf->reg && (pos < beg0 || pos >= end0)) continue; // out of the region requested
-               if (hash) {
-                       khint_t k;
-                       k = kh_get(64, hash, (uint64_t)tid<<32 | pos);
-                       if (k == kh_end(hash)) continue;
-               }
+               if (conf->bed && tid >= 0 && !bed_overlap(conf->bed, h->target_name[tid], pos, pos+1)) continue;
                if (tid != ref_tid) {
                        free(ref); ref = 0;
                        if (conf->fai) ref = fai_fetch(conf->fai, h->target_name[tid], &ref_len);
@@ -730,8 +759,9 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        ref_tid = tid;
                }
                if (conf->flag & MPLP_GLF) {
-                       int _ref0, ref16;
+                       int total_depth, _ref0, ref16;
                        bcf1_t *b = calloc(1, sizeof(bcf1_t));
+                       for (i = total_depth = 0; i < n; ++i) total_depth += n_plp[i];
                        group_smpl(&gplp, sm, &buf, n, fn, n_plp, plp);
                        _ref0 = (ref && pos < ref_len)? ref[pos] : 'N';
                        ref16 = bam_nt16_table[_ref0];
@@ -743,7 +773,7 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        bcf_write(bp, bh, b);
                        bcf_destroy(b);
                        // call indels
-                       if (!(conf->flag&MPLP_NO_INDEL) && bcf_call_gap_prep(gplp.n, gplp.n_plp, gplp.plp, pos, bca, ref, rghash) >= 0) {
+                       if (!(conf->flag&MPLP_NO_INDEL) && total_depth < max_indel_depth && bcf_call_gap_prep(gplp.n, gplp.n_plp, gplp.plp, pos, bca, ref, rghash) >= 0) {
                                for (i = 0; i < gplp.n; ++i)
                                        bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], -1, bca, bcr + i);
                                if (bcf_call_combine(gplp.n, bcr, -1, &bc) >= 0) {
@@ -781,12 +811,6 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
        for (i = 0; i < gplp.n; ++i) free(gplp.plp[i]);
        free(gplp.plp); free(gplp.n_plp); free(gplp.m_plp);
        bcf_call_del_rghash(rghash);
-       if (hash) { // free the hash table
-               khint_t k;
-               for (k = kh_begin(hash); k < kh_end(hash); ++k)
-                       if (kh_exist(hash, k)) free(kh_val(hash, k));
-               kh_destroy(64, hash);
-       }
        bcf_hdr_destroy(bh); bcf_call_destroy(bca); free(bc.PL); free(bcr);
        bam_mplp_destroy(iter);
        bam_header_destroy(h);
@@ -800,7 +824,7 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
 }
 
 #define MAX_PATH_LEN 1024
-int read_file_list(const char *file_list,int *n,char **argv[])
+static int read_file_list(const char *file_list,int *n,char **argv[])
 {
     char buf[MAX_PATH_LEN];
     int len, nfiles;
@@ -853,16 +877,17 @@ int bam_mpileup(int argc, char *argv[])
        int c;
     const char *file_list = NULL;
     char **fn = NULL;
-    int nfiles = 0;
+    int nfiles = 0, use_orphan = 0;
        mplp_conf_t mplp;
        memset(&mplp, 0, sizeof(mplp_conf_t));
        mplp.max_mq = 60;
        mplp.min_baseQ = 13;
        mplp.capQ_thres = 0;
-       mplp.max_depth = 250;
+       mplp.max_depth = 250; mplp.max_indel_depth = 250;
        mplp.openQ = 40; mplp.extQ = 20; mplp.tandemQ = 100;
+       mplp.min_frac = 0.002; mplp.min_support = 1;
        mplp.flag = MPLP_NO_ORPHAN | MPLP_REALN;
-       while ((c = getopt(argc, argv, "gf:r:l:M:q:Q:uaORC:BDSd:b:P:o:e:h:I")) >= 0) {
+       while ((c = getopt(argc, argv, "Agf:r:l:M:q:Q:uaRC:BDSd:L:b:P:o:e:h:Im:F:EG:6")) >= 0) {
                switch (c) {
                case 'f':
                        mplp.fai = fai_load(optarg);
@@ -870,17 +895,18 @@ int bam_mpileup(int argc, char *argv[])
                        break;
                case 'd': mplp.max_depth = atoi(optarg); break;
                case 'r': mplp.reg = strdup(optarg); break;
-               case 'l': mplp.fn_pos = strdup(optarg); break;
+               case 'l': mplp.bed = bed_read(optarg); break;
                case 'P': mplp.pl_list = strdup(optarg); break;
                case 'g': mplp.flag |= MPLP_GLF; break;
                case 'u': mplp.flag |= MPLP_NO_COMP | MPLP_GLF; break;
                case 'a': mplp.flag |= MPLP_NO_ORPHAN | MPLP_REALN; break;
-               case 'B': mplp.flag &= ~MPLP_REALN & ~MPLP_NO_ORPHAN; break;
-               case 'O': mplp.flag |= MPLP_NO_ORPHAN; break;
+               case 'B': mplp.flag &= ~MPLP_REALN; break;
                case 'R': mplp.flag |= MPLP_REALN; break;
                case 'D': mplp.flag |= MPLP_FMT_DP; break;
                case 'S': mplp.flag |= MPLP_FMT_SP; break;
                case 'I': mplp.flag |= MPLP_NO_INDEL; break;
+               case 'E': mplp.flag |= MPLP_EXT_BAQ; break;
+               case '6': mplp.flag |= MPLP_ILLUMINA13; break;
                case 'C': mplp.capQ_thres = atoi(optarg); break;
                case 'M': mplp.max_mq = atoi(optarg); break;
                case 'q': mplp.min_mq = atoi(optarg); break;
@@ -889,43 +915,68 @@ int bam_mpileup(int argc, char *argv[])
                case 'o': mplp.openQ = atoi(optarg); break;
                case 'e': mplp.extQ = atoi(optarg); break;
                case 'h': mplp.tandemQ = atoi(optarg); break;
+               case 'A': use_orphan = 1; break;
+               case 'F': mplp.min_frac = atof(optarg); break;
+               case 'm': mplp.min_support = atoi(optarg); break;
+               case 'L': mplp.max_indel_depth = atoi(optarg); break;
+               case 'G': {
+                               FILE *fp_rg;
+                               char buf[1024];
+                               mplp.rghash = bcf_str2id_init();
+                               if ((fp_rg = fopen(optarg, "r")) == 0)
+                                       fprintf(pysamerr, "(%s) Fail to open file %s. Continue anyway.\n", __func__, optarg);
+                               while (!feof(fp_rg) && fscanf(fp_rg, "%s", buf) > 0) // this is not a good style, but forgive me...
+                                       bcf_str2id_add(mplp.rghash, strdup(buf));
+                               fclose(fp_rg);
+                       }
+                       break;
                }
        }
+       if (use_orphan) mplp.flag &= ~MPLP_NO_ORPHAN;
        if (argc == 1) {
                fprintf(pysamerr, "\n");
-               fprintf(pysamerr, "Usage:   samtools mpileup [options] in1.bam [in2.bam [...]]\n\n");
-               fprintf(pysamerr, "Options: -f FILE     reference sequence file [null]\n");
-               fprintf(pysamerr, "         -r STR      region in which pileup is generated [null]\n");
-               fprintf(pysamerr, "         -l FILE     list of positions (format: chr pos) [null]\n");
-               fprintf(pysamerr, "         -b FILE     list of input BAM files [null]\n");
-               fprintf(pysamerr, "         -M INT      cap mapping quality at INT [%d]\n", mplp.max_mq);
-               fprintf(pysamerr, "         -Q INT      min base quality [%d]\n", mplp.min_baseQ);
-               fprintf(pysamerr, "         -q INT      filter out alignment with MQ smaller than INT [%d]\n", mplp.min_mq);
-               fprintf(pysamerr, "         -d INT      max per-sample depth [%d]\n", mplp.max_depth);
-               fprintf(pysamerr, "         -P STR      comma separated list of platforms for indels [all]\n");
-               fprintf(pysamerr, "         -o INT      Phred-scaled gap open sequencing error probability [%d]\n", mplp.openQ);
-               fprintf(pysamerr, "         -e INT      Phred-scaled gap extension seq error probability [%d]\n", mplp.extQ);
-               fprintf(pysamerr, "         -h INT      coefficient for homopolyer errors [%d]\n", mplp.tandemQ);
-               fprintf(pysamerr, "         -g          generate BCF output\n");
-               fprintf(pysamerr, "         -u          do not compress BCF output\n");
-               fprintf(pysamerr, "         -B          disable BAQ computation\n");
-               fprintf(pysamerr, "         -D          output per-sample DP\n");
-               fprintf(pysamerr, "         -S          output per-sample SP (strand bias P-value, slow)\n");
-               fprintf(pysamerr, "         -I          do not perform indel calling\n");
+               fprintf(pysamerr, "Usage: samtools mpileup [options] in1.bam [in2.bam [...]]\n\n");
+               fprintf(pysamerr, "Input options:\n\n");
+               fprintf(pysamerr, "       -6           assume the quality is in the Illumina-1.3+ encoding\n");
+               fprintf(pysamerr, "       -A           count anomalous read pairs\n");
+               fprintf(pysamerr, "       -B           disable BAQ computation\n");
+               fprintf(pysamerr, "       -b FILE      list of input BAM files [null]\n");
+               fprintf(pysamerr, "       -d INT       max per-BAM depth to avoid excessive memory usage [%d]\n", mplp.max_depth);
+               fprintf(pysamerr, "       -E           extended BAQ for higher sensitivity but lower specificity\n");
+               fprintf(pysamerr, "       -f FILE      faidx indexed reference sequence file [null]\n");
+               fprintf(pysamerr, "       -G FILE      exclude read groups listed in FILE [null]\n");
+               fprintf(pysamerr, "       -l FILE      list of positions (chr pos) or regions (BED) [null]\n");
+               fprintf(pysamerr, "       -M INT       cap mapping quality at INT [%d]\n", mplp.max_mq);
+               fprintf(pysamerr, "       -r STR       region in which pileup is generated [null]\n");
+               fprintf(pysamerr, "       -q INT       skip alignments with mapQ smaller than INT [%d]\n", mplp.min_mq);
+               fprintf(pysamerr, "       -Q INT       skip bases with baseQ/BAQ smaller than INT [%d]\n", mplp.min_baseQ);
+               fprintf(pysamerr, "\nOutput options:\n\n");
+               fprintf(pysamerr, "       -D           output per-sample DP in BCF (require -g/-u)\n");
+               fprintf(pysamerr, "       -g           generate BCF output (genotype likelihoods)\n");
+               fprintf(pysamerr, "       -S           output per-sample strand bias P-value in BCF (require -g/-u)\n");
+               fprintf(pysamerr, "       -u           generate uncompress BCF output\n");
+               fprintf(pysamerr, "\nSNP/INDEL genotype likelihoods options (effective with `-g' or `-u'):\n\n");
+               fprintf(pysamerr, "       -e INT       Phred-scaled gap extension seq error probability [%d]\n", mplp.extQ);
+               fprintf(pysamerr, "       -F FLOAT     minimum fraction of gapped reads for candidates [%g]\n", mplp.min_frac);
+               fprintf(pysamerr, "       -h INT       coefficient for homopolymer errors [%d]\n", mplp.tandemQ);
+               fprintf(pysamerr, "       -I           do not perform indel calling\n");
+               fprintf(pysamerr, "       -L INT       max per-sample depth for INDEL calling [%d]\n", mplp.max_indel_depth);
+               fprintf(pysamerr, "       -m INT       minimum gapped reads for indel candidates [%d]\n", mplp.min_support);
+               fprintf(pysamerr, "       -o INT       Phred-scaled gap open sequencing error probability [%d]\n", mplp.openQ);
+               fprintf(pysamerr, "       -P STR       comma separated list of platforms for indels [all]\n");
                fprintf(pysamerr, "\n");
                fprintf(pysamerr, "Notes: Assuming diploid individuals.\n\n");
                return 1;
        }
-    if ( file_list )
-    {
+    if (file_list) {
         if ( read_file_list(file_list,&nfiles,&fn) ) return 1;
         mpileup(&mplp,nfiles,fn);
         for (c=0; c<nfiles; c++) free(fn[c]);
         free(fn);
-    }
-    else
-           mpileup(&mplp, argc - optind, argv + optind);
+    } else mpileup(&mplp, argc - optind, argv + optind);
+       if (mplp.rghash) bcf_str2id_thorough_destroy(mplp.rghash);
        free(mplp.reg); free(mplp.pl_list);
        if (mplp.fai) fai_destroy(mplp.fai);
+       if (mplp.bed) bed_destroy(mplp.bed);
        return 0;
 }
index fa81d059b38fbae695135ff9d0b9e9b9c909156d..8737edc74d3f6d468ba68217bd40b6c09a465201 100644 (file)
@@ -72,6 +72,8 @@ static void swap_header_text(bam_header_t *h1, bam_header_t *h2)
 
 #define MERGE_RG     1
 #define MERGE_UNCOMP 2
+#define MERGE_LEVEL1 4
+#define MERGE_FORCE  8
 
 /*!
   @abstract    Merge multiple sorted BAM.
@@ -204,16 +206,14 @@ int bam_merge_core(int by_qname, const char *out, const char *headers, int n, ch
                h->i = i;
                h->b = (bam1_t*)calloc(1, sizeof(bam1_t));
                if (bam_iter_read(fp[i], iter[i], h->b) >= 0) {
-                       h->pos = ((uint64_t)h->b->core.tid<<32) | (uint32_t)h->b->core.pos<<1 | bam1_strand(h->b);
+                       h->pos = ((uint64_t)h->b->core.tid<<32) | (uint32_t)((int32_t)h->b->core.pos+1)<<1 | bam1_strand(h->b);
                        h->idx = idx++;
                }
                else h->pos = HEAP_EMPTY;
        }
-       if (flag & MERGE_UNCOMP) {
-               fpout = strcmp(out, "-")? bam_open(out, "wu") : bam_dopen(fileno(stdout), "wu");
-       } else {
-               fpout = strcmp(out, "-")? bam_open(out, "w") : bam_dopen(fileno(stdout), "w");
-       }
+       if (flag & MERGE_UNCOMP) fpout = strcmp(out, "-")? bam_open(out, "wu") : bam_dopen(fileno(stdout), "wu");
+       else if (flag & MERGE_LEVEL1) fpout = strcmp(out, "-")? bam_open(out, "w1") : bam_dopen(fileno(stdout), "w1");
+       else fpout = strcmp(out, "-")? bam_open(out, "w") : bam_dopen(fileno(stdout), "w");
        if (fpout == 0) {
                fprintf(pysamerr, "[%s] fail to create the output file.\n", __func__);
                return -1;
@@ -224,11 +224,14 @@ int bam_merge_core(int by_qname, const char *out, const char *headers, int n, ch
        ks_heapmake(heap, n, heap);
        while (heap->pos != HEAP_EMPTY) {
                bam1_t *b = heap->b;
-               if ((flag & MERGE_RG) && bam_aux_get(b, "RG") == 0)
+               if (flag & MERGE_RG) {
+                       uint8_t *rg = bam_aux_get(b, "RG");
+                       if (rg) bam_aux_del(b, rg);
                        bam_aux_append(b, "RG", 'Z', RG_len[heap->i] + 1, (uint8_t*)RG[heap->i]);
+               }
                bam_write1_core(fpout, &b->core, b->data_len, b->data);
                if ((j = bam_iter_read(fp[heap->i], iter[heap->i], b)) >= 0) {
-                       heap->pos = ((uint64_t)b->core.tid<<32) | (uint32_t)b->core.pos<<1 | bam1_strand(b);
+                       heap->pos = ((uint64_t)b->core.tid<<32) | (uint32_t)((int)b->core.pos+1)<<1 | bam1_strand(b);
                        heap->idx = idx++;
                } else if (j == -1) {
                        heap->pos = HEAP_EMPTY;
@@ -256,11 +259,13 @@ int bam_merge(int argc, char *argv[])
        int c, is_by_qname = 0, flag = 0, ret = 0;
        char *fn_headers = NULL, *reg = 0;
 
-       while ((c = getopt(argc, argv, "h:nruR:")) >= 0) {
+       while ((c = getopt(argc, argv, "h:nru1R:f")) >= 0) {
                switch (c) {
                case 'r': flag |= MERGE_RG; break;
+               case 'f': flag |= MERGE_FORCE; break;
                case 'h': fn_headers = strdup(optarg); break;
                case 'n': is_by_qname = 1; break;
+               case '1': flag |= MERGE_LEVEL1; break;
                case 'u': flag |= MERGE_UNCOMP; break;
                case 'R': reg = strdup(optarg); break;
                }
@@ -271,6 +276,8 @@ int bam_merge(int argc, char *argv[])
                fprintf(pysamerr, "Options: -n       sort by read names\n");
                fprintf(pysamerr, "         -r       attach RG tag (inferred from file names)\n");
                fprintf(pysamerr, "         -u       uncompressed BAM output\n");
+               fprintf(pysamerr, "         -f       overwrite the output BAM if exist\n");
+               fprintf(pysamerr, "         -1       compress level 1\n");
                fprintf(pysamerr, "         -R STR   merge file in the specified region STR [all]\n");
                fprintf(pysamerr, "         -h FILE  copy the header in FILE to <out.bam> [in1.bam]\n\n");
                fprintf(pysamerr, "Note: Samtools' merge does not reconstruct the @RG dictionary in the header. Users\n");
@@ -278,6 +285,14 @@ int bam_merge(int argc, char *argv[])
                fprintf(pysamerr, "      the header dictionary in merging.\n\n");
                return 1;
        }
+       if (!(flag & MERGE_FORCE) && strcmp(argv[optind], "-")) {
+               FILE *fp = fopen(argv[optind], "rb");
+               if (fp != NULL) {
+                       fclose(fp);
+                       fprintf(pysamerr, "[%s] File '%s' exists. Please apply '-f' to overwrite. Abort.\n", __func__, argv[optind]);
+                       return 1;
+               }
+       }
        if (bam_merge_core(is_by_qname, argv[optind], fn_headers, argc - optind - 1, argv + optind + 1, flag, reg) < 0) ret = 1;
        free(reg);
        free(fn_headers);
@@ -290,21 +305,26 @@ static inline int bam1_lt(const bam1_p a, const bam1_p b)
 {
        if (g_is_by_qname) {
                int t = strnum_cmp(bam1_qname(a), bam1_qname(b));
-               return (t < 0 || (t == 0 && (((uint64_t)a->core.tid<<32|a->core.pos) < ((uint64_t)b->core.tid<<32|b->core.pos))));
-       } else return (((uint64_t)a->core.tid<<32|a->core.pos) < ((uint64_t)b->core.tid<<32|b->core.pos));
+               return (t < 0 || (t == 0 && (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)))));
+       } else return (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)));
 }
 KSORT_INIT(sort, bam1_p, bam1_lt)
 
 static void sort_blocks(int n, int k, bam1_p *buf, const char *prefix, const bam_header_t *h, int is_stdout)
 {
-       char *name;
+       char *name, mode[3];
        int i;
        bamFile fp;
        ks_mergesort(sort, k, buf, 0);
        name = (char*)calloc(strlen(prefix) + 20, 1);
-       if (n >= 0) sprintf(name, "%s.%.4d.bam", prefix, n);
-       else sprintf(name, "%s.bam", prefix);
-       fp = is_stdout? bam_dopen(fileno(stdout), "w") : bam_open(name, "w");
+       if (n >= 0) {
+               sprintf(name, "%s.%.4d.bam", prefix, n);
+               strcpy(mode, "w1");
+       } else {
+               sprintf(name, "%s.bam", prefix);
+               strcpy(mode, "w");
+       }
+       fp = is_stdout? bam_dopen(fileno(stdout), mode) : bam_open(name, mode);
        if (fp == 0) {
                fprintf(pysamerr, "[sort_blocks] fail to create file %s.\n", name);
                free(name);
index 4d89ed8136de09b2973850074fb50b7dc911f6a9..4751782ce8e526c28adf00e85bbe1557e299348d 100644 (file)
@@ -5,31 +5,31 @@
 #include "bam.h"
 
 typedef struct {
-       long long n_reads, n_mapped, n_pair_all, n_pair_map, n_pair_good;
-       long long n_sgltn, n_read1, n_read2;
-       long long n_qcfail, n_dup;
-       long long n_diffchr, n_diffhigh;
+       long long n_reads[2], n_mapped[2], n_pair_all[2], n_pair_map[2], n_pair_good[2];
+       long long n_sgltn[2], n_read1[2], n_read2[2];
+       long long n_dup[2];
+       long long n_diffchr[2], n_diffhigh[2];
 } bam_flagstat_t;
 
 #define flagstat_loop(s, c) do {                                                                               \
-               ++(s)->n_reads;                                                                                                 \
+               int w = ((c)->flag & BAM_FQCFAIL)? 1 : 0;                                               \
+               ++(s)->n_reads[w];                                                                                              \
                if ((c)->flag & BAM_FPAIRED) {                                                                  \
-                       ++(s)->n_pair_all;                                                                                      \
-                       if ((c)->flag & BAM_FPROPER_PAIR) ++(s)->n_pair_good;           \
-                       if ((c)->flag & BAM_FREAD1) ++(s)->n_read1;                                     \
-                       if ((c)->flag & BAM_FREAD2) ++(s)->n_read2;                                     \
-                       if (((c)->flag & BAM_FMUNMAP) && !((c)->flag & BAM_FUNMAP)) ++(s)->n_sgltn;     \
+                       ++(s)->n_pair_all[w];                                                                           \
+                       if ((c)->flag & BAM_FPROPER_PAIR) ++(s)->n_pair_good[w];        \
+                       if ((c)->flag & BAM_FREAD1) ++(s)->n_read1[w];                          \
+                       if ((c)->flag & BAM_FREAD2) ++(s)->n_read2[w];                          \
+                       if (((c)->flag & BAM_FMUNMAP) && !((c)->flag & BAM_FUNMAP)) ++(s)->n_sgltn[w];  \
                        if (!((c)->flag & BAM_FUNMAP) && !((c)->flag & BAM_FMUNMAP)) { \
-                               ++(s)->n_pair_map;                                                                              \
+                               ++(s)->n_pair_map[w];                                                                   \
                                if ((c)->mtid != (c)->tid) {                                                    \
-                                       ++(s)->n_diffchr;                                                                       \
-                                       if ((c)->qual >= 5) ++(s)->n_diffhigh;                          \
+                                       ++(s)->n_diffchr[w];                                                            \
+                                       if ((c)->qual >= 5) ++(s)->n_diffhigh[w];                       \
                                }                                                                                                               \
                        }                                                                                                                       \
                }                                                                                                                               \
-               if (!((c)->flag & BAM_FUNMAP)) ++(s)->n_mapped;                                 \
-               if ((c)->flag & BAM_FQCFAIL) ++(s)->n_qcfail;                                   \
-               if ((c)->flag & BAM_FDUP) ++(s)->n_dup;                                                 \
+               if (!((c)->flag & BAM_FUNMAP)) ++(s)->n_mapped[w];                              \
+               if ((c)->flag & BAM_FDUP) ++(s)->n_dup[w];                                              \
        } while (0)
 
 bam_flagstat_t *bam_flagstat_core(bamFile fp)
@@ -61,18 +61,17 @@ int bam_flagstat(int argc, char *argv[])
        assert(fp);
        header = bam_header_read(fp);
        s = bam_flagstat_core(fp);
-       printf("%lld in total\n", s->n_reads);
-       printf("%lld QC failure\n", s->n_qcfail);
-       printf("%lld duplicates\n", s->n_dup);
-       printf("%lld mapped (%.2f%%)\n", s->n_mapped, (float)s->n_mapped / s->n_reads * 100.0);
-       printf("%lld paired in sequencing\n", s->n_pair_all);
-       printf("%lld read1\n", s->n_read1);
-       printf("%lld read2\n", s->n_read2);
-       printf("%lld properly paired (%.2f%%)\n", s->n_pair_good, (float)s->n_pair_good / s->n_pair_all * 100.0);
-       printf("%lld with itself and mate mapped\n", s->n_pair_map);
-       printf("%lld singletons (%.2f%%)\n", s->n_sgltn, (float)s->n_sgltn / s->n_pair_all * 100.0);
-       printf("%lld with mate mapped to a different chr\n", s->n_diffchr);
-       printf("%lld with mate mapped to a different chr (mapQ>=5)\n", s->n_diffhigh);
+       printf("%lld + %lld in total (QC-passed reads + QC-failed reads)\n", s->n_reads[0], s->n_reads[1]);
+       printf("%lld + %lld duplicates\n", s->n_dup[0], s->n_dup[1]);
+       printf("%lld + %lld mapped (%.2f%%:%.2f%%)\n", s->n_mapped[0], s->n_mapped[1], (float)s->n_mapped[0] / s->n_reads[0] * 100.0, (float)s->n_mapped[1] / s->n_reads[1] * 100.0);
+       printf("%lld + %lld paired in sequencing\n", s->n_pair_all[0], s->n_pair_all[1]);
+       printf("%lld + %lld read1\n", s->n_read1[0], s->n_read1[1]);
+       printf("%lld + %lld read2\n", s->n_read2[0], s->n_read2[1]);
+       printf("%lld + %lld properly paired (%.2f%%:%.2f%%)\n", s->n_pair_good[0], s->n_pair_good[1], (float)s->n_pair_good[0] / s->n_pair_all[0] * 100.0, (float)s->n_pair_good[1] / s->n_pair_all[1] * 100.0);
+       printf("%lld + %lld with itself and mate mapped\n", s->n_pair_map[0], s->n_pair_map[1]);
+       printf("%lld + %lld singletons (%.2f%%:%.2f%%)\n", s->n_sgltn[0], s->n_sgltn[1], (float)s->n_sgltn[0] / s->n_pair_all[0] * 100.0, (float)s->n_sgltn[1] / s->n_pair_all[1] * 100.0);
+       printf("%lld + %lld with mate mapped to a different chr\n", s->n_diffchr[0], s->n_diffchr[1]);
+       printf("%lld + %lld with mate mapped to a different chr (mapQ>=5)\n", s->n_diffhigh[0], s->n_diffhigh[1]);
        free(s);
        bam_header_destroy(header);
        bam_close(fp);
index 6e0276253e0cd61cfd0943eef82b708a7f70f329..d4abf671f143fe803c9919ecf6dc7c85b1a7e01a 100644 (file)
@@ -185,12 +185,12 @@ tview_t *tv_init(const char *fn, const char *fn_fa)
 {
        tview_t *tv = (tview_t*)calloc(1, sizeof(tview_t));
        tv->is_dot = 1;
-       tv->idx = bam_index_load(fn);
-       if (tv->idx == 0) exit(1);
        tv->fp = bam_open(fn, "r");
        bgzf_set_cache_size(tv->fp, 8 * 1024 *1024);
        assert(tv->fp);
        tv->header = bam_header_read(tv->fp);
+       tv->idx = bam_index_load(fn);
+       if (tv->idx == 0) exit(1);
        tv->lplbuf = bam_lplbuf_init(tv_pl_func, tv);
        if (fn_fa) tv->fai = fai_load(fn_fa);
        tv->bmc = bam_maqcns_init();
index 14307c93d85d3b2add9fe60b7ff7f6f0f76fc46c..e1c823d25030df88f138b1eae7dcf6c874654c41 100644 (file)
@@ -105,10 +105,16 @@ int bcf_sync(bcf1_t *b)
        ks_tokaux_t aux;
        // set ref, alt, flt, info, fmt
        b->ref = b->alt = b->flt = b->info = b->fmt = 0;
-       for (p = b->str, n = 0; p < b->str + b->l_str; ++p)
-               if (*p == 0 && p+1 != b->str + b->l_str) tmp[n++] = p + 1;
+       for (p = b->str, n = 0; p < b->str + b->l_str; ++p) {
+               if (*p == 0 && p+1 != b->str + b->l_str) {
+                       if (n == 5) {
+                               ++n;
+                               break;
+                       } else tmp[n++] = p + 1;
+               }
+       }
        if (n != 5) {
-               fprintf(pysamerr, "[%s] incorrect number of fields (%d != 5). Corrupted file?\n", __func__, n);
+               fprintf(pysamerr, "[%s] incorrect number of fields (%d != 5) at %d:%d\n", __func__, n, b->tid, b->pos);
                return -1;
        }
        b->ref = tmp[0]; b->alt = tmp[1]; b->flt = tmp[2]; b->info = tmp[3]; b->fmt = tmp[4];
@@ -138,10 +144,10 @@ int bcf_sync(bcf1_t *b)
                        b->gi[i].len = b->n_alleles * (b->n_alleles + 1) / 2;
                } else if (b->gi[i].fmt == bcf_str2int("DP", 2) || b->gi[i].fmt == bcf_str2int("HQ", 2)) {
                        b->gi[i].len = 2;
-               } else if (b->gi[i].fmt == bcf_str2int("GQ", 2) || b->gi[i].fmt == bcf_str2int("GT", 2)
-                                  || b->gi[i].fmt == bcf_str2int("SP", 2))
-               {
+               } else if (b->gi[i].fmt == bcf_str2int("GQ", 2) || b->gi[i].fmt == bcf_str2int("GT", 2)) {
                        b->gi[i].len = 1;
+               } else if (b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                       b->gi[i].len = 4;
                } else if (b->gi[i].fmt == bcf_str2int("GL", 2)) {
                        b->gi[i].len = b->n_alleles * (b->n_alleles + 1) / 2 * 4;
                }
@@ -242,8 +248,10 @@ void bcf_fmt_core(const bcf_hdr_t *h, bcf1_t *b, kstring_t *s)
                                }
                        } else if (b->gi[i].fmt == bcf_str2int("DP", 2)) {
                                kputw(((uint16_t*)b->gi[i].data)[j], s);
-                       } else if (b->gi[i].fmt == bcf_str2int("GQ", 2) || b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                       } else if (b->gi[i].fmt == bcf_str2int("GQ", 2)) {
                                kputw(((uint8_t*)b->gi[i].data)[j], s);
+                       } else if (b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                               kputw(((int32_t*)b->gi[i].data)[j], s);
                        } else if (b->gi[i].fmt == bcf_str2int("GT", 2)) {
                                int y = ((uint8_t*)b->gi[i].data)[j];
                                if (y>>7&1) {
@@ -261,7 +269,7 @@ void bcf_fmt_core(const bcf_hdr_t *h, bcf1_t *b, kstring_t *s)
                                        if (k > 0) kputc(',', s);
                                        ksprintf(s, "%.2f", d[k]);
                                }
-                       }
+                       } else kputc('.', s); // custom fields
                }
        }
 }
index f87ac1e6fa3021964753f051a944fdc95a59549d..ba6dbe9b42ae033c6b3c179a730a48312cf927dd 100644 (file)
@@ -129,6 +129,8 @@ extern "C" {
        int vcf_close(bcf_t *bp);
        // read the VCF/BCF header
        bcf_hdr_t *vcf_hdr_read(bcf_t *bp);
+       // read the sequence dictionary from a separate file; required for VCF->BCF conversion
+       int vcf_dictread(bcf_t *bp, bcf_hdr_t *h, const char *fn);
        // read a VCF/BCF record; return -1 on end-of-file and <-1 for errors
        int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b);
        // write the VCF header
@@ -142,10 +144,17 @@ extern "C" {
        int bcf_gl2pl(bcf1_t *b);
        // if the site is an indel
        int bcf_is_indel(const bcf1_t *b);
+       bcf_hdr_t *bcf_hdr_subsam(const bcf_hdr_t *h0, int n, char *const* samples, int *list);
+       int bcf_subsam(int n_smpl, int *list, bcf1_t *b);
+       // move GT to the first FORMAT field
+       int bcf_fix_gt(bcf1_t *b);
+       // update PL generated by old samtools
+       int bcf_fix_pl(bcf1_t *b);
 
        // string hash table
        void *bcf_build_refhash(bcf_hdr_t *h);
        void bcf_str2id_destroy(void *_hash);
+       void bcf_str2id_thorough_destroy(void *_hash);
        int bcf_str2id_add(void *_hash, const char *str);
        int bcf_str2id(void *_hash, const char *str);
        void *bcf_str2id_init();
index e512a5592ec6c1e25546954917877cef031786b4..6dc7e0ca06dc323312c16334721cc1e674d25983 100644 (file)
@@ -79,8 +79,8 @@ int bcf_2qcall(bcf_hdr_t *h, bcf1_t *b)
                for (k = j = 0; k < 4; ++k) {
                        for (l = k; l < 4; ++l) {
                                int t, x = map[k], y = map[l];
-                               if (x > y) t = x, x = y, y = t;
-                               g[j++] = p[x * b->n_alleles - x * (x-1) / 2 + (y - x)];
+                               if (x > y) t = x, x = y, y = t; // swap
+                               g[j++] = p[y * (y+1) / 2 + x];
                        }
                }
                printf("%s\t%d\t%c", h->ns[b->tid], b->pos+1, *b->ref);
index edacdb49c2689839f55e05850ae8ea54a311bf67..c48ab03c29cbcbd08c84f3cfd13ae1f8b1d81678 100644 (file)
@@ -1,5 +1,7 @@
 #include "pysam.h"
 
+#include <string.h>
+#include <math.h>
 #include "bcf.h"
 #include "kstring.h"
 #include "khash.h"
@@ -29,6 +31,16 @@ void bcf_str2id_destroy(void *_hash)
        if (hash) kh_destroy(str2id, hash); // Note that strings are not freed.
 }
 
+void bcf_str2id_thorough_destroy(void *_hash)
+{
+       khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
+       khint_t k;
+       if (hash == 0) return;
+       for (k = 0; k < kh_end(hash); ++k)
+               if (kh_exist(hash, k)) free((char*)kh_key(hash, k));
+       kh_destroy(str2id, hash);
+}
+
 int bcf_str2id(void *_hash, const char *str)
 {
        khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
@@ -53,8 +65,9 @@ int bcf_str2id_add(void *_hash, const char *str)
 int bcf_shrink_alt(bcf1_t *b, int n)
 {
        char *p;
-       int i, j, k, *z, n_smpl = b->n_smpl;
+       int i, j, k, n_smpl = b->n_smpl;
        if (b->n_alleles <= n) return -1;
+       // update ALT
        if (n > 1) {
                for (p = b->alt, k = 1; *p; ++p)
                        if (*p == ',' && ++k == n) break;
@@ -63,10 +76,7 @@ int bcf_shrink_alt(bcf1_t *b, int n)
        ++p;
        memmove(p, b->flt, b->str + b->l_str - b->flt);
        b->l_str -= b->flt - p;
-       z = alloca(sizeof(int) / 2 * n * (n+1));
-       for (i = k = 0; i < n; ++i)
-               for (j = 0; j < n - i; ++j)
-                       z[k++] = i * b->n_alleles + j;
+       // update PL
        for (i = 0; i < b->n_gi; ++i) {
                bcf_ginfo_t *g = b->gi + i;
                if (g->fmt == bcf_str2int("PL", 2)) {
@@ -75,7 +85,7 @@ int bcf_shrink_alt(bcf1_t *b, int n)
                        g->len = n * (n + 1) / 2;
                        for (l = k = 0; l < n_smpl; ++l) {
                                uint8_t *dl = d + l * x;
-                               for (j = 0; j < g->len; ++j) d[k++] = dl[z[j]];
+                               for (j = 0; j < g->len; ++j) d[k++] = dl[j];
                        }
                } // FIXME: to add GL
        }
@@ -109,3 +119,194 @@ int bcf_gl2pl(bcf1_t *b)
        }
        return 0;
 }
+/* FIXME: this function will fail given AB:GTX:GT. BCFtools never
+ * produces such FMT, but others may do. */
+int bcf_fix_gt(bcf1_t *b)
+{
+       char *s;
+       int i;
+       uint32_t tmp;
+       bcf_ginfo_t gt;
+       // check the presence of the GT FMT
+       if ((s = strstr(b->fmt, ":GT")) == 0) return 0; // no GT or GT is already the first
+       if (s[3] != '\0' && s[3] != ':') return 0; // :GTX in fact
+       tmp = bcf_str2int("GT", 2);
+       for (i = 0; i < b->n_gi; ++i)
+               if (b->gi[i].fmt == tmp) break;
+       if (i == b->n_gi) return 0; // no GT in b->gi; probably a bug...
+       gt = b->gi[i];
+       // move GT to the first
+       for (; i > 0; --i) b->gi[i] = b->gi[i-1];
+       b->gi[0] = gt;
+       memmove(b->fmt + 3, b->fmt, s + 1 - b->fmt);
+       b->fmt[0] = 'G'; b->fmt[1] = 'T'; b->fmt[2] = ':';
+       return 0;
+}
+
+int bcf_fix_pl(bcf1_t *b)
+{
+       int i;
+       uint32_t tmp;
+       uint8_t *PL, *swap;
+       bcf_ginfo_t *gi;
+       // pinpoint PL
+       tmp = bcf_str2int("PL", 2);
+       for (i = 0; i < b->n_gi; ++i)
+               if (b->gi[i].fmt == tmp) break;
+       if (i == b->n_gi) return 0;
+       // prepare
+       gi = b->gi + i;
+       PL = (uint8_t*)gi->data;
+       swap = alloca(gi->len);
+       // loop through individuals
+       for (i = 0; i < b->n_smpl; ++i) {
+               int k, l, x;
+               uint8_t *PLi = PL + i * gi->len;
+               memcpy(swap, PLi, gi->len);
+               for (k = x = 0; k < b->n_alleles; ++k)
+                       for (l = k; l < b->n_alleles; ++l)
+                               PLi[l*(l+1)/2 + k] = swap[x++];
+       }
+       return 0;
+}
+
+int bcf_smpl_covered(const bcf1_t *b)
+{
+       int i, j, n = 0;
+       uint32_t tmp;
+       bcf_ginfo_t *gi;
+       // pinpoint PL
+       tmp = bcf_str2int("PL", 2);
+       for (i = 0; i < b->n_gi; ++i)
+               if (b->gi[i].fmt == tmp) break;
+       if (i == b->n_gi) return 0;
+       // count how many samples having PL!=[0..0]
+       gi = b->gi + i;
+       for (i = 0; i < b->n_smpl; ++i) {
+               uint8_t *PLi = ((uint8_t*)gi->data) + i * gi->len;
+               for (j = 0; j < gi->len; ++j)
+                       if (PLi[j]) break;
+               if (j < gi->len) ++n;
+       }
+       return n;
+}
+
+static void *locate_field(const bcf1_t *b, const char *fmt, int l)
+{
+       int i;
+       uint32_t tmp;
+       tmp = bcf_str2int(fmt, l);
+       for (i = 0; i < b->n_gi; ++i)
+               if (b->gi[i].fmt == tmp) break;
+       return i == b->n_gi? 0 : b->gi[i].data;
+}
+
+int bcf_anno_max(bcf1_t *b)
+{
+       int k, max_gq, max_sp, n_het;
+       kstring_t str;
+       uint8_t *gt, *gq;
+       int32_t *sp;
+       max_gq = max_sp = n_het = 0;
+       gt = locate_field(b, "GT", 2);
+       if (gt == 0) return -1;
+       gq = locate_field(b, "GQ", 2);
+       sp = locate_field(b, "SP", 2);
+       if (sp)
+               for (k = 0; k < b->n_smpl; ++k)
+                       if (gt[k]&0x3f)
+                               max_sp = max_sp > (int)sp[k]? max_sp : sp[k];
+       if (gq)
+               for (k = 0; k < b->n_smpl; ++k)
+                       if (gt[k]&0x3f)
+                               max_gq = max_gq > (int)gq[k]? max_gq : gq[k];
+       for (k = 0; k < b->n_smpl; ++k) {
+               int a1, a2;
+               a1 = gt[k]&7; a2 = gt[k]>>3&7;
+               if ((!a1 && a2) || (!a2 && a1)) { // a het
+                       if (gq == 0) ++n_het;
+                       else if (gq[k] >= 20) ++n_het;
+               }
+       }
+       if (n_het) max_sp -= (int)(4.343 * log(n_het) + .499);
+       if (max_sp < 0) max_sp = 0;
+       memset(&str, 0, sizeof(kstring_t));
+       if (*b->info) kputc(';', &str);
+       ksprintf(&str, "MXSP=%d;MXGQ=%d", max_sp, max_gq);
+       bcf_append_info(b, str.s, str.l);
+       free(str.s);
+       return 0;
+}
+
+// FIXME: only data are shuffled; the header is NOT
+int bcf_shuffle(bcf1_t *b, int seed)
+{
+       int i, j, *a;
+       if (seed > 0) srand48(seed);
+       a = malloc(b->n_smpl * sizeof(int));
+       for (i = 0; i < b->n_smpl; ++i) a[i] = i;
+       for (i = b->n_smpl; i > 1; --i) {
+               int tmp;
+               j = (int)(drand48() * i);
+               tmp = a[j]; a[j] = a[i-1]; a[i-1] = tmp;
+       }
+       for (j = 0; j < b->n_gi; ++j) {
+               bcf_ginfo_t *gi = b->gi + j;
+               uint8_t *swap, *data = (uint8_t*)gi->data;
+               swap = malloc(gi->len * b->n_smpl);
+               for (i = 0; i < b->n_smpl; ++i)
+                       memcpy(swap + gi->len * a[i], data + gi->len * i, gi->len);
+               free(gi->data);
+               gi->data = swap;
+       }
+       free(a);
+       return 0;
+}
+
+bcf_hdr_t *bcf_hdr_subsam(const bcf_hdr_t *h0, int n, char *const* samples, int *list)
+{
+       int i, ret, j;
+       khint_t k;
+       bcf_hdr_t *h;
+       khash_t(str2id) *hash;
+       kstring_t s;
+       s.l = s.m = 0; s.s = 0;
+       hash = kh_init(str2id);
+       for (i = 0; i < h0->n_smpl; ++i) {
+               k = kh_put(str2id, hash, h0->sns[i], &ret);
+               kh_val(hash, k) = i;
+       }
+       for (i = j = 0; i < n; ++i) {
+               k = kh_get(str2id, hash, samples[i]);
+               if (k != kh_end(hash)) {
+                       list[j++] = kh_val(hash, k);
+                       kputs(samples[i], &s); kputc('\0', &s);
+               }
+       }
+       if (j < n) fprintf(pysamerr, "<%s> %d samples in the list but not in BCF.", __func__, n - j);
+       kh_destroy(str2id, hash);
+       h = calloc(1, sizeof(bcf_hdr_t));
+       *h = *h0;
+       h->ns = 0; h->sns = 0;
+       h->name = malloc(h->l_nm); memcpy(h->name, h0->name, h->l_nm);
+       h->txt = calloc(1, h->l_txt + 1); memcpy(h->txt, h0->txt, h->l_txt);
+       h->l_smpl = s.l; h->sname = s.s;
+       bcf_hdr_sync(h);
+       return h;
+}
+
+int bcf_subsam(int n_smpl, int *list, bcf1_t *b)
+{
+       int i, j;
+       for (j = 0; j < b->n_gi; ++j) {
+               bcf_ginfo_t *gi = b->gi + j;
+               uint8_t *swap;
+               swap = malloc(gi->len * b->n_smpl);
+               for (i = 0; i < n_smpl; ++i)
+                       memcpy(swap + i * gi->len, (uint8_t*)gi->data + list[i] * gi->len, gi->len);
+               free(gi->data);
+               gi->data = swap;
+       }
+       b->n_smpl = n_smpl;
+       return 0;
+}
index 2e21fe554b33138e7b177a8f6edb4d6f0cbfb0ca..378c3d5bb4be6f697b9c0d90cb777353a51b4d5c 100644 (file)
@@ -8,9 +8,7 @@
 #include "bcf.h"
 #include "prob1.h"
 #include "kstring.h"
-
-#include "khash.h"
-KHASH_SET_INIT_INT64(set64)
+#include "time.h"
 
 #include "kseq.h"
 KSTREAM_INIT(gzFile, gzread, 16384)
@@ -21,70 +19,27 @@ KSTREAM_INIT(gzFile, gzread, 16384)
 #define VC_VARONLY 16
 #define VC_VCFIN   32
 #define VC_UNCOMP  64
-#define VC_HWE     128
 #define VC_KEEPALT 256
 #define VC_ACGT_ONLY 512
 #define VC_QCALL   1024
 #define VC_CALL_GT 2048
 #define VC_ADJLD   4096
 #define VC_NO_INDEL 8192
-#define VC_FOLDED 16384
+#define VC_ANNO_MAX 16384
+#define VC_FIX_PL   32768
+#define VC_EM       0x10000
 
 typedef struct {
-       int flag, prior_type, n1;
-       char *fn_list, *prior_file;
-       double theta, pref, indel_frac;
+       int flag, prior_type, n1, n_sub, *sublist, n_perm;
+       char *prior_file, **subsam, *fn_dict;
+       uint8_t *ploidy;
+       double theta, pref, indel_frac, min_perm_p, min_smpl_frac, min_lrt;
+       void *bed;
 } viewconf_t;
 
-khash_t(set64) *bcf_load_pos(const char *fn, bcf_hdr_t *_h)
-{
-       void *str2id;
-       gzFile fp;
-       kstream_t *ks;
-       int ret, dret, lineno = 1;
-       kstring_t *str;
-       khash_t(set64) *hash = 0;
-
-       hash = kh_init(set64);
-       str2id = bcf_build_refhash(_h);
-       str = calloc(1, sizeof(kstring_t));
-       fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
-       ks = ks_init(fp);
-       while (ks_getuntil(ks, 0, str, &dret) >= 0) {
-               int tid = bcf_str2id(str2id, str->s);
-               if (tid >= 0 && dret != '\n') {
-                       if (ks_getuntil(ks, 0, str, &dret) >= 0) {
-                               uint64_t x = (uint64_t)tid<<32 | (atoi(str->s) - 1);
-                               kh_put(set64, hash, x, &ret);
-                       } else break;
-               } else fprintf(pysamerr, "[%s] %s is not a reference name (line %d).\n", __func__, str->s, lineno);
-               if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n');
-               if (dret < 0) break;
-               ++lineno;
-       }
-       bcf_str2id_destroy(str2id);
-       ks_destroy(ks);
-       gzclose(fp);
-       free(str->s); free(str);
-       return hash;
-}
-
-static double test_hwe(const double g[3])
-{
-       extern double kf_gammaq(double p, double x);
-       double fexp, chi2, f[3], n;
-       int i;
-       n = g[0] + g[1] + g[2];
-       fexp = (2. * g[2] + g[1]) / (2. * n);
-       if (fexp > 1. - 1e-10) fexp = 1. - 1e-10;
-       if (fexp < 1e-10) fexp = 1e-10;
-       f[0] = n * (1. - fexp) * (1. - fexp);
-       f[1] = n * 2. * fexp * (1. - fexp);
-       f[2] = n * fexp * fexp;
-       for (i = 0, chi2 = 0.; i < 3; ++i)
-               chi2 += (g[i] - f[i]) * (g[i] - f[i]) / f[i];
-       return kf_gammaq(.5, chi2 / 2.);
-}
+void *bed_read(const char *fn);
+void bed_destroy(void *_h);
+int bed_overlap(const void *_h, const char *chr, int beg, int end);
 
 typedef struct {
        double p[4];
@@ -149,37 +104,61 @@ static void rm_info(bcf1_t *b, const char *key)
        bcf_sync(b);
 }
 
-static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p1rst_t *pr, double pref, int flag)
+static int update_bcf1(bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p1rst_t *pr, double pref, int flag, double em[9])
 {
        kstring_t s;
-       int is_var = (pr->p_ref < pref);
-       double p_hwe, r = is_var? pr->p_ref : 1. - pr->p_ref;
+       int has_I16, is_var;
+       double fq, r;
        anno16_t a;
 
-       p_hwe = pr->g[0] >= 0.? test_hwe(pr->g) : 1.0; // only do HWE g[] is calculated
-       test16(b, &a);
-       rm_info(b, "I16=");
+       has_I16 = test16(b, &a) >= 0? 1 : 0;
+       rm_info(b, "I16="); // FIXME: probably this function has a bug. If I move it below, I16 will not be removed!
 
        memset(&s, 0, sizeof(kstring_t));
        kputc('\0', &s); kputs(b->ref, &s); kputc('\0', &s);
        kputs(b->alt, &s); kputc('\0', &s); kputc('\0', &s);
        kputs(b->info, &s);
        if (b->info[0]) kputc(';', &s);
-//     ksprintf(&s, "AF1=%.4lg;AFE=%.4lg;CI95=%.4lg,%.4lg", 1.-pr->f_em, 1.-pr->f_exp, pr->cil, pr->cih);
-       ksprintf(&s, "AF1=%.4lg;CI95=%.4lg,%.4lg", 1.-pr->f_em, pr->cil, pr->cih);
-       ksprintf(&s, ";DP4=%d,%d,%d,%d;MQ=%d", a.d[0], a.d[1], a.d[2], a.d[3], a.mq);
-       if (a.is_tested) {
-               if (pr->pc[0] >= 0.) ksprintf(&s, ";PC4=%lg,%lg,%lg,%lg", pr->pc[0], pr->pc[1], pr->pc[2], pr->pc[3]);
-               ksprintf(&s, ";PV4=%.2lg,%.2lg,%.2lg,%.2lg", a.p[0], a.p[1], a.p[2], a.p[3]);
+       { // print EM
+               if (em[0] >= 0) ksprintf(&s, "AF1=%.4g", 1 - em[0]);
+               if (em[4] >= 0 && em[4] <= 0.05) ksprintf(&s, ";G3=%.4g,%.4g,%.4g;HWE=%.3g", em[3], em[2], em[1], em[4]);
+               if (em[5] >= 0 && em[6] >= 0) ksprintf(&s, ";AF2=%.4g,%.4g", 1 - em[5], 1 - em[6]);
+               if (em[7] >= 0) ksprintf(&s, ";LRT=%.3g", em[7]);
        }
-       if (pr->g[0] >= 0. && p_hwe <= .2)
-               ksprintf(&s, ";GC=%.2lf,%.2lf,%.2lf;HWE=%.3lf", pr->g[2], pr->g[1], pr->g[0], p_hwe);
+       if (pr == 0) { // if pr is unset, return
+               kputc('\0', &s); kputs(b->fmt, &s); kputc('\0', &s);
+               free(b->str);
+               b->m_str = s.m; b->l_str = s.l; b->str = s.s;
+               bcf_sync(b);
+               return 1;
+       }
+
+       is_var = (pr->p_ref < pref);
+       r = is_var? pr->p_ref : pr->p_var;
+
+       ksprintf(&s, ";CI95=%.4g,%.4g", pr->cil, pr->cih); // FIXME: when EM is not used, ";" should be omitted!
+       if (has_I16) ksprintf(&s, ";DP4=%d,%d,%d,%d;MQ=%d", a.d[0], a.d[1], a.d[2], a.d[3], a.mq);
+       fq = pr->p_ref_folded < 0.5? -4.343 * log(pr->p_ref_folded) : 4.343 * log(pr->p_var_folded);
+       if (fq < -999) fq = -999;
+       if (fq > 999) fq = 999;
+       ksprintf(&s, ";FQ=%.3g", fq);
+       if (pr->cmp[0] >= 0.) { // two sample groups
+               int i, q[3];
+               for (i = 1; i < 3; ++i) {
+                       double x = pr->cmp[i] + pr->cmp[0]/2.;
+                       q[i] = x == 0? 255 : (int)(-4.343 * log(x) + .499);
+                       if (q[i] > 255) q[i] = 255;
+               }
+               if (pr->perm_rank >= 0) ksprintf(&s, ";PR=%d", pr->perm_rank);
+               ksprintf(&s, ";PCHI2=%.3g;PC2=%d,%d", q[1], q[2], pr->p_chi2);
+       }
+       if (has_I16 && a.is_tested) ksprintf(&s, ";PV4=%.2g,%.2g,%.2g,%.2g", a.p[0], a.p[1], a.p[2], a.p[3]);
        kputc('\0', &s);
        kputs(b->fmt, &s); kputc('\0', &s);
        free(b->str);
        b->m_str = s.m; b->l_str = s.l; b->str = s.s;
-       b->qual = r < 1e-100? 99 : -4.343 * log(r);
-       if (b->qual > 99) b->qual = 99;
+       b->qual = r < 1e-100? 999 : -4.343 * log(r);
+       if (b->qual > 999) b->qual = 999;
        bcf_sync(b);
        if (!is_var) bcf_shrink_alt(b, 1);
        else if (!(flag&VC_KEEPALT))
@@ -191,7 +170,7 @@ static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p
                b->m_str = s.m; b->l_str = s.l; b->str = s.s;
                bcf_sync(b);
                for (i = 0; i < b->n_smpl; ++i) {
-                       x = bcf_p1_call_gt(pa, pr->f_em, i);
+                       x = bcf_p1_call_gt(pa, pr->f_exp, i);
                        ((uint8_t*)b->gi[old_n_gi].data)[i] = (x&3) == 0? 1<<3|1 : (x&3) == 1? 1 : 0;
                        ((uint8_t*)b->gi[old_n_gi+1].data)[i] = x>>2;
                }
@@ -199,47 +178,147 @@ static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p
        return is_var;
 }
 
-double bcf_ld_freq(const bcf1_t *b0, const bcf1_t *b1, double f[4]);
+static char **read_samples(const char *fn, int *_n)
+{
+       gzFile fp;
+       kstream_t *ks;
+       kstring_t s;
+       int dret, n = 0, max = 0;
+       char **sam = 0;
+       *_n = 0;
+       s.l = s.m = 0; s.s = 0;
+       fp = gzopen(fn, "r");
+       if (fp == 0) return 0; // fail to open file
+       ks = ks_init(fp);
+       while (ks_getuntil(ks, 0, &s, &dret) >= 0) {
+               int l;
+               if (max == n) {
+                       max = max? max<<1 : 4;
+                       sam = realloc(sam, sizeof(void*)*max);
+               }
+               l = s.l;
+               sam[n] = malloc(s.l + 2);
+               strcpy(sam[n], s.s);
+               sam[n][l+1] = 2; // by default, diploid
+               if (dret != '\n') {
+                       if (ks_getuntil(ks, 0, &s, &dret) >= 0) { // read ploidy, 1 or 2
+                               int x = (int)s.s[0] - '0';
+                               if (x == 1 || x == 2) sam[n][l+1] = x;
+                               else fprintf(pysamerr, "(%s) ploidy can only be 1 or 2; assume diploid\n", __func__);
+                       }
+                       if (dret != '\n') ks_getuntil(ks, '\n', &s, &dret);
+               }
+               ++n;
+       }
+       ks_destroy(ks);
+       gzclose(fp);
+       free(s.s);
+       *_n = n;
+       return sam;
+}
+
+static void write_header(bcf_hdr_t *h)
+{
+       kstring_t str;
+       str.l = h->l_txt? h->l_txt - 1 : 0;
+       str.m = str.l + 1; str.s = h->txt;
+       if (!strstr(str.s, "##INFO=<ID=DP,"))
+               kputs("##INFO=<ID=DP,Number=1,Type=Integer,Description=\"Raw read depth\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=DP4,"))
+               kputs("##INFO=<ID=DP4,Number=4,Type=Integer,Description=\"# high-quality ref-forward bases, ref-reverse, alt-forward and alt-reverse bases\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=MQ,"))
+               kputs("##INFO=<ID=MQ,Number=1,Type=Integer,Description=\"Root-mean-square mapping quality of covering reads\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=FQ,"))
+               kputs("##INFO=<ID=FQ,Number=1,Type=Float,Description=\"Phred probability of all samples being the same\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=AF1,"))
+               kputs("##INFO=<ID=AF1,Number=1,Type=Float,Description=\"Max-likelihood estimate of the site allele frequency of the first ALT allele\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=G3,"))
+               kputs("##INFO=<ID=G3,Number=3,Type=Float,Description=\"ML estimate of genotype frequencies\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=HWE,"))
+               kputs("##INFO=<ID=HWE,Number=1,Type=Float,Description=\"Chi^2 based HWE test P-value based on G3\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=CI95,"))
+               kputs("##INFO=<ID=CI95,Number=2,Type=Float,Description=\"Equal-tail Bayesian credible interval of the site allele frequency at the 95% level\">\n", &str);
+       if (!strstr(str.s, "##INFO=<ID=PV4,"))
+               kputs("##INFO=<ID=PV4,Number=4,Type=Float,Description=\"P-values for strand bias, baseQ bias, mapQ bias and tail distance bias\">\n", &str);
+    if (!strstr(str.s, "##INFO=<ID=INDEL,"))
+        kputs("##INFO=<ID=INDEL,Number=0,Type=Flag,Description=\"Indicates that the variant is an INDEL.\">\n", &str);
+    if (!strstr(str.s, "##INFO=<ID=PC2,"))
+        kputs("##INFO=<ID=PC2,Number=2,Type=Integer,Description=\"Phred probability of the nonRef allele frequency in group1 samples being larger (,smaller) than in group2.\">\n", &str);
+    if (!strstr(str.s, "##INFO=<ID=PCHI2,"))
+        kputs("##INFO=<ID=PCHI2,Number=1,Type=Float,Description=\"Posterior weighted chi^2 P-value for testing the association between group1 and group2 samples.\">\n", &str);
+    if (!strstr(str.s, "##INFO=<ID=QCHI2,"))
+        kputs("##INFO=<ID=QCHI2,Number=1,Type=Integer,Description=\"Phred scaled PCHI2.\">\n", &str);
+    if (!strstr(str.s, "##INFO=<ID=RP,"))
+        kputs("##INFO=<ID=PR,Number=1,Type=Integer,Description=\"# permutations yielding a smaller PCHI2.\">\n", &str);
+    if (!strstr(str.s, "##FORMAT=<ID=GT,"))
+        kputs("##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">\n", &str);
+    if (!strstr(str.s, "##FORMAT=<ID=GQ,"))
+        kputs("##FORMAT=<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">\n", &str);
+    if (!strstr(str.s, "##FORMAT=<ID=GL,"))
+        kputs("##FORMAT=<ID=GL,Number=3,Type=Float,Description=\"Likelihoods for RR,RA,AA genotypes (R=ref,A=alt)\">\n", &str);
+       if (!strstr(str.s, "##FORMAT=<ID=DP,"))
+               kputs("##FORMAT=<ID=DP,Number=1,Type=Integer,Description=\"# high-quality bases\">\n", &str);
+       if (!strstr(str.s, "##FORMAT=<ID=SP,"))
+               kputs("##FORMAT=<ID=SP,Number=1,Type=Integer,Description=\"Phred-scaled strand bias P-value\">\n", &str);
+       if (!strstr(str.s, "##FORMAT=<ID=PL,"))
+               kputs("##FORMAT=<ID=PL,Number=-1,Type=Integer,Description=\"List of Phred-scaled genotype likelihoods, number of values is (#ALT+1)*(#ALT+2)/2\">\n", &str);
+       h->l_txt = str.l + 1; h->txt = str.s;
+}
+
+double bcf_pair_freq(const bcf1_t *b0, const bcf1_t *b1, double f[4]);
 
 int bcfview(int argc, char *argv[])
 {
        extern int bcf_2qcall(bcf_hdr_t *h, bcf1_t *b);
        extern void bcf_p1_indel_prior(bcf_p1aux_t *ma, double x);
+       extern int bcf_fix_gt(bcf1_t *b);
+       extern int bcf_anno_max(bcf1_t *b);
+       extern int bcf_shuffle(bcf1_t *b, int seed);
        bcf_t *bp, *bout = 0;
        bcf1_t *b, *blast;
-       int c;
+       int c, *seeds = 0;
        uint64_t n_processed = 0;
        viewconf_t vc;
        bcf_p1aux_t *p1 = 0;
-       bcf_hdr_t *h;
+       bcf_hdr_t *hin, *hout;
        int tid, begin, end;
        char moder[4], modew[4];
-       khash_t(set64) *hash = 0;
 
        tid = begin = end = -1;
        memset(&vc, 0, sizeof(viewconf_t));
-       vc.prior_type = vc.n1 = -1; vc.theta = 1e-3; vc.pref = 0.5; vc.indel_frac = -1.;
-       while ((c = getopt(argc, argv, "fN1:l:cHAGvbSuP:t:p:QgLi:I")) >= 0) {
+       vc.prior_type = vc.n1 = -1; vc.theta = 1e-3; vc.pref = 0.5; vc.indel_frac = -1.; vc.n_perm = 0; vc.min_perm_p = 0.01; vc.min_smpl_frac = 0; vc.min_lrt = 1;
+       while ((c = getopt(argc, argv, "FN1:l:cC:eHAGvbSuP:t:p:QgLi:IMs:D:U:X:d:")) >= 0) {
                switch (c) {
-               case 'f': vc.flag |= VC_FOLDED; break;
                case '1': vc.n1 = atoi(optarg); break;
-               case 'l': vc.fn_list = strdup(optarg); break;
+               case 'l': vc.bed = bed_read(optarg); break;
+               case 'D': vc.fn_dict = strdup(optarg); break;
+               case 'F': vc.flag |= VC_FIX_PL; break;
                case 'N': vc.flag |= VC_ACGT_ONLY; break;
                case 'G': vc.flag |= VC_NO_GENO; break;
                case 'A': vc.flag |= VC_KEEPALT; break;
                case 'b': vc.flag |= VC_BCFOUT; break;
                case 'S': vc.flag |= VC_VCFIN; break;
                case 'c': vc.flag |= VC_CALL; break;
+               case 'e': vc.flag |= VC_EM; break;
                case 'v': vc.flag |= VC_VARONLY | VC_CALL; break;
                case 'u': vc.flag |= VC_UNCOMP | VC_BCFOUT; break;
-               case 'H': vc.flag |= VC_HWE; break;
                case 'g': vc.flag |= VC_CALL_GT | VC_CALL; break;
                case 'I': vc.flag |= VC_NO_INDEL; break;
+               case 'M': vc.flag |= VC_ANNO_MAX; break;
                case 't': vc.theta = atof(optarg); break;
                case 'p': vc.pref = atof(optarg); break;
                case 'i': vc.indel_frac = atof(optarg); break;
                case 'Q': vc.flag |= VC_QCALL; break;
                case 'L': vc.flag |= VC_ADJLD; break;
+               case 'U': vc.n_perm = atoi(optarg); break;
+               case 'C': vc.min_lrt = atof(optarg); break;
+               case 'X': vc.min_perm_p = atof(optarg); break;
+               case 'd': vc.min_smpl_frac = atof(optarg); break;
+               case 's': vc.subsam = read_samples(optarg, &vc.n_sub);
+                       vc.ploidy = calloc(vc.n_sub + 1, 1);
+                       for (tid = 0; tid < vc.n_sub; ++tid) vc.ploidy[tid] = vc.subsam[tid][strlen(vc.subsam[tid]) + 1];
+                       tid = -1;
+                       break;
                case 'P':
                        if (strcmp(optarg, "full") == 0) vc.prior_type = MC_PTYPE_FULL;
                        else if (strcmp(optarg, "cond2") == 0) vc.prior_type = MC_PTYPE_COND2;
@@ -250,31 +329,51 @@ int bcfview(int argc, char *argv[])
        }
        if (argc == optind) {
                fprintf(pysamerr, "\n");
-               fprintf(pysamerr, "Usage:   bcftools view [options] <in.bcf> [reg]\n\n");
-               fprintf(pysamerr, "Options: -c        SNP calling\n");
-               fprintf(pysamerr, "         -v        output potential variant sites only (force -c)\n");
-               fprintf(pysamerr, "         -g        call genotypes at variant sites (force -c)\n");
-               fprintf(pysamerr, "         -b        output BCF instead of VCF\n");
-               fprintf(pysamerr, "         -u        uncompressed BCF output (force -b)\n");
-               fprintf(pysamerr, "         -S        input is VCF\n");
-               fprintf(pysamerr, "         -A        keep all possible alternate alleles at variant sites\n");
-               fprintf(pysamerr, "         -G        suppress all individual genotype information\n");
-               fprintf(pysamerr, "         -H        perform Hardy-Weinberg test (slower)\n");
-               fprintf(pysamerr, "         -N        skip sites where REF is not A/C/G/T\n");
-               fprintf(pysamerr, "         -Q        output the QCALL likelihood format\n");
-               fprintf(pysamerr, "         -L        calculate LD for adjacent sites\n");
-               fprintf(pysamerr, "         -I        skip indels\n");
-               fprintf(pysamerr, "         -f        reference-free variant calling\n");
-               fprintf(pysamerr, "         -1 INT    number of group-1 samples [0]\n");
-               fprintf(pysamerr, "         -l FILE   list of sites to output [all sites]\n");
-               fprintf(pysamerr, "         -t FLOAT  scaled substitution mutation rate [%.4lg]\n", vc.theta);
-               fprintf(pysamerr, "         -i FLOAT  indel-to-substitution ratio [%.4lg]\n", vc.indel_frac);
-               fprintf(pysamerr, "         -p FLOAT  variant if P(ref|D)<FLOAT [%.3lg]\n", vc.pref);
-               fprintf(pysamerr, "         -P STR    type of prior: full, cond2, flat [full]\n");
+               fprintf(pysamerr, "Usage: bcftools view [options] <in.bcf> [reg]\n\n");
+               fprintf(pysamerr, "Input/output options:\n\n");
+               fprintf(pysamerr, "       -A        keep all possible alternate alleles at variant sites\n");
+               fprintf(pysamerr, "       -b        output BCF instead of VCF\n");
+               fprintf(pysamerr, "       -D FILE   sequence dictionary for VCF->BCF conversion [null]\n");
+               fprintf(pysamerr, "       -F        PL generated by r921 or before (which generate old ordering)\n");
+               fprintf(pysamerr, "       -G        suppress all individual genotype information\n");
+               fprintf(pysamerr, "       -l FILE   list of sites (chr pos) or regions (BED) to output [all sites]\n");
+               fprintf(pysamerr, "       -L        calculate LD for adjacent sites\n");
+               fprintf(pysamerr, "       -N        skip sites where REF is not A/C/G/T\n");
+               fprintf(pysamerr, "       -Q        output the QCALL likelihood format\n");
+               fprintf(pysamerr, "       -s FILE   list of samples to use [all samples]\n");
+               fprintf(pysamerr, "       -S        input is VCF\n");
+               fprintf(pysamerr, "       -u        uncompressed BCF output (force -b)\n");
+               fprintf(pysamerr, "\nConsensus/variant calling options:\n\n");
+               fprintf(pysamerr, "       -c        SNP calling (force -e)\n");
+               fprintf(pysamerr, "       -d FLOAT  skip loci where less than FLOAT fraction of samples covered [0]\n");
+               fprintf(pysamerr, "       -e        likelihood based analyses\n");
+               fprintf(pysamerr, "       -g        call genotypes at variant sites (force -c)\n");
+               fprintf(pysamerr, "       -i FLOAT  indel-to-substitution ratio [%.4g]\n", vc.indel_frac);
+               fprintf(pysamerr, "       -I        skip indels\n");
+               fprintf(pysamerr, "       -p FLOAT  variant if P(ref|D)<FLOAT [%.3g]\n", vc.pref);
+               fprintf(pysamerr, "       -P STR    type of prior: full, cond2, flat [full]\n");
+               fprintf(pysamerr, "       -t FLOAT  scaled substitution mutation rate [%.4g]\n", vc.theta);
+               fprintf(pysamerr, "       -v        output potential variant sites only (force -c)\n");
+               fprintf(pysamerr, "\nContrast calling and association test options:\n\n");
+               fprintf(pysamerr, "       -1 INT    number of group-1 samples [0]\n");
+               fprintf(pysamerr, "       -C FLOAT  posterior constrast for LRT<FLOAT and P(ref|D)<0.5 [%g]\n", vc.min_lrt);
+               fprintf(pysamerr, "       -U INT    number of permutations for association testing (effective with -1) [0]\n");
+               fprintf(pysamerr, "       -X FLOAT  only perform permutations for P(chi^2)<FLOAT [%g]\n", vc.min_perm_p);
                fprintf(pysamerr, "\n");
                return 1;
        }
 
+       if (vc.flag & VC_CALL) vc.flag |= VC_EM;
+       if ((vc.flag & VC_VCFIN) && (vc.flag & VC_BCFOUT) && vc.fn_dict == 0) {
+               fprintf(pysamerr, "[%s] For VCF->BCF conversion please specify the sequence dictionary with -D\n", __func__);
+               return 1;
+       }
+       if (vc.n1 <= 0) vc.n_perm = 0; // TODO: give a warning here!
+       if (vc.n_perm > 0) {
+               seeds = malloc(vc.n_perm * sizeof(int));
+               srand48(time(0));
+               for (c = 0; c < vc.n_perm; ++c) seeds[c] = lrand48();
+       }
        b = calloc(1, sizeof(bcf1_t));
        blast = calloc(1, sizeof(bcf1_t));
        strcpy(moder, "r");
@@ -283,27 +382,34 @@ int bcfview(int argc, char *argv[])
        if (vc.flag & VC_BCFOUT) strcat(modew, "b");
        if (vc.flag & VC_UNCOMP) strcat(modew, "u");
        bp = vcf_open(argv[optind], moder);
-       h = vcf_hdr_read(bp);
+       hin = hout = vcf_hdr_read(bp);
+       if (vc.fn_dict && (vc.flag & VC_VCFIN))
+               vcf_dictread(bp, hin, vc.fn_dict);
        bout = vcf_open("-", modew);
-       if (!(vc.flag & VC_QCALL)) vcf_hdr_write(bout, h);
+       if (!(vc.flag & VC_QCALL)) {
+               if (vc.n_sub) {
+                       vc.sublist = calloc(vc.n_sub, sizeof(int));
+                       hout = bcf_hdr_subsam(hin, vc.n_sub, vc.subsam, vc.sublist);
+               }
+               if (vc.flag & VC_CALL) write_header(hout);
+               vcf_hdr_write(bout, hout);
+       }
        if (vc.flag & VC_CALL) {
-               p1 = bcf_p1_init(h->n_smpl);
+               p1 = bcf_p1_init(hout->n_smpl, vc.ploidy);
                if (vc.prior_file) {
                        if (bcf_p1_read_prior(p1, vc.prior_file) < 0) {
                                fprintf(pysamerr, "[%s] fail to read the prior AFS.\n", __func__);
                                return 1;
                        }
                } else bcf_p1_init_prior(p1, vc.prior_type, vc.theta);
-               if (vc.n1 > 0) {
+               if (vc.n1 > 0 && vc.min_lrt > 0.) { // set n1
                        bcf_p1_set_n1(p1, vc.n1);
                        bcf_p1_init_subprior(p1, vc.prior_type, vc.theta);
                }
                if (vc.indel_frac > 0.) bcf_p1_indel_prior(p1, vc.indel_frac); // otherwise use the default indel_frac
-               if (vc.flag & VC_FOLDED) bcf_p1_set_folded(p1);
        }
-       if (vc.fn_list) hash = bcf_load_pos(vc.fn_list, h);
        if (optind + 1 < argc && !(vc.flag&VC_VCFIN)) {
-               void *str2id = bcf_build_refhash(h);
+               void *str2id = bcf_build_refhash(hout);
                if (bcf_parse_region(str2id, argv[optind+1], &tid, &begin, &end) >= 0) {
                        bcf_idx_t *idx;
                        idx = bcf_idx_load(argv[optind]);
@@ -319,8 +425,18 @@ int bcfview(int argc, char *argv[])
                        }
                }
        }
-       while (vcf_read(bp, h, b) > 0) {
-               int is_indel = bcf_is_indel(b);
+       while (vcf_read(bp, hin, b) > 0) {
+               int is_indel;
+               double em[9];
+               if ((vc.flag & VC_VARONLY) && strcmp(b->alt, "X") == 0) continue;
+               if ((vc.flag & VC_VARONLY) && vc.min_smpl_frac > 0.) {
+                       extern int bcf_smpl_covered(const bcf1_t *b);
+                       int n = bcf_smpl_covered(b);
+                       if ((double)n / b->n_smpl < vc.min_smpl_frac) continue;
+               }
+               if (vc.n_sub) bcf_subsam(vc.n_sub, vc.sublist, b);
+               if (vc.flag & VC_FIX_PL) bcf_fix_pl(b);
+               is_indel = bcf_is_indel(b);
                if ((vc.flag & VC_NO_INDEL) && is_indel) continue;
                if ((vc.flag & VC_ACGT_ONLY) && !is_indel) {
                        int x;
@@ -328,13 +444,7 @@ int bcfview(int argc, char *argv[])
                        x = toupper(b->ref[0]);
                        if (x != 'A' && x != 'C' && x != 'G' && x != 'T') continue;
                }
-               if (hash) {
-                       uint64_t x = (uint64_t)b->tid<<32 | b->pos;
-                       khint_t k = kh_get(set64, hash, x);
-                       if (kh_size(hash) == 0) break;
-                       if (k == kh_end(hash)) continue;
-                       kh_del(set64, hash, k);
-               }
+               if (vc.bed && !bed_overlap(vc.bed, hin->ns[b->tid], b->pos, b->pos + strlen(b->ref))) continue;
                if (tid >= 0) {
                        int l = strlen(b->ref);
                        l = b->pos + (l > 0? l : 1);
@@ -343,46 +453,77 @@ int bcfview(int argc, char *argv[])
                }
                ++n_processed;
                if (vc.flag & VC_QCALL) { // output QCALL format; STOP here
-                       bcf_2qcall(h, b);
+                       bcf_2qcall(hout, b);
                        continue;
                }
+               if (vc.flag & VC_EM) bcf_em1(b, vc.n1, 0xff, em);
+               else {
+                       int i;
+                       for (i = 0; i < 9; ++i) em[i] = -1.;
+               }
                if (vc.flag & (VC_CALL|VC_ADJLD)) bcf_gl2pl(b);
                if (vc.flag & VC_CALL) { // call variants
                        bcf_p1rst_t pr;
-                       bcf_p1_cal(b, p1, &pr); // pr.g[3] is not calculated here
-                       if (vc.flag&VC_HWE) bcf_p1_cal_g3(p1, pr.g);
+                       int calret = bcf_p1_cal(b, (em[7] >= 0 && em[7] < vc.min_lrt), p1, &pr);
                        if (n_processed % 100000 == 0) {
                                fprintf(pysamerr, "[%s] %ld sites processed.\n", __func__, (long)n_processed);
                                bcf_p1_dump_afs(p1);
                        }
                        if (pr.p_ref >= vc.pref && (vc.flag & VC_VARONLY)) continue;
-                       update_bcf1(h->n_smpl, b, p1, &pr, vc.pref, vc.flag);
-               }
+                       if (vc.n_perm && vc.n1 > 0 && pr.p_chi2 < vc.min_perm_p) { // permutation test
+                               bcf_p1rst_t r;
+                               int i, n = 0;
+                               for (i = 0; i < vc.n_perm; ++i) {
+#ifdef BCF_PERM_LRT // LRT based permutation is much faster but less robust to artifacts
+                                       double x[9];
+                                       bcf_shuffle(b, seeds[i]);
+                                       bcf_em1(b, vc.n1, 1<<7, x);
+                                       if (x[7] < em[7]) ++n;
+#else
+                                       bcf_shuffle(b, seeds[i]);
+                                       bcf_p1_cal(b, 1, p1, &r);
+                                       if (pr.p_chi2 >= r.p_chi2) ++n;
+#endif
+                               }
+                               pr.perm_rank = n;
+                       }
+                       if (calret >= 0) update_bcf1(b, p1, &pr, vc.pref, vc.flag, em);
+               } else if (vc.flag & VC_EM) update_bcf1(b, 0, 0, 0, vc.flag, em);
                if (vc.flag & VC_ADJLD) { // compute LD
                        double f[4], r2;
-                       if ((r2 = bcf_ld_freq(blast, b, f)) >= 0) {
+                       if ((r2 = bcf_pair_freq(blast, b, f)) >= 0) {
                                kstring_t s;
                                s.m = s.l = 0; s.s = 0;
                                if (*b->info) kputc(';', &s);
-                               ksprintf(&s, "NEIR=%.3lf;NEIF=%.3lf,%.3lf", r2, f[0]+f[2], f[0]+f[1]);
+                               ksprintf(&s, "NEIR=%.3f;NEIF4=%.3f,%.3f,%.3f,%.3f", r2, f[0], f[1], f[2], f[3]);
                                bcf_append_info(b, s.s, s.l);
                                free(s.s);
                        }
                        bcf_cpy(blast, b);
                }
+               if (vc.flag & VC_ANNO_MAX) bcf_anno_max(b);
                if (vc.flag & VC_NO_GENO) { // do not output GENO fields
                        b->n_gi = 0;
                        b->fmt[0] = '\0';
-               }
-               vcf_write(bout, h, b);
+                       b->l_str = b->fmt - b->str + 1;
+               } else bcf_fix_gt(b);
+               vcf_write(bout, hout, b);
        }
        if (vc.prior_file) free(vc.prior_file);
        if (vc.flag & VC_CALL) bcf_p1_dump_afs(p1);
-       bcf_hdr_destroy(h);
+       if (hin != hout) bcf_hdr_destroy(hout);
+       bcf_hdr_destroy(hin);
        bcf_destroy(b); bcf_destroy(blast);
        vcf_close(bp); vcf_close(bout);
-       if (hash) kh_destroy(set64, hash);
-       if (vc.fn_list) free(vc.fn_list);
+       if (vc.fn_dict) free(vc.fn_dict);
+       if (vc.ploidy) free(vc.ploidy);
+       if (vc.n_sub) {
+               int i;
+               for (i = 0; i < vc.n_sub; ++i) free(vc.subsam[i]);
+               free(vc.subsam); free(vc.sublist);
+       }
+       if (vc.bed) bed_destroy(vc.bed);
+       if (seeds) free(seeds);
        if (p1) bcf_p1_destroy(p1);
        return 0;
 }
diff --git a/samtools/bcftools/em.c.pysam.c b/samtools/bcftools/em.c.pysam.c
new file mode 100644 (file)
index 0000000..914dc05
--- /dev/null
@@ -0,0 +1,308 @@
+#include "pysam.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "bcf.h"
+#include "kmin.h"
+
+static double g_q2p[256];
+
+#define ITER_MAX 50
+#define ITER_TRY 10
+#define EPS 1e-5
+
+extern double kf_gammaq(double, double);
+
+/*
+       Generic routines
+ */
+// get the 3 genotype likelihoods
+static double *get_pdg3(const bcf1_t *b)
+{
+       double *pdg;
+       const uint8_t *PL = 0;
+       int i, PL_len = 0;
+       // initialize g_q2p if necessary
+       if (g_q2p[0] == 0.)
+               for (i = 0; i < 256; ++i)
+                       g_q2p[i] = pow(10., -i / 10.);
+       // set PL and PL_len
+       for (i = 0; i < b->n_gi; ++i) {
+               if (b->gi[i].fmt == bcf_str2int("PL", 2)) {
+                       PL = (const uint8_t*)b->gi[i].data;
+                       PL_len = b->gi[i].len;
+                       break;
+               }
+       }
+       if (i == b->n_gi) return 0; // no PL
+       // fill pdg
+       pdg = malloc(3 * b->n_smpl * sizeof(double));
+       for (i = 0; i < b->n_smpl; ++i) {
+               const uint8_t *pi = PL + i * PL_len;
+               double *p = pdg + i * 3;
+               p[0] = g_q2p[pi[2]]; p[1] = g_q2p[pi[1]]; p[2] = g_q2p[pi[0]];
+       }
+       return pdg;
+}
+
+// estimate site allele frequency in a very naive and inaccurate way
+static double est_freq(int n, const double *pdg)
+{
+       int i, gcnt[3], tmp1;
+       // get a rough estimate of the genotype frequency
+       gcnt[0] = gcnt[1] = gcnt[2] = 0;
+       for (i = 0; i < n; ++i) {
+               const double *p = pdg + i * 3;
+               if (p[0] != 1. || p[1] != 1. || p[2] != 1.) {
+                       int which = p[0] > p[1]? 0 : 1;
+                       which = p[which] > p[2]? which : 2;
+                       ++gcnt[which];
+               }
+       }
+       tmp1 = gcnt[0] + gcnt[1] + gcnt[2];
+       return (tmp1 == 0)? -1.0 : (.5 * gcnt[1] + gcnt[2]) / tmp1;
+}
+
+/*
+       Single-locus EM
+ */
+
+typedef struct {
+       int beg, end;
+       const double *pdg;
+} minaux1_t;
+
+static double prob1(double f, void *data)
+{
+       minaux1_t *a = (minaux1_t*)data;
+       double p = 1., l = 0., f3[3];
+       int i;
+//     printf("brent %lg\n", f);
+       if (f < 0 || f > 1) return 1e300;
+       f3[0] = (1.-f)*(1.-f); f3[1] = 2.*f*(1.-f); f3[2] = f*f;
+       for (i = a->beg; i < a->end; ++i) {
+               const double *pdg = a->pdg + i * 3;
+               p *= pdg[0] * f3[0] + pdg[1] * f3[1] + pdg[2] * f3[2];
+               if (p < 1e-200) l -= log(p), p = 1.;
+       }
+       return l - log(p);
+}
+
+// one EM iteration for allele frequency estimate
+static double freq_iter(double *f, const double *_pdg, int beg, int end)
+{
+       double f0 = *f, f3[3], err;
+       int i;
+//     printf("em %lg\n", *f);
+       f3[0] = (1.-f0)*(1.-f0); f3[1] = 2.*f0*(1.-f0); f3[2] = f0*f0;
+       for (i = beg, f0 = 0.; i < end; ++i) {
+               const double *pdg = _pdg + i * 3;
+               f0 += (pdg[1] * f3[1] + 2. * pdg[2] * f3[2])
+                       / (pdg[0] * f3[0] + pdg[1] * f3[1] + pdg[2] * f3[2]);
+       }
+       f0 /= (end - beg) * 2;
+       err = fabs(f0 - *f);
+       *f = f0;
+       return err;
+}
+
+/* The following function combines EM and Brent's method. When the signal from
+ * the data is strong, EM is faster but sometimes, EM may converge very slowly.
+ * When this happens, we switch to Brent's method. The idea is learned from
+ * Rasmus Nielsen.
+ */
+static double freqml(double f0, int beg, int end, const double *pdg)
+{
+       int i;
+       double f;
+       for (i = 0, f = f0; i < ITER_TRY; ++i)
+               if (freq_iter(&f, pdg, beg, end) < EPS) break;
+       if (i == ITER_TRY) { // haven't converged yet; try Brent's method
+               minaux1_t a;
+               a.beg = beg; a.end = end; a.pdg = pdg;
+               kmin_brent(prob1, f0 == f? .5*f0 : f0, f, (void*)&a, EPS, &f);
+       }
+       return f;
+}
+
+// one EM iteration for genotype frequency estimate
+static double g3_iter(double g[3], const double *_pdg, int beg, int end)
+{
+       double err, gg[3];
+       int i;
+       gg[0] = gg[1] = gg[2] = 0.;
+//     printf("%lg,%lg,%lg\n", g[0], g[1], g[2]);
+       for (i = beg; i < end; ++i) {
+               double sum, tmp[3];
+               const double *pdg = _pdg + i * 3;
+               tmp[0] = pdg[0] * g[0]; tmp[1] = pdg[1] * g[1]; tmp[2] = pdg[2] * g[2];
+               sum = (tmp[0] + tmp[1] + tmp[2]) * (end - beg);
+               gg[0] += tmp[0] / sum; gg[1] += tmp[1] / sum; gg[2] += tmp[2] / sum;
+       }
+       err = fabs(gg[0] - g[0]) > fabs(gg[1] - g[1])? fabs(gg[0] - g[0]) : fabs(gg[1] - g[1]);
+       err = err > fabs(gg[2] - g[2])? err : fabs(gg[2] - g[2]);
+       g[0] = gg[0]; g[1] = gg[1]; g[2] = gg[2];
+       return err;
+}
+
+// perform likelihood ratio test
+static double lk_ratio_test(int n, int n1, const double *pdg, double f3[3][3])
+{
+       double r;
+       int i;
+       for (i = 0, r = 1.; i < n1; ++i) {
+               const double *p = pdg + i * 3;
+               r *= (p[0] * f3[1][0] + p[1] * f3[1][1] + p[2] * f3[1][2])
+                       / (p[0] * f3[0][0] + p[1] * f3[0][1] + p[2] * f3[0][2]);
+       }
+       for (; i < n; ++i) {
+               const double *p = pdg + i * 3;
+               r *= (p[0] * f3[2][0] + p[1] * f3[2][1] + p[2] * f3[2][2])
+                       / (p[0] * f3[0][0] + p[1] * f3[0][1] + p[2] * f3[0][2]);
+       }
+       return r;
+}
+
+// x[0]: ref frequency
+// x[1..3]: alt-alt, alt-ref, ref-ref frequenc
+// x[4]: HWE P-value
+// x[5..6]: group1 freq, group2 freq
+// x[7]: 1-degree P-value
+// x[8]: 2-degree P-value
+int bcf_em1(const bcf1_t *b, int n1, int flag, double x[9])
+{
+       double *pdg;
+       int i, n, n2;
+       if (b->n_alleles < 2) return -1; // one allele only
+       // initialization
+       if (n1 < 0 || n1 > b->n_smpl) n1 = 0;
+       if (flag & 1<<7) flag |= 7<<5; // compute group freq if LRT is required
+       if (flag & 0xf<<1) flag |= 0xf<<1;
+       n = b->n_smpl; n2 = n - n1;
+       pdg = get_pdg3(b);
+       if (pdg == 0) return -1;
+       for (i = 0; i < 9; ++i) x[i] = -1.;
+       {
+               if ((x[0] = est_freq(n, pdg)) < 0.) {
+                       free(pdg);
+                       return -1; // no data
+               }
+               x[0] = freqml(x[0], 0, n, pdg);
+       }
+       if (flag & (0xf<<1|1<<8)) { // estimate the genotype frequency and test HWE
+               double *g = x + 1, f3[3], r;
+               f3[0] = g[0] = (1 - x[0]) * (1 - x[0]);
+               f3[1] = g[1] = 2 * x[0] * (1 - x[0]);
+               f3[2] = g[2] = x[0] * x[0];
+               for (i = 0; i < ITER_MAX; ++i)
+                       if (g3_iter(g, pdg, 0, n) < EPS) break;
+               // Hardy-Weinberg equilibrium (HWE)
+               for (i = 0, r = 1.; i < n; ++i) {
+                       double *p = pdg + i * 3;
+                       r *= (p[0] * g[0] + p[1] * g[1] + p[2] * g[2]) / (p[0] * f3[0] + p[1] * f3[1] + p[2] * f3[2]);
+               }
+               x[4] = kf_gammaq(.5, log(r));
+       }
+       if ((flag & 7<<5) && n1 > 0 && n1 < n) { // group frequency
+               x[5] = freqml(x[0], 0, n1, pdg);
+               x[6] = freqml(x[0], n1, n, pdg);
+       }
+       if ((flag & 1<<7) && n1 > 0 && n1 < n) { // 1-degree P-value
+               double f[3], f3[3][3];
+               f[0] = x[0]; f[1] = x[5]; f[2] = x[6];
+               for (i = 0; i < 3; ++i)
+                       f3[i][0] = (1-f[i])*(1-f[i]), f3[i][1] = 2*f[i]*(1-f[i]), f3[i][2] = f[i]*f[i];
+               x[7] = kf_gammaq(.5, log(lk_ratio_test(n, n1, pdg, f3)));
+       }
+       if ((flag & 1<<8) && n1 > 0 && n1 < n) { // 2-degree P-value
+               double g[3][3];
+               for (i = 0; i < 3; ++i) memcpy(g[i], x + 1, 3 * sizeof(double));
+               for (i = 0; i < ITER_MAX; ++i)
+                       if (g3_iter(g[1], pdg, 0, n1) < EPS) break;
+               for (i = 0; i < ITER_MAX; ++i)
+                       if (g3_iter(g[2], pdg, n1, n) < EPS) break;
+               x[8] = kf_gammaq(1., log(lk_ratio_test(n, n1, pdg, g)));
+       }
+       // free
+       free(pdg);
+       return 0;
+}
+
+/*
+       Two-locus EM (LD)
+ */
+
+#define _G1(h, k) ((h>>1&1) + (k>>1&1))
+#define _G2(h, k) ((h&1) + (k&1))
+
+// 0: the previous site; 1: the current site
+static int pair_freq_iter(int n, double *pdg[2], double f[4])
+{
+       double ff[4];
+       int i, k, h;
+//     printf("%lf,%lf,%lf,%lf\n", f[0], f[1], f[2], f[3]);
+       memset(ff, 0, 4 * sizeof(double));
+       for (i = 0; i < n; ++i) {
+               double *p[2], sum, tmp;
+               p[0] = pdg[0] + i * 3; p[1] = pdg[1] + i * 3;
+               for (k = 0, sum = 0.; k < 4; ++k)
+                       for (h = 0; h < 4; ++h)
+                               sum += f[k] * f[h] * p[0][_G1(k,h)] * p[1][_G2(k,h)];
+               for (k = 0; k < 4; ++k) {
+                       tmp = f[0] * (p[0][_G1(0,k)] * p[1][_G2(0,k)] + p[0][_G1(k,0)] * p[1][_G2(k,0)])
+                               + f[1] * (p[0][_G1(1,k)] * p[1][_G2(1,k)] + p[0][_G1(k,1)] * p[1][_G2(k,1)])
+                               + f[2] * (p[0][_G1(2,k)] * p[1][_G2(2,k)] + p[0][_G1(k,2)] * p[1][_G2(k,2)])
+                               + f[3] * (p[0][_G1(3,k)] * p[1][_G2(3,k)] + p[0][_G1(k,3)] * p[1][_G2(k,3)]);
+                       ff[k] += f[k] * tmp / sum;
+               }
+       }
+       for (k = 0; k < 4; ++k) f[k] = ff[k] / (2 * n);
+       return 0;
+}
+
+double bcf_pair_freq(const bcf1_t *b0, const bcf1_t *b1, double f[4])
+{
+       const bcf1_t *b[2];
+       int i, j, n_smpl;
+       double *pdg[2], flast[4], r, f0[2];
+       // initialize others
+       if (b0->n_smpl != b1->n_smpl) return -1; // different number of samples
+       n_smpl = b0->n_smpl;
+       b[0] = b0; b[1] = b1;
+       f[0] = f[1] = f[2] = f[3] = -1.;
+       if (b[0]->n_alleles < 2 || b[1]->n_alleles < 2) return -1; // one allele only
+       pdg[0] = get_pdg3(b0); pdg[1] = get_pdg3(b1);
+       if (pdg[0] == 0 || pdg[1] == 0) {
+               free(pdg[0]); free(pdg[1]);
+               return -1;
+       }
+       // set the initial value
+       f0[0] = est_freq(n_smpl, pdg[0]);
+       f0[1] = est_freq(n_smpl, pdg[1]);
+       f[0] = (1 - f0[0]) * (1 - f0[1]); f[3] = f0[0] * f0[1];
+       f[1] = (1 - f0[0]) * f0[1]; f[2] = f0[0] * (1 - f0[1]);
+       // iteration
+       for (j = 0; j < ITER_MAX; ++j) {
+               double eps = 0;
+               memcpy(flast, f, 4 * sizeof(double));
+               pair_freq_iter(n_smpl, pdg, f);
+               for (i = 0; i < 4; ++i) {
+                       double x = fabs(f[i] - flast[i]);
+                       if (x > eps) eps = x;
+               }
+               if (eps < EPS) break;
+       }
+       // free
+       free(pdg[0]); free(pdg[1]);
+       { // calculate r^2
+               double p[2], q[2], D;
+               p[0] = f[0] + f[1]; q[0] = 1 - p[0];
+               p[1] = f[0] + f[2]; q[1] = 1 - p[1];
+               D = f[0] * f[3] - f[1] * f[2];
+               r = sqrt(D * D / (p[0] * p[1] * q[0] * q[1]));
+//             printf("R(%lf,%lf,%lf,%lf)=%lf\n", f[0], f[1], f[2], f[3], r);
+               if (isnan(r)) r = -1.;
+       }
+       return r;
+}
index a4fc7752a1f1e260b6c530e35c7e0eadcbd949bd..cbd358507405729f44f7eda8b58dda7ca64a269d 100644 (file)
@@ -66,7 +66,8 @@ double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double
 
        n1_ = n11 + n12; n_1 = n11 + n21; n = n11 + n12 + n21 + n22; // calculate n1_, n_1 and n
        max = (n_1 < n1_) ? n_1 : n1_; // max n11, for right tail
-       min = (n1_ + n_1 - n < 0) ? 0 : (n1_ + n_1 - n < 0); // min n11, for left tail
+       min = n1_ + n_1 - n;
+       if (min < 0) min = 0; // min n11, for left tail
        *two = *_left = *_right = 1.;
        if (min == max) return 1.; // no need to do test
        q = hypergeo_acc(n11, n1_, n_1, n, &aux); // the probability of the current table
@@ -81,6 +82,7 @@ double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double
        p = hypergeo_acc(max, 0, 0, 0, &aux);
        for (right = 0., j = max - 1; p < 0.99999999 * q; --j) // loop until underflow
                right += p, p = hypergeo_acc(j, 0, 0, 0, &aux);
+       ++j;
        if (p < 1.00000001 * q) right += p;
        else ++j;
        // two-tail
diff --git a/samtools/bcftools/kmin.c.pysam.c b/samtools/bcftools/kmin.c.pysam.c
new file mode 100644 (file)
index 0000000..ee7b512
--- /dev/null
@@ -0,0 +1,211 @@
+#include "pysam.h"
+
+/* The MIT License
+
+   Copyright (c) 2008, 2010 by Attractive Chaos <attractor@live.co.uk>
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   "Software"), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+   SOFTWARE.
+*/
+
+/* Hooke-Jeeves algorithm for nonlinear minimization
+   Based on the pseudocodes by Bell and Pike (CACM 9(9):684-685), and
+   the revision by Tomlin and Smith (CACM 12(11):637-638). Both of the
+   papers are comments on Kaupe's Algorithm 178 "Direct Search" (ACM
+   6(6):313-314). The original algorithm was designed by Hooke and
+   Jeeves (ACM 8:212-229). This program is further revised according to
+   Johnson's implementation at Netlib (opt/hooke.c).
+   Hooke-Jeeves algorithm is very simple and it works quite well on a
+   few examples. However, it might fail to converge due to its heuristic
+   nature. A possible improvement, as is suggested by Johnson, may be to
+   choose a small r at the beginning to quickly approach to the minimum
+   and a large r at later step to hit the minimum.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "kmin.h"
+
+static double __kmin_hj_aux(kmin_f func, int n, double *x1, void *data, double fx1, double *dx, int *n_calls)
+{
+       int k, j = *n_calls;
+       double ftmp;
+       for (k = 0; k != n; ++k) {
+               x1[k] += dx[k];
+               ftmp = func(n, x1, data); ++j;
+               if (ftmp < fx1) fx1 = ftmp;
+               else { /* search the opposite direction */
+                       dx[k] = 0.0 - dx[k];
+                       x1[k] += dx[k] + dx[k];
+                       ftmp = func(n, x1, data); ++j;
+                       if (ftmp < fx1) fx1 = ftmp;
+                       else x1[k] -= dx[k]; /* back to the original x[k] */
+               }
+       }
+       *n_calls = j;
+       return fx1; /* here: fx1=f(n,x1) */
+}
+
+double kmin_hj(kmin_f func, int n, double *x, void *data, double r, double eps, int max_calls)
+{
+       double fx, fx1, *x1, *dx, radius;
+       int k, n_calls = 0;
+       x1 = (double*)calloc(n, sizeof(double));
+       dx = (double*)calloc(n, sizeof(double));
+       for (k = 0; k != n; ++k) { /* initial directions, based on MGJ */
+               dx[k] = fabs(x[k]) * r;
+               if (dx[k] == 0) dx[k] = r;
+       }
+       radius = r;
+       fx1 = fx = func(n, x, data); ++n_calls;
+       for (;;) {
+               memcpy(x1, x, n * sizeof(double)); /* x1 = x */
+               fx1 = __kmin_hj_aux(func, n, x1, data, fx, dx, &n_calls);
+               while (fx1 < fx) {
+                       for (k = 0; k != n; ++k) {
+                               double t = x[k];
+                               dx[k] = x1[k] > x[k]? fabs(dx[k]) : 0.0 - fabs(dx[k]);
+                               x[k] = x1[k];
+                               x1[k] = x1[k] + x1[k] - t;
+                       }
+                       fx = fx1;
+                       if (n_calls >= max_calls) break;
+                       fx1 = func(n, x1, data); ++n_calls;
+                       fx1 = __kmin_hj_aux(func, n, x1, data, fx1, dx, &n_calls);
+                       if (fx1 >= fx) break;
+                       for (k = 0; k != n; ++k)
+                               if (fabs(x1[k] - x[k]) > .5 * fabs(dx[k])) break;
+                       if (k == n) break;
+               }
+               if (radius >= eps) {
+                       if (n_calls >= max_calls) break;
+                       radius *= r;
+                       for (k = 0; k != n; ++k) dx[k] *= r;
+               } else break; /* converge */
+       }
+       free(x1); free(dx);
+       return fx1;
+}
+
+// I copied this function somewhere several years ago with some of my modifications, but I forgot the source.
+double kmin_brent(kmin1_f func, double a, double b, void *data, double tol, double *xmin)
+{
+       double bound, u, r, q, fu, tmp, fa, fb, fc, c;
+       const double gold1 = 1.6180339887;
+       const double gold2 = 0.3819660113;
+       const double tiny = 1e-20;
+       const int max_iter = 100;
+
+       double e, d, w, v, mid, tol1, tol2, p, eold, fv, fw;
+       int iter;
+
+       fa = func(a, data); fb = func(b, data);
+       if (fb > fa) { // swap, such that f(a) > f(b)
+               tmp = a; a = b; b = tmp;
+               tmp = fa; fa = fb; fb = tmp;
+       }
+       c = b + gold1 * (b - a), fc = func(c, data); // golden section extrapolation
+       while (fb > fc) {
+               bound = b + 100.0 * (c - b); // the farthest point where we want to go
+               r = (b - a) * (fb - fc);
+               q = (b - c) * (fb - fa);
+               if (fabs(q - r) < tiny) { // avoid 0 denominator
+                       tmp = q > r? tiny : 0.0 - tiny;
+               } else tmp = q - r;
+               u = b - ((b - c) * q - (b - a) * r) / (2.0 * tmp); // u is the parabolic extrapolation point
+               if ((b > u && u > c) || (b < u && u < c)) { // u lies between b and c
+                       fu = func(u, data);
+                       if (fu < fc) { // (b,u,c) bracket the minimum
+                               a = b; b = u; fa = fb; fb = fu;
+                               break;
+                       } else if (fu > fb) { // (a,b,u) bracket the minimum
+                               c = u; fc = fu;
+                               break;
+                       }
+                       u = c + gold1 * (c - b); fu = func(u, data); // golden section extrapolation
+               } else if ((c > u && u > bound) || (c < u && u < bound)) { // u lies between c and bound
+                       fu = func(u, data);
+                       if (fu < fc) { // fb > fc > fu
+                               b = c; c = u; u = c + gold1 * (c - b);
+                               fb = fc; fc = fu; fu = func(u, data);
+                       } else { // (b,c,u) bracket the minimum
+                               a = b; b = c; c = u;
+                               fa = fb; fb = fc; fc = fu;
+                               break;
+                       }
+               } else if ((u > bound && bound > c) || (u < bound && bound < c)) { // u goes beyond the bound
+                       u = bound; fu = func(u, data);
+               } else { // u goes the other way around, use golden section extrapolation
+                       u = c + gold1 * (c - b); fu = func(u, data);
+               }
+               a = b; b = c; c = u;
+               fa = fb; fb = fc; fc = fu;
+       }
+       if (a > c) u = a, a = c, c = u; // swap
+
+       // now, a<b<c, fa>fb and fb<fc, move on to Brent's algorithm
+       e = d = 0.0;
+       w = v = b; fv = fw = fb;
+       for (iter = 0; iter != max_iter; ++iter) {
+               mid = 0.5 * (a + c);
+               tol2 = 2.0 * (tol1 = tol * fabs(b) + tiny);
+               if (fabs(b - mid) <= (tol2 - 0.5 * (c - a))) {
+                       *xmin = b; return fb; // found
+               }
+               if (fabs(e) > tol1) {
+                       // related to parabolic interpolation
+                       r = (b - w) * (fb - fv);
+                       q = (b - v) * (fb - fw);
+                       p = (b - v) * q - (b - w) * r;
+                       q = 2.0 * (q - r);
+                       if (q > 0.0) p = 0.0 - p;
+                       else q = 0.0 - q;
+                       eold = e; e = d;
+                       if (fabs(p) >= fabs(0.5 * q * eold) || p <= q * (a - b) || p >= q * (c - b)) {
+                               d = gold2 * (e = (b >= mid ? a - b : c - b));
+                       } else {
+                               d = p / q; u = b + d; // actual parabolic interpolation happens here
+                               if (u - a < tol2 || c - u < tol2)
+                                       d = (mid > b)? tol1 : 0.0 - tol1;
+                       }
+               } else d = gold2 * (e = (b >= mid ? a - b : c - b)); // golden section interpolation
+               u = fabs(d) >= tol1 ? b + d : b + (d > 0.0? tol1 : -tol1);
+               fu = func(u, data);
+               if (fu <= fb) { // u is the minimum point so far
+                       if (u >= b) a = b;
+                       else c = b;
+                       v = w; w = b; b = u; fv = fw; fw = fb; fb = fu;
+               } else { // adjust (a,c) and (u,v,w)
+                       if (u < b) a = u;
+                       else c = u;
+                       if (fu <= fw || w == b) {
+                               v = w; w = u;
+                               fv = fw; fw = fu;
+                       } else if (fu <= fv || v == b || v == w) {
+                               v = u; fv = fu;
+                       }
+               }
+       }
+       *xmin = b;
+       return fb;
+}
diff --git a/samtools/bcftools/kmin.h b/samtools/bcftools/kmin.h
new file mode 100644 (file)
index 0000000..6feba45
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+   Copyright (c) 2008, 2010 by Attractive Chaos <attractor@live.co.uk>
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   "Software"), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+   SOFTWARE.
+*/
+
+#ifndef KMIN_H
+#define KMIN_H
+
+#define KMIN_RADIUS  0.5
+#define KMIN_EPS     1e-7
+#define KMIN_MAXCALL 50000
+
+typedef double (*kmin_f)(int, double*, void*);
+typedef double (*kmin1_f)(double, void*);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+       double kmin_hj(kmin_f func, int n, double *x, void *data, double r, double eps, int max_calls);
+       double kmin_brent(kmin1_f func, double a, double b, void *data, double tol, double *xmin);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/samtools/bcftools/ld.c.pysam.c b/samtools/bcftools/ld.c.pysam.c
deleted file mode 100644 (file)
index 2b7bf47..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "pysam.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "bcf.h"
-
-static double g_q2p[256];
-
-#define LD_ITER_MAX 50
-#define LD_ITER_EPS 1e-4
-
-#define _G1(h, k) ((h>>1&1) + (k>>1&1))
-#define _G2(h, k) ((h&1) + (k&1))
-
-// 0: the previous site; 1: the current site
-static int freq_iter(int n, double *pdg[2], double f[4])
-{
-       double ff[4];
-       int i, k, h;
-       memset(ff, 0, 4 * sizeof(double));
-       for (i = 0; i < n; ++i) {
-               double *p[2], sum, tmp;
-               p[0] = pdg[0] + i * 3; p[1] = pdg[1] + i * 3;
-               for (k = 0, sum = 0.; k < 4; ++k)
-                       for (h = 0; h < 4; ++h)
-                               sum += f[k] * f[h] * p[0][_G1(k,h)] * p[1][_G2(k,h)];
-               for (k = 0; k < 4; ++k) {
-                       tmp = f[0] * (p[0][_G1(0,k)] * p[1][_G2(0,k)] + p[0][_G1(k,0)] * p[1][_G2(k,0)])
-                               + f[1] * (p[0][_G1(1,k)] * p[1][_G2(1,k)] + p[0][_G1(k,1)] * p[1][_G2(k,1)])
-                               + f[2] * (p[0][_G1(2,k)] * p[1][_G2(2,k)] + p[0][_G1(k,2)] * p[1][_G2(k,2)])
-                               + f[3] * (p[0][_G1(3,k)] * p[1][_G2(3,k)] + p[0][_G1(k,3)] * p[1][_G2(k,3)]);
-                       ff[k] += f[k] * tmp / sum;
-               }
-       }
-       for (k = 0; k < 4; ++k) f[k] = ff[k] / (2 * n);
-       return 0;
-}
-
-double bcf_ld_freq(const bcf1_t *b0, const bcf1_t *b1, double f[4])
-{
-       const bcf1_t *b[2];
-       uint8_t *PL[2];
-       int i, j, PL_len[2], n_smpl;
-       double *pdg[2], flast[4], r;
-       // initialize g_q2p if necessary
-       if (g_q2p[0] == 0.)
-               for (i = 0; i < 256; ++i)
-                       g_q2p[i] = pow(10., -i / 10.);
-       // initialize others
-       if (b0->n_smpl != b1->n_smpl) return -1; // different number of samples
-       n_smpl = b0->n_smpl;
-       b[0] = b0; b[1] = b1;
-       f[0] = f[1] = f[2] = f[3] = -1.;
-       if (b[0]->n_alleles < 2 || b[1]->n_alleles < 2) return -1; // one allele only
-       // set PL and PL_len
-       for (j = 0; j < 2; ++j) {
-               const bcf1_t *bj = b[j];
-               for (i = 0; i < bj->n_gi; ++i) {
-                       if (bj->gi[i].fmt == bcf_str2int("PL", 2)) {
-                               PL[j] = (uint8_t*)bj->gi[i].data;
-                               PL_len[j] = bj->gi[i].len;
-                               break;
-                       }
-               }
-               if (i == bj->n_gi) return -1; // no PL
-       }
-       // fill pdg[2]
-       pdg[0] = malloc(3 * n_smpl * sizeof(double));
-       pdg[1] = malloc(3 * n_smpl * sizeof(double));
-       for (j = 0; j < 2; ++j) {
-               for (i = 0; i < n_smpl; ++i) {
-                       const uint8_t *pi = PL[j] + i * PL_len[j];
-                       double *p = pdg[j] + i * 3;
-                       p[0] = g_q2p[pi[b[j]->n_alleles]]; p[1] = g_q2p[pi[1]]; p[2] = g_q2p[pi[0]];
-               }
-       }
-       // iteration
-       f[0] = f[1] = f[2] = f[3] = 0.25; // this is a really bad guess...
-       for (j = 0; j < LD_ITER_MAX; ++j) {
-               double eps = 0;
-               memcpy(flast, f, 4 * sizeof(double));
-               freq_iter(n_smpl, pdg, f);
-               for (i = 0; i < 4; ++i) {
-                       double x = fabs(f[i] - flast[i]);
-                       if (x > eps) eps = x;
-               }
-               if (eps < LD_ITER_EPS) break;
-       }
-       // free
-       free(pdg[0]); free(pdg[1]);
-       { // calculate r^2
-               double p[2], q[2], D;
-               p[0] = f[0] + f[1]; q[0] = 1 - p[0];
-               p[1] = f[0] + f[2]; q[1] = 1 - p[1];
-               D = f[0] * f[3] - f[1] * f[2];
-               r = sqrt(D * D / (p[0] * p[1] * q[0] * q[1]));
-               // fprintf(pysamerr, "R(%lf,%lf,%lf,%lf)=%lf\n", f[0], f[1], f[2], f[3], r2);
-               if (isnan(r)) r = -1.;
-       }
-       return r;
-}
index 7738c391094130e630593aeb74bc62866698b585..ac331848f624e466091552f6291ea46e0d239062 100644 (file)
@@ -5,13 +5,14 @@
 #include <string.h>
 #include <stdio.h>
 #include <errno.h>
+#include <assert.h>
 #include "prob1.h"
 
 #include "kseq.h"
 KSTREAM_INIT(gzFile, gzread, 16384)
 
 #define MC_MAX_EM_ITER 16
-#define MC_EM_EPS 1e-4
+#define MC_EM_EPS 1e-5
 #define MC_DEF_INDEL 0.15
 
 unsigned char seq_nt4_table[256] = {
@@ -34,24 +35,20 @@ unsigned char seq_nt4_table[256] = {
 };
 
 struct __bcf_p1aux_t {
-       int n, M, n1, is_indel, is_folded;
+       int n, M, n1, is_indel;
+       uint8_t *ploidy; // haploid or diploid ONLY
        double *q2p, *pdg; // pdg -> P(D|g)
        double *phi, *phi_indel;
        double *z, *zswap; // aux for afs
        double *z1, *z2, *phi1, *phi2; // only calculated when n1 is set
+       double **hg; // hypergeometric distribution
+       double *lf; // log factorial
        double t, t1, t2;
        double *afs, *afs1; // afs: accumulative AFS; afs1: site posterior distribution
        const uint8_t *PL; // point to PL
        int PL_len;
 };
 
-static void fold_array(int M, double *x)
-{
-       int k;
-       for (k = 0; k < M/2; ++k)
-               x[k] = x[M-k] = (x[k] + x[M-k]) / 2.;
-}
-
 void bcf_p1_indel_prior(bcf_p1aux_t *ma, double x)
 {
        int i;
@@ -132,27 +129,38 @@ int bcf_p1_read_prior(bcf_p1aux_t *ma, const char *fn)
        return 0;
 }
 
-bcf_p1aux_t *bcf_p1_init(int n)
+bcf_p1aux_t *bcf_p1_init(int n, uint8_t *ploidy)
 {
        bcf_p1aux_t *ma;
        int i;
        ma = calloc(1, sizeof(bcf_p1aux_t));
        ma->n1 = -1;
        ma->n = n; ma->M = 2 * n;
+       if (ploidy) {
+               ma->ploidy = malloc(n);
+               memcpy(ma->ploidy, ploidy, n);
+               for (i = 0, ma->M = 0; i < n; ++i) ma->M += ploidy[i];
+               if (ma->M == 2 * n) {
+                       free(ma->ploidy);
+                       ma->ploidy = 0;
+               }
+       }
        ma->q2p = calloc(256, sizeof(double));
        ma->pdg = calloc(3 * ma->n, sizeof(double));
        ma->phi = calloc(ma->M + 1, sizeof(double));
        ma->phi_indel = calloc(ma->M + 1, sizeof(double));
        ma->phi1 = calloc(ma->M + 1, sizeof(double));
        ma->phi2 = calloc(ma->M + 1, sizeof(double));
-       ma->z = calloc(2 * ma->n + 1, sizeof(double));
-       ma->zswap = calloc(2 * ma->n + 1, sizeof(double));
+       ma->z = calloc(ma->M + 1, sizeof(double));
+       ma->zswap = calloc(ma->M + 1, sizeof(double));
        ma->z1 = calloc(ma->M + 1, sizeof(double)); // actually we do not need this large
        ma->z2 = calloc(ma->M + 1, sizeof(double));
-       ma->afs = calloc(2 * ma->n + 1, sizeof(double));
-       ma->afs1 = calloc(2 * ma->n + 1, sizeof(double));
+       ma->afs = calloc(ma->M + 1, sizeof(double));
+       ma->afs1 = calloc(ma->M + 1, sizeof(double));
+       ma->lf = calloc(ma->M + 1, sizeof(double));
        for (i = 0; i < 256; ++i)
                ma->q2p[i] = pow(10., -i / 10.);
+       for (i = 0; i <= ma->M; ++i) ma->lf[i] = lgamma(i + 1);
        bcf_p1_init_prior(ma, MC_PTYPE_FULL, 1e-3); // the simplest prior
        return ma;
 }
@@ -160,23 +168,24 @@ bcf_p1aux_t *bcf_p1_init(int n)
 int bcf_p1_set_n1(bcf_p1aux_t *b, int n1)
 {
        if (n1 == 0 || n1 >= b->n) return -1;
+       if (b->M != b->n * 2) {
+               fprintf(pysamerr, "[%s] unable to set `n1' when there are haploid samples.\n", __func__);
+               return -1;
+       }
        b->n1 = n1;
        return 0;
 }
 
-void bcf_p1_set_folded(bcf_p1aux_t *p1a)
-{
-       if (p1a->n1 < 0) {
-               p1a->is_folded = 1;
-               fold_array(p1a->M, p1a->phi);
-               fold_array(p1a->M, p1a->phi_indel);
-       }
-}
-
 void bcf_p1_destroy(bcf_p1aux_t *ma)
 {
        if (ma) {
-               free(ma->q2p); free(ma->pdg);
+               int k;
+               free(ma->lf);
+               if (ma->hg && ma->n1 > 0) {
+                       for (k = 0; k <= 2*ma->n1; ++k) free(ma->hg[k]);
+                       free(ma->hg);
+               }
+               free(ma->ploidy); free(ma->q2p); free(ma->pdg);
                free(ma->phi); free(ma->phi_indel); free(ma->phi1); free(ma->phi2);
                free(ma->z); free(ma->zswap); free(ma->z1); free(ma->z2);
                free(ma->afs); free(ma->afs1);
@@ -186,18 +195,16 @@ void bcf_p1_destroy(bcf_p1aux_t *ma)
 
 static int cal_pdg(const bcf1_t *b, bcf_p1aux_t *ma)
 {
-       int i, j, k;
+       int i, j;
        long *p, tmp;
        p = alloca(b->n_alleles * sizeof(long));
        memset(p, 0, sizeof(long) * b->n_alleles);
        for (j = 0; j < ma->n; ++j) {
                const uint8_t *pi = ma->PL + j * ma->PL_len;
                double *pdg = ma->pdg + j * 3;
-               pdg[0] = ma->q2p[pi[b->n_alleles]]; pdg[1] = ma->q2p[pi[1]]; pdg[2] = ma->q2p[pi[0]];
-               for (i = k = 0; i < b->n_alleles; ++i) {
-                       p[i] += (int)pi[k];
-                       k += b->n_alleles - i;
-               }
+               pdg[0] = ma->q2p[pi[2]]; pdg[1] = ma->q2p[pi[1]]; pdg[2] = ma->q2p[pi[0]];
+               for (i = 0; i < b->n_alleles; ++i)
+                       p[i] += (int)pi[(i+1)*(i+2)/2-1];
        }
        for (i = 0; i < b->n_alleles; ++i) p[i] = p[i]<<4 | i;
        for (i = 1; i < b->n_alleles; ++i) // insertion sort
@@ -207,28 +214,18 @@ static int cal_pdg(const bcf1_t *b, bcf_p1aux_t *ma)
                if ((p[i]&0xf) == 0) break;
        return i;
 }
-// f0 is the reference allele frequency
-static double mc_freq_iter(double f0, const bcf_p1aux_t *ma)
-{
-       double f, f3[3];
-       int i;
-       f3[0] = (1.-f0)*(1.-f0); f3[1] = 2.*f0*(1.-f0); f3[2] = f0*f0;
-       for (i = 0, f = 0.; i < ma->n; ++i) {
-               double *pdg;
-               pdg = ma->pdg + i * 3;
-               f += (pdg[1] * f3[1] + 2. * pdg[2] * f3[2])
-                       / (pdg[0] * f3[0] + pdg[1] * f3[1] + pdg[2] * f3[2]);
-       }
-       f /= ma->n * 2.;
-       return f;
-}
 
 int bcf_p1_call_gt(const bcf_p1aux_t *ma, double f0, int k)
 {
        double sum, g[3];
        double max, f3[3], *pdg = ma->pdg + k * 3;
-       int q, i, max_i;
-       f3[0] = (1.-f0)*(1.-f0); f3[1] = 2.*f0*(1.-f0); f3[2] = f0*f0;
+       int q, i, max_i, ploidy;
+       ploidy = ma->ploidy? ma->ploidy[k] : 2;
+       if (ploidy == 2) {
+               f3[0] = (1.-f0)*(1.-f0); f3[1] = 2.*f0*(1.-f0); f3[2] = f0*f0;
+       } else {
+               f3[0] = 1. - f0; f3[1] = 0; f3[2] = f0;
+       }
        for (i = 0, sum = 0.; i < 3; ++i)
                sum += (g[i] = pdg[i] * f3[i]);
        for (i = 0, max = -1., max_i = 0; i < 3; ++i) {
@@ -248,6 +245,7 @@ static void mc_cal_y_core(bcf_p1aux_t *ma, int beg)
 {
        double *z[2], *tmp, *pdg;
        int _j, last_min, last_max;
+       assert(beg == 0 || ma->M == ma->n*2);
        z[0] = ma->z;
        z[1] = ma->zswap;
        pdg = ma->pdg;
@@ -256,41 +254,81 @@ static void mc_cal_y_core(bcf_p1aux_t *ma, int beg)
        z[0][0] = 1.;
        last_min = last_max = 0;
        ma->t = 0.;
-       for (_j = beg; _j < ma->n; ++_j) {
-               int k, j = _j - beg, _min = last_min, _max = last_max;
-               double p[3], sum;
-               pdg = ma->pdg + _j * 3;
-               p[0] = pdg[0]; p[1] = 2. * pdg[1]; p[2] = pdg[2];
-               for (; _min < _max && z[0][_min] < TINY; ++_min) z[0][_min] = z[1][_min] = 0.;
-               for (; _max > _min && z[0][_max] < TINY; --_max) z[0][_max] = z[1][_max] = 0.;
-               _max += 2;
-               if (_min == 0) 
-                       k = 0, z[1][k] = (2*j+2-k)*(2*j-k+1) * p[0] * z[0][k];
-               if (_min <= 1)
-                       k = 1, z[1][k] = (2*j+2-k)*(2*j-k+1) * p[0] * z[0][k] + k*(2*j+2-k) * p[1] * z[0][k-1];
-               for (k = _min < 2? 2 : _min; k <= _max; ++k)
-                       z[1][k] = (2*j+2-k)*(2*j-k+1) * p[0] * z[0][k]
-                               + k*(2*j+2-k) * p[1] * z[0][k-1]
-                               + k*(k-1)* p[2] * z[0][k-2];
-               for (k = _min, sum = 0.; k <= _max; ++k) sum += z[1][k];
-               ma->t += log(sum / ((2. * j + 2) * (2. * j + 1)));
-               for (k = _min; k <= _max; ++k) z[1][k] /= sum;
-               if (_min >= 1) z[1][_min-1] = 0.;
-               if (_min >= 2) z[1][_min-2] = 0.;
-               if (j < ma->n - 1) z[1][_max+1] = z[1][_max+2] = 0.;
-               if (_j == ma->n1 - 1) { // set pop1
-                       ma->t1 = ma->t;
-                       memcpy(ma->z1, z[1], sizeof(double) * (ma->n1 * 2 + 1));
+       if (ma->M == ma->n * 2) {
+               int M = 0;
+               for (_j = beg; _j < ma->n; ++_j) {
+                       int k, j = _j - beg, _min = last_min, _max = last_max, M0;
+                       double p[3], sum;
+                       M0 = M; M += 2;
+                       pdg = ma->pdg + _j * 3;
+                       p[0] = pdg[0]; p[1] = 2. * pdg[1]; p[2] = pdg[2];
+                       for (; _min < _max && z[0][_min] < TINY; ++_min) z[0][_min] = z[1][_min] = 0.;
+                       for (; _max > _min && z[0][_max] < TINY; --_max) z[0][_max] = z[1][_max] = 0.;
+                       _max += 2;
+                       if (_min == 0) k = 0, z[1][k] = (M0-k+1) * (M0-k+2) * p[0] * z[0][k];
+                       if (_min <= 1) k = 1, z[1][k] = (M0-k+1) * (M0-k+2) * p[0] * z[0][k] + k*(M0-k+2) * p[1] * z[0][k-1];
+                       for (k = _min < 2? 2 : _min; k <= _max; ++k)
+                               z[1][k] = (M0-k+1)*(M0-k+2) * p[0] * z[0][k] + k*(M0-k+2) * p[1] * z[0][k-1] + k*(k-1)* p[2] * z[0][k-2];
+                       for (k = _min, sum = 0.; k <= _max; ++k) sum += z[1][k];
+                       ma->t += log(sum / (M * (M - 1.)));
+                       for (k = _min; k <= _max; ++k) z[1][k] /= sum;
+                       if (_min >= 1) z[1][_min-1] = 0.;
+                       if (_min >= 2) z[1][_min-2] = 0.;
+                       if (j < ma->n - 1) z[1][_max+1] = z[1][_max+2] = 0.;
+                       if (_j == ma->n1 - 1) { // set pop1; ma->n1==-1 when unset
+                               ma->t1 = ma->t;
+                               memcpy(ma->z1, z[1], sizeof(double) * (ma->n1 * 2 + 1));
+                       }
+                       tmp = z[0]; z[0] = z[1]; z[1] = tmp;
+                       last_min = _min; last_max = _max;
+               }
+               //for (_j = 0; _j < last_min; ++_j) z[0][_j] = 0.; // TODO: are these necessary?
+               //for (_j = last_max + 1; _j < ma->M; ++_j) z[0][_j] = 0.;
+       } else { // this block is very similar to the block above; these two might be merged in future
+               int j, M = 0;
+               for (j = 0; j < ma->n; ++j) {
+                       int k, M0, _min = last_min, _max = last_max;
+                       double p[3], sum;
+                       pdg = ma->pdg + j * 3;
+                       for (; _min < _max && z[0][_min] < TINY; ++_min) z[0][_min] = z[1][_min] = 0.;
+                       for (; _max > _min && z[0][_max] < TINY; --_max) z[0][_max] = z[1][_max] = 0.;
+                       M0 = M;
+                       M += ma->ploidy[j];
+                       if (ma->ploidy[j] == 1) {
+                               p[0] = pdg[0]; p[1] = pdg[2];
+                               _max++;
+                               if (_min == 0) k = 0, z[1][k] = (M0+1-k) * p[0] * z[0][k];
+                               for (k = _min < 1? 1 : _min; k <= _max; ++k)
+                                       z[1][k] = (M0+1-k) * p[0] * z[0][k] + k * p[1] * z[0][k-1];
+                               for (k = _min, sum = 0.; k <= _max; ++k) sum += z[1][k];
+                               ma->t += log(sum / M);
+                               for (k = _min; k <= _max; ++k) z[1][k] /= sum;
+                               if (_min >= 1) z[1][_min-1] = 0.;
+                               if (j < ma->n - 1) z[1][_max+1] = 0.;
+                       } else if (ma->ploidy[j] == 2) {
+                               p[0] = pdg[0]; p[1] = 2 * pdg[1]; p[2] = pdg[2];
+                               _max += 2;
+                               if (_min == 0) k = 0, z[1][k] = (M0-k+1) * (M0-k+2) * p[0] * z[0][k];
+                               if (_min <= 1) k = 1, z[1][k] = (M0-k+1) * (M0-k+2) * p[0] * z[0][k] + k*(M0-k+2) * p[1] * z[0][k-1];
+                               for (k = _min < 2? 2 : _min; k <= _max; ++k)
+                                       z[1][k] = (M0-k+1)*(M0-k+2) * p[0] * z[0][k] + k*(M0-k+2) * p[1] * z[0][k-1] + k*(k-1)* p[2] * z[0][k-2];
+                               for (k = _min, sum = 0.; k <= _max; ++k) sum += z[1][k];
+                               ma->t += log(sum / (M * (M - 1.)));
+                               for (k = _min; k <= _max; ++k) z[1][k] /= sum;
+                               if (_min >= 1) z[1][_min-1] = 0.;
+                               if (_min >= 2) z[1][_min-2] = 0.;
+                               if (j < ma->n - 1) z[1][_max+1] = z[1][_max+2] = 0.;
+                       }
+                       tmp = z[0]; z[0] = z[1]; z[1] = tmp;
+                       last_min = _min; last_max = _max;
                }
-               tmp = z[0]; z[0] = z[1]; z[1] = tmp;
-               last_min = _min; last_max = _max;
        }
        if (z[0] != ma->z) memcpy(ma->z, z[0], sizeof(double) * (ma->M + 1));
 }
 
 static void mc_cal_y(bcf_p1aux_t *ma)
 {
-       if (ma->n1 > 0 && ma->n1 < ma->n) {
+       if (ma->n1 > 0 && ma->n1 < ma->n && ma->M == ma->n * 2) { // NB: ma->n1 is ineffective when there are haploid samples
                int k;
                long double x;
                memset(ma->z1, 0, sizeof(double) * (2 * ma->n1 + 1));
@@ -306,41 +344,131 @@ static void mc_cal_y(bcf_p1aux_t *ma)
        } else mc_cal_y_core(ma, 0);
 }
 
-static void contrast(bcf_p1aux_t *ma, double pc[4]) // mc_cal_y() must be called before hand
+#define CONTRAST_TINY 1e-30
+
+extern double kf_gammaq(double s, double z); // incomplete gamma function for chi^2 test
+
+static inline double chi2_test(int a, int b, int c, int d)
+{
+       double x, z;
+       x = (double)(a+b) * (c+d) * (b+d) * (a+c);
+       if (x == 0.) return 1;
+       z = a * d - b * c;
+       return kf_gammaq(.5, .5 * z * z * (a+b+c+d) / x);
+}
+
+// chi2=(a+b+c+d)(ad-bc)^2/[(a+b)(c+d)(a+c)(b+d)]
+static inline double contrast2_aux(const bcf_p1aux_t *p1, double sum, int k1, int k2, double x[3])
+{
+       double p = p1->phi[k1+k2] * p1->z1[k1] * p1->z2[k2] / sum * p1->hg[k1][k2];
+       int n1 = p1->n1, n2 = p1->n - p1->n1;
+       if (p < CONTRAST_TINY) return -1;
+       if (.5*k1/n1 < .5*k2/n2) x[1] += p;
+       else if (.5*k1/n1 > .5*k2/n2) x[2] += p;
+       else x[0] += p;
+       return p * chi2_test(k1, k2, (n1<<1) - k1, (n2<<1) - k2);
+}
+
+static double contrast2(bcf_p1aux_t *p1, double ret[3])
 {
-       int k, n1 = ma->n1, n2 = ma->n - ma->n1;
-       long double sum1, sum2;
-       pc[0] = pc[1] = pc[2] = pc[3] = -1.;
-       if (n1 <= 0 || n2 <= 0) return;
-       for (k = 0, sum1 = 0.; k <= 2*n1; ++k) sum1 += ma->phi1[k] * ma->z1[k];
-       for (k = 0, sum2 = 0.; k <= 2*n2; ++k) sum2 += ma->phi2[k] * ma->z2[k];
-       pc[2] = ma->phi1[2*n1] * ma->z1[2*n1] / sum1;
-       pc[3] = ma->phi2[2*n2] * ma->z2[2*n2] / sum2;
-       for (k = 2; k < 4; ++k) {
-               pc[k] = pc[k] > .5? -(-4.343 * log(1. - pc[k] + TINY) + .499) : -4.343 * log(pc[k] + TINY) + .499;
-               pc[k] = (int)pc[k];
-               if (pc[k] > 99) pc[k] = 99;
-               if (pc[k] < -99) pc[k] = -99;
+       int k, k1, k2, k10, k20, n1, n2;
+       double sum;
+       // get n1 and n2
+       n1 = p1->n1; n2 = p1->n - p1->n1;
+       if (n1 <= 0 || n2 <= 0) return 0.;
+       if (p1->hg == 0) { // initialize the hypergeometric distribution
+               /* NB: the hg matrix may take a lot of memory when there are many samples. There is a way
+                  to avoid precomputing this matrix, but it is slower and quite intricate. The following
+                  computation in this block can be accelerated with a similar strategy, but perhaps this
+                  is not a serious concern for now. */
+               double tmp = lgamma(2*(n1+n2)+1) - (lgamma(2*n1+1) + lgamma(2*n2+1));
+               p1->hg = calloc(2*n1+1, sizeof(void*));
+               for (k1 = 0; k1 <= 2*n1; ++k1) {
+                       p1->hg[k1] = calloc(2*n2+1, sizeof(double));
+                       for (k2 = 0; k2 <= 2*n2; ++k2)
+                               p1->hg[k1][k2] = exp(lgamma(k1+k2+1) + lgamma(p1->M-k1-k2+1) - (lgamma(k1+1) + lgamma(k2+1) + lgamma(2*n1-k1+1) + lgamma(2*n2-k2+1) + tmp));
+               }
+       }
+       { // compute
+               long double suml = 0;
+               for (k = 0; k <= p1->M; ++k) suml += p1->phi[k] * p1->z[k];
+               sum = suml;
+       }
+       { // get the max k1 and k2
+               double max;
+               int max_k;
+               for (k = 0, max = 0, max_k = -1; k <= 2*n1; ++k) {
+                       double x = p1->phi1[k] * p1->z1[k];
+                       if (x > max) max = x, max_k = k;
+               }
+               k10 = max_k;
+               for (k = 0, max = 0, max_k = -1; k <= 2*n2; ++k) {
+                       double x = p1->phi2[k] * p1->z2[k];
+                       if (x > max) max = x, max_k = k;
+               }
+               k20 = max_k;
+       }
+       { // We can do the following with one nested loop, but that is an O(N^2) thing. The following code block is much faster for large N.
+               double x[3], y;
+               long double z = 0., L[2];
+               x[0] = x[1] = x[2] = 0; L[0] = L[1] = 0;
+               for (k1 = k10; k1 >= 0; --k1) {
+                       for (k2 = k20; k2 >= 0; --k2) {
+                               if ((y = contrast2_aux(p1, sum, k1, k2, x)) < 0) break;
+                               else z += y;
+                       }
+                       for (k2 = k20 + 1; k2 <= 2*n2; ++k2) {
+                               if ((y = contrast2_aux(p1, sum, k1, k2, x)) < 0) break;
+                               else z += y;
+                       }
+               }
+               ret[0] = x[0]; ret[1] = x[1]; ret[2] = x[2];
+               x[0] = x[1] = x[2] = 0;
+               for (k1 = k10 + 1; k1 <= 2*n1; ++k1) {
+                       for (k2 = k20; k2 >= 0; --k2) {
+                               if ((y = contrast2_aux(p1, sum, k1, k2, x)) < 0) break;
+                               else z += y;
+                       }
+                       for (k2 = k20 + 1; k2 <= 2*n2; ++k2) {
+                               if ((y = contrast2_aux(p1, sum, k1, k2, x)) < 0) break;
+                               else z += y;
+                       }
+               }
+               ret[0] += x[0]; ret[1] += x[1]; ret[2] += x[2];
+               if (ret[0] + ret[1] + ret[2] < 0.95) { // in case of bad things happened
+                       ret[0] = ret[1] = ret[2] = 0; L[0] = L[1] = 0;
+                       for (k1 = 0, z = 0.; k1 <= 2*n1; ++k1)
+                               for (k2 = 0; k2 <= 2*n2; ++k2)
+                                       if ((y = contrast2_aux(p1, sum, k1, k2, ret)) >= 0) z += y;
+                       if (ret[0] + ret[1] + ret[2] < 0.95) // It seems that this may be caused by floating point errors. I do not really understand why...
+                               z = 1.0, ret[0] = ret[1] = ret[2] = 1./3;
+               }
+               return (double)z;
        }
-       pc[0] = ma->phi2[2*n2] * ma->z2[2*n2] / sum2 * (1. - ma->phi1[2*n1] * ma->z1[2*n1] / sum1);
-       pc[1] = ma->phi1[2*n1] * ma->z1[2*n1] / sum1 * (1. - ma->phi2[2*n2] * ma->z2[2*n2] / sum2);
-       pc[0] = pc[0] == 1.? 99 : (int)(-4.343 * log(1. - pc[0]) + .499);
-       pc[1] = pc[1] == 1.? 99 : (int)(-4.343 * log(1. - pc[1]) + .499);
 }
 
-static double mc_cal_afs(bcf_p1aux_t *ma)
+static double mc_cal_afs(bcf_p1aux_t *ma, double *p_ref_folded, double *p_var_folded)
 {
        int k;
-       long double sum = 0.;
+       long double sum = 0., sum2;
        double *phi = ma->is_indel? ma->phi_indel : ma->phi;
        memset(ma->afs1, 0, sizeof(double) * (ma->M + 1));
        mc_cal_y(ma);
+       // compute AFS
        for (k = 0, sum = 0.; k <= ma->M; ++k)
                sum += (long double)phi[k] * ma->z[k];
        for (k = 0; k <= ma->M; ++k) {
                ma->afs1[k] = phi[k] * ma->z[k] / sum;
                if (isnan(ma->afs1[k]) || isinf(ma->afs1[k])) return -1.;
        }
+       // compute folded variant probability
+       for (k = 0, sum = 0.; k <= ma->M; ++k)
+               sum += (long double)(phi[k] + phi[ma->M - k]) / 2. * ma->z[k];
+       for (k = 1, sum2 = 0.; k < ma->M; ++k)
+               sum2 += (long double)(phi[k] + phi[ma->M - k]) / 2. * ma->z[k];
+       *p_var_folded = sum2 / sum;
+       *p_ref_folded = (phi[k] + phi[ma->M - k]) / 2. * (ma->z[ma->M] + ma->z[0]) / sum;
+       // the expected frequency
        for (k = 0, sum = 0.; k <= ma->M; ++k) {
                ma->afs[k] += ma->afs1[k];
                sum += k * ma->afs1[k];
@@ -348,37 +476,12 @@ static double mc_cal_afs(bcf_p1aux_t *ma)
        return sum / ma->M;
 }
 
-long double bcf_p1_cal_g3(bcf_p1aux_t *p1a, double g[3])
-{
-       long double pd = 0., g2[3];
-       int i, k;
-       memset(g2, 0, sizeof(long double) * 3);
-       for (k = 0; k < p1a->M; ++k) {
-               double f = (double)k / p1a->M, f3[3], g1[3];
-               long double z = 1.;
-               g1[0] = g1[1] = g1[2] = 0.;
-               f3[0] = (1. - f) * (1. - f); f3[1] = 2. * f * (1. - f); f3[2] = f * f;
-               for (i = 0; i < p1a->n; ++i) {
-                       double *pdg = p1a->pdg + i * 3;
-                       double x = pdg[0] * f3[0] + pdg[1] * f3[1] + pdg[2] * f3[2];
-                       z *= x;
-                       g1[0] += pdg[0] * f3[0] / x;
-                       g1[1] += pdg[1] * f3[1] / x;
-                       g1[2] += pdg[2] * f3[2] / x;
-               }
-               pd += p1a->phi[k] * z;
-               for (i = 0; i < 3; ++i)
-                       g2[i] += p1a->phi[k] * z * g1[i];
-       }
-       for (i = 0; i < 3; ++i) g[i] = g2[i] / pd;
-       return pd;
-}
-
-int bcf_p1_cal(bcf1_t *b, bcf_p1aux_t *ma, bcf_p1rst_t *rst)
+int bcf_p1_cal(const bcf1_t *b, int do_contrast, bcf_p1aux_t *ma, bcf_p1rst_t *rst)
 {
        int i, k;
        long double sum = 0.;
        ma->is_indel = bcf_is_indel(b);
+       rst->perm_rank = -1;
        // set PL and PL_len
        for (i = 0; i < b->n_gi; ++i) {
                if (b->gi[i].fmt == bcf_str2int("PL", 2)) {
@@ -387,11 +490,15 @@ int bcf_p1_cal(bcf1_t *b, bcf_p1aux_t *ma, bcf_p1rst_t *rst)
                        break;
                }
        }
+       if (i == b->n_gi) return -1; // no PL
        if (b->n_alleles < 2) return -1; // FIXME: find a better solution
        // 
        rst->rank0 = cal_pdg(b, ma);
-       rst->f_exp = mc_cal_afs(ma);
-       rst->p_ref = ma->is_folded? ma->afs1[ma->M] + ma->afs1[0] : ma->afs1[ma->M];
+       rst->f_exp = mc_cal_afs(ma, &rst->p_ref_folded, &rst->p_var_folded);
+       rst->p_ref = ma->afs1[ma->M];
+       for (k = 0, sum = 0.; k < ma->M; ++k)
+               sum += ma->afs1[k];
+       rst->p_var = (double)sum;
        // calculate f_flat and f_em
        for (k = 0, sum = 0.; k <= ma->M; ++k)
                sum += (long double)ma->z[k];
@@ -401,14 +508,6 @@ int bcf_p1_cal(bcf1_t *b, bcf_p1aux_t *ma, bcf_p1rst_t *rst)
                rst->f_flat += k * p;
        }
        rst->f_flat /= ma->M;
-       { // calculate f_em
-               double flast = rst->f_flat;
-               for (i = 0; i < MC_MAX_EM_ITER; ++i) {
-                       rst->f_em = mc_freq_iter(flast, ma);
-                       if (fabs(rst->f_em - flast) < MC_EM_EPS) break;
-                       flast = rst->f_em;
-               }
-       }
        { // estimate equal-tail credible interval (95% level)
                int l, h;
                double p;
@@ -422,15 +521,15 @@ int bcf_p1_cal(bcf1_t *b, bcf_p1aux_t *ma, bcf_p1rst_t *rst)
                h = i;
                rst->cil = (double)(ma->M - h) / ma->M; rst->cih = (double)(ma->M - l) / ma->M;
        }
-       rst->g[0] = rst->g[1] = rst->g[2] = -1.;
-       contrast(ma, rst->pc);
+       rst->cmp[0] = rst->cmp[1] = rst->cmp[2] = rst->p_chi2 = -1.0;
+       if (do_contrast && rst->p_var > 0.5) // skip contrast2() if the locus is a strong non-variant
+               rst->p_chi2 = contrast2(ma, rst->cmp);
        return 0;
 }
 
 void bcf_p1_dump_afs(bcf_p1aux_t *ma)
 {
        int k;
-       if (ma->is_folded) fold_array(ma->M, ma->afs);
        fprintf(pysamerr, "[afs]");
        for (k = 0; k <= ma->M; ++k)
                fprintf(pysamerr, " %d:%.3lf", k, ma->afs[ma->M - k]);
index 38275349750bde05f386387a36dc6ffdc0466223..571f42f1c63f5e93a4d1b601bd4843f7e1a48483 100644 (file)
@@ -7,11 +7,10 @@ struct __bcf_p1aux_t;
 typedef struct __bcf_p1aux_t bcf_p1aux_t;
 
 typedef struct {
-       int rank0;
-       double f_em, f_exp, f_flat, p_ref;
+       int rank0, perm_rank; // NB: perm_rank is always set to -1 by bcf_p1_cal()
+       double f_exp, f_flat, p_ref_folded, p_ref, p_var_folded, p_var;
        double cil, cih;
-       double pc[4];
-       double g[3];
+       double cmp[3], p_chi2; // used by contrast2()
 } bcf_p1rst_t;
 
 #define MC_PTYPE_FULL  1
@@ -22,18 +21,19 @@ typedef struct {
 extern "C" {
 #endif
 
-       bcf_p1aux_t *bcf_p1_init(int n);
+       bcf_p1aux_t *bcf_p1_init(int n, uint8_t *ploidy);
        void bcf_p1_init_prior(bcf_p1aux_t *ma, int type, double theta);
        void bcf_p1_init_subprior(bcf_p1aux_t *ma, int type, double theta);
        void bcf_p1_destroy(bcf_p1aux_t *ma);
-       int bcf_p1_cal(bcf1_t *b, bcf_p1aux_t *ma, bcf_p1rst_t *rst);
+       int bcf_p1_cal(const bcf1_t *b, int do_contrast, bcf_p1aux_t *ma, bcf_p1rst_t *rst);
        int bcf_p1_call_gt(const bcf_p1aux_t *ma, double f0, int k);
        void bcf_p1_dump_afs(bcf_p1aux_t *ma);
        int bcf_p1_read_prior(bcf_p1aux_t *ma, const char *fn);
-       long double bcf_p1_cal_g3(bcf_p1aux_t *p1a, double g[3]);
        int bcf_p1_set_n1(bcf_p1aux_t *b, int n1);
        void bcf_p1_set_folded(bcf_p1aux_t *p1a); // only effective when set_n1() is not called
 
+       int bcf_em1(const bcf1_t *b, int n1, int flag, double x[9]);
+
 #ifdef __cplusplus
 }
 #endif
index 5bad5c65fc1fc47dd68dcdf67e2e8fd3d78f0c71..a30de824ebd966fb69aec80713db0b10fd1fd282 100644 (file)
@@ -74,6 +74,33 @@ bcf_t *vcf_open(const char *fn, const char *mode)
        return bp;
 }
 
+int vcf_dictread(bcf_t *bp, bcf_hdr_t *h, const char *fn)
+{
+       vcf_t *v;
+       gzFile fp;
+       kstream_t *ks;
+       kstring_t s, rn;
+       int dret;
+       if (bp == 0) return -1;
+       if (!bp->is_vcf) return 0;
+       s.l = s.m = 0; s.s = 0;
+       rn.m = rn.l = h->l_nm; rn.s = h->name;
+       v = (vcf_t*)bp->v;
+       fp = gzopen(fn, "r");
+       ks = ks_init(fp);
+       while (ks_getuntil(ks, 0, &s, &dret) >= 0) {
+               bcf_str2id_add(v->refhash, strdup(s.s));
+               kputs(s.s, &rn); kputc('\0', &rn);
+               if (dret != '\n') ks_getuntil(ks, '\n', &s, &dret);
+       }
+       ks_destroy(ks);
+       gzclose(fp);
+       h->l_nm = rn.l; h->name = rn.s;
+       bcf_hdr_sync(h);
+       free(s.s);
+       return 0;
+}
+
 int vcf_close(bcf_t *bp)
 {
        vcf_t *v;
@@ -86,7 +113,7 @@ int vcf_close(bcf_t *bp)
        }
        if (v->fpout) fclose(v->fpout);
        free(v->line.s);
-       bcf_str2id_destroy(v->refhash);
+       bcf_str2id_thorough_destroy(v->refhash);
        free(v);
        free(bp);
        return 0;
@@ -95,15 +122,14 @@ int vcf_close(bcf_t *bp)
 int vcf_hdr_write(bcf_t *bp, const bcf_hdr_t *h)
 {
        vcf_t *v = (vcf_t*)bp->v;
-       int i, has_ref = 0, has_ver = 0;
+       int i, has_ver = 0;
        if (!bp->is_vcf) return bcf_hdr_write(bp, h);
        if (h->l_txt > 0) {
                if (strstr(h->txt, "##fileformat=")) has_ver = 1;
-               if (has_ver == 0) fprintf(v->fpout, "##fileformat=VCFv4.0\n");
+               if (has_ver == 0) fprintf(v->fpout, "##fileformat=VCFv4.1\n");
                fwrite(h->txt, 1, h->l_txt - 1, v->fpout);
-               if (strstr(h->txt, "##SQ=")) has_ref = 1;
        }
-       if (has_ver == 0) fprintf(v->fpout, "##fileformat=VCFv4.0\n");
+       if (h->l_txt == 0) fprintf(v->fpout, "##fileformat=VCFv4.1\n");
        fprintf(v->fpout, "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT");
        for (i = 0; i < h->n_smpl; ++i)
                fprintf(v->fpout, "\t%s", h->sns[i]);
@@ -140,7 +166,7 @@ int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b)
                if (k == 0) { // ref
                        int tid = bcf_str2id(v->refhash, p);
                        if (tid < 0) {
-                               tid = bcf_str2id_add(v->refhash, p);
+                               tid = bcf_str2id_add(v->refhash, strdup(p));
                                kputs(p, &rn); kputc('\0', &rn);
                                sync = 1;
                        }
@@ -158,8 +184,10 @@ int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b)
                                for (i = 0; i < b->n_gi; ++i) {
                                        if (b->gi[i].fmt == bcf_str2int("GT", 2)) {
                                                ((uint8_t*)b->gi[i].data)[k-9] = 1<<7;
-                                       } else if (b->gi[i].fmt == bcf_str2int("GQ", 2) || b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                                       } else if (b->gi[i].fmt == bcf_str2int("GQ", 2)) {
                                                ((uint8_t*)b->gi[i].data)[k-9] = 0;
+                                       } else if (b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                                               ((int32_t*)b->gi[i].data)[k-9] = 0;
                                        } else if (b->gi[i].fmt == bcf_str2int("DP", 2)) {
                                                ((uint16_t*)b->gi[i].data)[k-9] = 0;
                                        } else if (b->gi[i].fmt == bcf_str2int("PL", 2)) {
@@ -175,11 +203,15 @@ int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b)
                        for (q = kstrtok(p, ":", &a2), i = 0; q && i < b->n_gi; q = kstrtok(0, 0, &a2), ++i) {
                                if (b->gi[i].fmt == bcf_str2int("GT", 2)) {
                                        ((uint8_t*)b->gi[i].data)[k-9] = (q[0] - '0')<<3 | (q[2] - '0') | (q[1] == '/'? 0 : 1) << 6;
-                               } else if (b->gi[i].fmt == bcf_str2int("GQ", 2) || b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                               } else if (b->gi[i].fmt == bcf_str2int("GQ", 2)) {
                                        double _x = strtod(q, &q);
                                        int x = (int)(_x + .499);
                                        if (x > 255) x = 255;
                                        ((uint8_t*)b->gi[i].data)[k-9] = x;
+                               } else if (b->gi[i].fmt == bcf_str2int("SP", 2)) {
+                                       int x = strtol(q, &q, 10);
+                                       if (x > 0xffff) x = 0xffff;
+                                       ((uint32_t*)b->gi[i].data)[k-9] = x;
                                } else if (b->gi[i].fmt == bcf_str2int("DP", 2)) {
                                        int x = strtol(q, &q, 10);
                                        if (x > 0xffff) x = 0xffff;
@@ -200,7 +232,7 @@ int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b)
                                        y = b->n_alleles * (b->n_alleles + 1) / 2;
                                        for (j = 0; j < y; ++j) {
                                                x = strtod(q, &q);
-                                               data[(k-9) * y + j] = x;
+                                               data[(k-9) * y + j] = x > 0? -x/10. : x;
                                                ++q;
                                        }
                                }
diff --git a/samtools/bedidx.c.pysam.c b/samtools/bedidx.c.pysam.c
new file mode 100644 (file)
index 0000000..c3ab06f
--- /dev/null
@@ -0,0 +1,158 @@
+#include "pysam.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <zlib.h>
+
+#include "ksort.h"
+KSORT_INIT_GENERIC(uint64_t)
+
+#include "kseq.h"
+KSTREAM_INIT(gzFile, gzread, 8192)
+
+typedef struct {
+       int n, m;
+       uint64_t *a;
+       int *idx;
+} bed_reglist_t;
+
+#include "khash.h"
+KHASH_MAP_INIT_STR(reg, bed_reglist_t)
+
+#define LIDX_SHIFT 13
+
+typedef kh_reg_t reghash_t;
+
+int *bed_index_core(int n, uint64_t *a, int *n_idx)
+{
+       int i, j, m, *idx;
+       m = *n_idx = 0; idx = 0;
+       for (i = 0; i < n; ++i) {
+               int beg, end;
+               beg = a[i]>>32 >> LIDX_SHIFT; end = ((uint32_t)a[i]) >> LIDX_SHIFT;
+               if (m < end + 1) {
+                       int oldm = m;
+                       m = end + 1;
+                       kroundup32(m);
+                       idx = realloc(idx, m * sizeof(int));
+                       for (j = oldm; j < m; ++j) idx[j] = -1;
+               }
+               if (beg == end) {
+                       if (idx[beg] < 0) idx[beg] = i;
+               } else {
+                       for (j = beg; j <= end; ++j)
+                               if (idx[j] < 0) idx[j] = i;
+               }
+               *n_idx = end + 1;
+       }
+       return idx;
+}
+
+void bed_index(void *_h)
+{
+       reghash_t *h = (reghash_t*)_h;
+       khint_t k;
+       for (k = 0; k < kh_end(h); ++k) {
+               if (kh_exist(h, k)) {
+                       bed_reglist_t *p = &kh_val(h, k);
+                       if (p->idx) free(p->idx);
+                       ks_introsort(uint64_t, p->n, p->a);
+                       p->idx = bed_index_core(p->n, p->a, &p->m);
+               }
+       }
+}
+
+int bed_overlap_core(const bed_reglist_t *p, int beg, int end)
+{
+       int i, min_off;
+       if (p->n == 0) return 0;
+       min_off = (beg>>LIDX_SHIFT >= p->n)? p->idx[p->n-1] : p->idx[beg>>LIDX_SHIFT];
+       if (min_off < 0) { // TODO: this block can be improved, but speed should not matter too much here
+               int n = beg>>LIDX_SHIFT;
+               if (n > p->n) n = p->n;
+               for (i = n - 1; i >= 0; --i)
+                       if (p->idx[i] >= 0) break;
+               min_off = i >= 0? p->idx[i] : 0;
+       }
+       for (i = min_off; i < p->n; ++i) {
+               if ((int)(p->a[i]>>32) >= end) break; // out of range; no need to proceed
+               if ((int32_t)p->a[i] > beg && (int32_t)(p->a[i]>>32) < end)
+                       return 1; // find the overlap; return
+       }
+       return 0;
+}
+
+int bed_overlap(const void *_h, const char *chr, int beg, int end)
+{
+       const reghash_t *h = (const reghash_t*)_h;
+       khint_t k;
+       if (!h) return 0;
+       k = kh_get(reg, h, chr);
+       if (k == kh_end(h)) return 0;
+       return bed_overlap_core(&kh_val(h, k), beg, end);
+}
+
+void *bed_read(const char *fn)
+{
+       reghash_t *h = kh_init(reg);
+       gzFile fp;
+       kstream_t *ks;
+       int dret;
+       kstring_t *str;
+       // read the list
+       fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
+       if (fp == 0) return 0;
+       str = calloc(1, sizeof(kstring_t));
+       ks = ks_init(fp);
+       while (ks_getuntil(ks, 0, str, &dret) >= 0) { // read the chr name
+               int beg = -1, end = -1;
+               bed_reglist_t *p;
+               khint_t k = kh_get(reg, h, str->s);
+               if (k == kh_end(h)) { // absent from the hash table
+                       int ret;
+                       char *s = strdup(str->s);
+                       k = kh_put(reg, h, s, &ret);
+                       memset(&kh_val(h, k), 0, sizeof(bed_reglist_t));
+               }
+               p = &kh_val(h, k);
+               if (dret != '\n') { // if the lines has other characters
+                       if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0])) {
+                               beg = atoi(str->s); // begin
+                               if (dret != '\n') {
+                                       if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0]))
+                                               end = atoi(str->s); // end
+                               }
+                       }
+               }
+               if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n'); // skip the rest of the line
+               if (end < 0 && beg > 0) end = beg, beg = beg - 1; // if there is only one column
+               if (beg >= 0 && end > beg) {
+                       if (p->n == p->m) {
+                               p->m = p->m? p->m<<1 : 4;
+                               p->a = realloc(p->a, p->m * 8);
+                       }
+                       p->a[p->n++] = (uint64_t)beg<<32 | end;
+               }
+       }
+       ks_destroy(ks);
+       gzclose(fp);
+       free(str->s); free(str);
+       bed_index(h);
+       return h;
+}
+
+void bed_destroy(void *_h)
+{
+       reghash_t *h = (reghash_t*)_h;
+       khint_t k;
+       for (k = 0; k < kh_end(h); ++k) {
+               if (kh_exist(h, k)) {
+                       free(kh_val(h, k).a);
+                       free(kh_val(h, k).idx);
+                       free((char*)kh_key(h, k));
+               }
+       }
+       kh_destroy(reg, h);
+}
index 269c2717846de6adf3b05a8bf8eedb05f37e78c1..067b89d1950d0c677626d77eb608a701bb422b2e 100644 (file)
@@ -113,6 +113,32 @@ report_error(BGZF* fp, const char* message) {
     fp->error = message;
 }
 
+int bgzf_check_bgzf(const char *fn)
+{
+    BGZF *fp;
+    uint8_t buf[10],magic[10]="\037\213\010\4\0\0\0\0\0\377";
+    int n;
+
+    if ((fp = bgzf_open(fn, "r")) == 0) 
+    {
+        fprintf(pysamerr, "[bgzf_check_bgzf] failed to open the file: %s\n",fn);
+        return -1;
+    }
+
+#ifdef _USE_KNETFILE
+    n = knet_read(fp->x.fpr, buf, 10);
+#else
+    n = fread(buf, 1, 10, fp->file);
+#endif
+    bgzf_close(fp);
+
+    if ( n!=10 ) 
+        return -1;
+
+    if ( !memcmp(magic, buf, 10) ) return 1;
+    return 0;
+}
+
 static BGZF *bgzf_read_init()
 {
        BGZF *fp;
@@ -150,7 +176,7 @@ open_read(int fd)
 
 static
 BGZF*
-open_write(int fd, bool is_uncompressed)
+open_write(int fd, int compress_level) // compress_level==-1 for the default level
 {
     FILE* file = fdopen(fd, "w");
     BGZF* fp;
@@ -158,7 +184,9 @@ open_write(int fd, bool is_uncompressed)
        fp = malloc(sizeof(BGZF));
     fp->file_descriptor = fd;
     fp->open_mode = 'w';
-    fp->owned_file = 0; fp->is_uncompressed = is_uncompressed;
+    fp->owned_file = 0;
+       fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
+       if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
 #ifdef _USE_KNETFILE
     fp->x.fpw = file;
 #else
@@ -197,13 +225,20 @@ bgzf_open(const char* __restrict path, const char* __restrict mode)
         fp = open_read(fd);
 #endif
     } else if (strchr(mode, 'w') || strchr(mode, 'W')) {
-               int fd, oflag = O_WRONLY | O_CREAT | O_TRUNC;
+               int fd, compress_level = -1, oflag = O_WRONLY | O_CREAT | O_TRUNC;
 #ifdef _WIN32
                oflag |= O_BINARY;
 #endif
                fd = open(path, oflag, 0666);
                if (fd == -1) return 0;
-        fp = open_write(fd, strchr(mode, 'u')? 1 : 0);
+               { // set compress_level
+                       int i;
+                       for (i = 0; mode[i]; ++i)
+                               if (mode[i] >= '0' && mode[i] <= '9') break;
+                       if (mode[i]) compress_level = (int)mode[i] - '0';
+                       if (strchr(mode, 'u')) compress_level = 0;
+               }
+        fp = open_write(fd, compress_level);
     }
     if (fp != NULL) fp->owned_file = 1;
     return fp;
@@ -216,7 +251,12 @@ bgzf_fdopen(int fd, const char * __restrict mode)
     if (mode[0] == 'r' || mode[0] == 'R') {
         return open_read(fd);
     } else if (mode[0] == 'w' || mode[0] == 'W') {
-        return open_write(fd, strstr(mode, "u")? 1 : 0);
+               int i, compress_level = -1;
+               for (i = 0; mode[i]; ++i)
+                       if (mode[i] >= '0' && mode[i] <= '9') break;
+               if (mode[i]) compress_level = (int)mode[i] - '0';
+               if (strchr(mode, 'u')) compress_level = 0;
+        return open_write(fd, compress_level);
     } else {
         return NULL;
     }
@@ -256,7 +296,6 @@ deflate_block(BGZF* fp, int block_length)
     int input_length = block_length;
     int compressed_length = 0;
     while (1) {
-               int compress_level = fp->is_uncompressed? 0 : Z_DEFAULT_COMPRESSION;
         z_stream zs;
         zs.zalloc = NULL;
         zs.zfree = NULL;
@@ -265,7 +304,7 @@ deflate_block(BGZF* fp, int block_length)
         zs.next_out = (void*)&buffer[BLOCK_HEADER_LENGTH];
         zs.avail_out = buffer_size - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
 
-        int status = deflateInit2(&zs, compress_level, Z_DEFLATED,
+        int status = deflateInit2(&zs, fp->compress_level, Z_DEFLATED,
                                   GZIP_WINDOW_BITS, Z_DEFAULT_MEM_LEVEL, Z_DEFAULT_STRATEGY);
         if (status != Z_OK) {
             report_error(fp, "deflate init failed");
@@ -332,6 +371,7 @@ inflate_block(BGZF* fp, int block_length)
     // Inflate the block in fp->compressed_block into fp->uncompressed_block
 
     z_stream zs;
+       int status;
     zs.zalloc = NULL;
     zs.zfree = NULL;
     zs.next_in = fp->compressed_block + 18;
@@ -339,7 +379,7 @@ inflate_block(BGZF* fp, int block_length)
     zs.next_out = fp->uncompressed_block;
     zs.avail_out = fp->uncompressed_block_size;
 
-    int status = inflateInit2(&zs, GZIP_WINDOW_BITS);
+    status = inflateInit2(&zs, GZIP_WINDOW_BITS);
     if (status != Z_OK) {
         report_error(fp, "inflate init failed");
         return -1;
@@ -433,7 +473,7 @@ int
 bgzf_read_block(BGZF* fp)
 {
     bgzf_byte_t header[BLOCK_HEADER_LENGTH];
-       int count, size = 0;
+       int count, size = 0, block_length, remaining;
 #ifdef _USE_KNETFILE
     int64_t block_address = knet_tell(fp->x.fpr);
        if (load_block_from_cache(fp, block_address)) return 0;
@@ -456,10 +496,10 @@ bgzf_read_block(BGZF* fp)
         report_error(fp, "invalid block header");
         return -1;
     }
-    int block_length = unpackInt16((uint8_t*)&header[16]) + 1;
+    block_length = unpackInt16((uint8_t*)&header[16]) + 1;
     bgzf_byte_t* compressed_block = (bgzf_byte_t*) fp->compressed_block;
     memcpy(compressed_block, header, BLOCK_HEADER_LENGTH);
-    int remaining = block_length - BLOCK_HEADER_LENGTH;
+    remaining = block_length - BLOCK_HEADER_LENGTH;
 #ifdef _USE_KNETFILE
     count = knet_read(fp->x.fpr, &compressed_block[BLOCK_HEADER_LENGTH], remaining);
 #else
@@ -496,7 +536,8 @@ bgzf_read(BGZF* fp, void* data, int length)
     int bytes_read = 0;
     bgzf_byte_t* output = data;
     while (bytes_read < length) {
-        int available = fp->block_length - fp->block_offset;
+        int copy_length, available = fp->block_length - fp->block_offset;
+               bgzf_byte_t *buffer;
         if (available <= 0) {
             if (bgzf_read_block(fp) != 0) {
                 return -1;
@@ -506,8 +547,8 @@ bgzf_read(BGZF* fp, void* data, int length)
                 break;
             }
         }
-        int copy_length = bgzf_min(length-bytes_read, available);
-        bgzf_byte_t* buffer = fp->uncompressed_block;
+        copy_length = bgzf_min(length-bytes_read, available);
+        buffer = fp->uncompressed_block;
         memcpy(output, buffer + fp->block_offset, copy_length);
         fp->block_offset += copy_length;
         output += copy_length;
@@ -554,6 +595,8 @@ int bgzf_flush_try(BGZF *fp, int size)
 
 int bgzf_write(BGZF* fp, const void* data, int length)
 {
+       const bgzf_byte_t *input = data;
+       int block_length, bytes_written;
     if (fp->open_mode != 'w') {
         report_error(fp, "file not open for writing");
         return -1;
@@ -562,9 +605,9 @@ int bgzf_write(BGZF* fp, const void* data, int length)
     if (fp->uncompressed_block == NULL)
         fp->uncompressed_block = malloc(fp->uncompressed_block_size);
 
-    const bgzf_byte_t* input = data;
-    int block_length = fp->uncompressed_block_size;
-    int bytes_written = 0;
+    input = data;
+    block_length = fp->uncompressed_block_size;
+    bytes_written = 0;
     while (bytes_written < length) {
         int copy_length = bgzf_min(block_length - fp->block_offset, length - bytes_written);
         bgzf_byte_t* buffer = fp->uncompressed_block;
index 099ae9a6da1785ae132be55932a2e5c930ba49cc..7295f37425df320199aef87bb7bb80e482cc38bd 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <stdint.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <zlib.h>
 #ifdef _USE_KNETFILE
 #include "knetfile.h"
@@ -37,7 +36,7 @@
 typedef struct {
     int file_descriptor;
     char open_mode;  // 'r' or 'w'
-    bool owned_file, is_uncompressed;
+    int16_t owned_file, compress_level;
 #ifdef _USE_KNETFILE
        union {
                knetFile *fpr;
@@ -129,6 +128,7 @@ int bgzf_check_EOF(BGZF *fp);
 int bgzf_read_block(BGZF* fp);
 int bgzf_flush(BGZF* fp);
 int bgzf_flush_try(BGZF *fp, int size);
+int bgzf_check_bgzf(const char *fn);
 
 #ifdef __cplusplus
 }
diff --git a/samtools/cut_target.c.pysam.c b/samtools/cut_target.c.pysam.c
new file mode 100644 (file)
index 0000000..13cf2d2
--- /dev/null
@@ -0,0 +1,195 @@
+#include "pysam.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "bam.h"
+#include "errmod.h"
+#include "faidx.h"
+
+#define ERR_DEP 0.83f
+
+typedef struct {
+       int e[2][3], p[2][2];
+} score_param_t;
+
+/* Note that although the two matrics have 10 parameters in total, only 4
+ * (probably 3) are free.  Changing the scoring matrices in a sort of symmetric
+ * way will not change the result. */
+static score_param_t g_param = { {{0,0,0},{-4,1,6}}, {{0,-14000}, {0,0}} };
+
+typedef struct {
+       int min_baseQ, tid, max_bases;
+       uint16_t *bases;
+       bamFile fp;
+       bam_header_t *h;
+       char *ref;
+       faidx_t *fai;
+       errmod_t *em;
+} ct_t;
+
+static uint16_t gencns(ct_t *g, int n, const bam_pileup1_t *plp)
+{
+       int i, j, ret, tmp, k, sum[4], qual;
+       float q[16];
+       if (n > g->max_bases) { // enlarge g->bases
+               g->max_bases = n;
+               kroundup32(g->max_bases);
+               g->bases = realloc(g->bases, g->max_bases * 2);
+       }
+       for (i = k = 0; i < n; ++i) {
+               const bam_pileup1_t *p = plp + i;
+               uint8_t *seq;
+               int q, baseQ, b;
+               if (p->is_refskip || p->is_del) continue;
+               baseQ = bam1_qual(p->b)[p->qpos];
+               if (baseQ < g->min_baseQ) continue;
+               seq = bam1_seq(p->b);
+               b = bam_nt16_nt4_table[bam1_seqi(seq, p->qpos)];
+               if (b > 3) continue;
+               q = baseQ < p->b->core.qual? baseQ : p->b->core.qual;
+               if (q < 4) q = 4;
+               if (q > 63) q = 63;
+               g->bases[k++] = q<<5 | bam1_strand(p->b)<<4 | b;
+       }
+       if (k == 0) return 0;
+       errmod_cal(g->em, k, 4, g->bases, q);
+       for (i = 0; i < 4; ++i) sum[i] = (int)(q[i<<2|i] + .499) << 2 | i;
+       for (i = 1; i < 4; ++i) // insertion sort
+               for (j = i; j > 0 && sum[j] < sum[j-1]; --j)
+                       tmp = sum[j], sum[j] = sum[j-1], sum[j-1] = tmp;
+       qual = (sum[1]>>2) - (sum[0]>>2);
+       k = k < 256? k : 255;
+       ret = (qual < 63? qual : 63) << 2 | (sum[0]&3);
+       return ret<<8|k;
+}
+
+static void process_cns(bam_header_t *h, int tid, int l, uint16_t *cns)
+{
+       int i, f[2][2], *prev, *curr, *swap_tmp, s;
+       uint8_t *b; // backtrack array
+       b = calloc(l, 1);
+       f[0][0] = f[0][1] = 0;
+       prev = f[0]; curr = f[1];
+       // fill the backtrack matrix
+       for (i = 0; i < l; ++i) {
+               int c = (cns[i] == 0)? 0 : (cns[i]>>8 == 0)? 1 : 2;
+               int tmp0, tmp1;
+               // compute f[0]
+               tmp0 = prev[0] + g_param.e[0][c] + g_param.p[0][0]; // (s[i+1],s[i])=(0,0)
+               tmp1 = prev[1] + g_param.e[0][c] + g_param.p[1][0]; // (0,1)
+               if (tmp0 > tmp1) curr[0] = tmp0, b[i] = 0;
+               else curr[0] = tmp1, b[i] = 1;
+               // compute f[1]
+               tmp0 = prev[0] + g_param.e[1][c] + g_param.p[0][1]; // (s[i+1],s[i])=(1,0)
+               tmp1 = prev[1] + g_param.e[1][c] + g_param.p[1][1]; // (1,1)
+               if (tmp0 > tmp1) curr[1] = tmp0, b[i] |= 0<<1;
+               else curr[1] = tmp1, b[i] |= 1<<1;
+               // swap
+               swap_tmp = prev; prev = curr; curr = swap_tmp;
+       }
+       // backtrack
+       s = prev[0] > prev[1]? 0 : 1;
+       for (i = l - 1; i > 0; --i) {
+               b[i] |= s<<2;
+               s = b[i]>>s&1;
+       }
+       // print
+       for (i = 0, s = -1; i <= l; ++i) {
+               if (i == l || ((b[i]>>2&3) == 0 && s >= 0)) {
+                       if (s >= 0) {
+                               int j;
+                               printf("%s:%d-%d\t0\t%s\t%d\t60\t%dM\t*\t0\t0\t", h->target_name[tid], s+1, i, h->target_name[tid], s+1, i-s);
+                               for (j = s; j < i; ++j) {
+                                       int c = cns[j]>>8;
+                                       if (c == 0) putchar('N');
+                                       else putchar("ACGT"[c&3]);
+                               }
+                               putchar('\t');
+                               for (j = s; j < i; ++j)
+                                       putchar(33 + (cns[j]>>8>>2));
+                               putchar('\n');
+                       }
+                       //if (s >= 0) printf("%s\t%d\t%d\t%d\n", h->target_name[tid], s, i, i - s);
+                       s = -1;
+               } else if ((b[i]>>2&3) && s < 0) s = i;
+       }
+       free(b);
+}
+
+static int read_aln(void *data, bam1_t *b)
+{
+       extern int bam_prob_realn_core(bam1_t *b, const char *ref, int flag);
+       ct_t *g = (ct_t*)data;
+       int ret, len;
+       ret = bam_read1(g->fp, b);
+       if (ret >= 0 && g->fai && b->core.tid >= 0 && (b->core.flag&4) == 0) {
+               if (b->core.tid != g->tid) { // then load the sequence
+                       free(g->ref);
+                       g->ref = fai_fetch(g->fai, g->h->target_name[b->core.tid], &len);
+                       g->tid = b->core.tid;
+               }
+               bam_prob_realn_core(b, g->ref, 1<<1|1);
+       }
+       return ret;
+}
+
+int main_cut_target(int argc, char *argv[])
+{
+       int c, tid, pos, n, lasttid = -1, lastpos = -1, l, max_l;
+       const bam_pileup1_t *p;
+       bam_plp_t plp;
+       uint16_t *cns;
+       ct_t g;
+
+       memset(&g, 0, sizeof(ct_t));
+       g.min_baseQ = 13; g.tid = -1;
+       while ((c = getopt(argc, argv, "f:Q:i:o:0:1:2:")) >= 0) {
+               switch (c) {
+                       case 'Q': g.min_baseQ = atoi(optarg); break; // quality cutoff
+                       case 'i': g_param.p[0][1] = -atoi(optarg); break; // 0->1 transition (in) PENALTY
+                       case '0': g_param.e[1][0] = atoi(optarg); break; // emission SCORE
+                       case '1': g_param.e[1][1] = atoi(optarg); break;
+                       case '2': g_param.e[1][2] = atoi(optarg); break;
+                       case 'f': g.fai = fai_load(optarg);
+                               if (g.fai == 0) fprintf(pysamerr, "[%s] fail to load the fasta index.\n", __func__);
+                               break;
+               }
+       }
+       if (argc == optind) {
+               fprintf(pysamerr, "Usage: samtools targetcut [-Q minQ] [-i inPen] [-0 em0] [-1 em1] [-2 em2] [-f ref] <in.bam>\n");
+               return 1;
+       }
+       l = max_l = 0; cns = 0;
+       g.fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r");
+       g.h = bam_header_read(g.fp);
+       g.em = errmod_init(1 - ERR_DEP);
+       plp = bam_plp_init(read_aln, &g);
+       while ((p = bam_plp_auto(plp, &tid, &pos, &n)) != 0) {
+               if (tid < 0) break;
+               if (tid != lasttid) { // change of chromosome
+                       if (cns) process_cns(g.h, lasttid, l, cns);
+                       if (max_l < g.h->target_len[tid]) {
+                               max_l = g.h->target_len[tid];
+                               kroundup32(max_l);
+                               cns = realloc(cns, max_l * 2);
+                       }
+                       l = g.h->target_len[tid];
+                       memset(cns, 0, max_l * 2);
+                       lasttid = tid;
+               }
+               cns[pos] = gencns(&g, n, p);
+               lastpos = pos;
+       }
+       process_cns(g.h, lasttid, l, cns);
+       free(cns);
+       bam_header_destroy(g.h);
+       bam_plp_destroy(plp);
+       bam_close(g.fp);
+       if (g.fai) {
+               fai_destroy(g.fai); free(g.ref);
+       }
+       errmod_destroy(g.em);
+       free(g.bases);
+       return 0;
+}
index e3e9a90540cee5a78bb603956db20e7861555c2d..32c07b67b625924230689fca1d16da4f49e5938b 100644 (file)
@@ -12,6 +12,13 @@ typedef struct {
 
 errmod_t *errmod_init(float depcorr);
 void errmod_destroy(errmod_t *em);
+
+/*
+       n: number of bases
+       m: maximum base
+       bases[i]: qual:6, strand:1, base:4
+       q[i*m+j]: phred-scaled likelihood of (i,j)
+ */
 int errmod_cal(const errmod_t *em, int n, int m, uint16_t *bases, float *q);
 
 #endif
index b4ce846f45fbd8932db949e9bb33e0cb3c595a8e..526a9c0022ff477807e6475b2910c2497f4caf36 100644 (file)
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
 #include "faidx.h"
 #include "khash.h"
 
index 1d583efa3b2ff7c91d980383ded2db4aea97f849..a7e80568e0c33bb16c007954a5f25934e306f7df 100644 (file)
@@ -1,6 +1,6 @@
 /* The MIT License
 
-   Copyright (c) 2008 Genome Research Ltd (GRL).
+   Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attractor@live.co.uk>
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -23,8 +23,6 @@
    SOFTWARE.
 */
 
-/* Contact: Heng Li <lh3@sanger.ac.uk> */
-
 /*
   An example:
 
@@ -49,6 +47,14 @@ int main() {
 */
 
 /*
+  2011-02-14 (0.2.5):
+
+    * Allow to declare global functions.
+
+  2009-09-26 (0.2.4):
+
+    * Improve portability
+
   2008-09-19 (0.2.3):
 
        * Corrected the example
@@ -88,17 +94,35 @@ int main() {
   @copyright Heng Li
  */
 
-#define AC_VERSION_KHASH_H "0.2.2"
+#define AC_VERSION_KHASH_H "0.2.5"
 
-#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
+
+/* compipler specific configuration */
+
+#if UINT_MAX == 0xffffffffu
+typedef unsigned int khint32_t;
+#elif ULONG_MAX == 0xffffffffu
+typedef unsigned long khint32_t;
+#endif
+
+#if ULONG_MAX == ULLONG_MAX
+typedef unsigned long khint64_t;
+#else
+typedef unsigned long long khint64_t;
+#endif
+
+#ifdef _MSC_VER
+#define inline __inline
+#endif
 
-typedef uint32_t khint_t;
+typedef khint32_t khint_t;
 typedef khint_t khiter_t;
 
 #define __ac_HASH_PRIME_SIZE 32
-static const uint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
+static const khint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
 {
   0ul,          3ul,          11ul,         23ul,         53ul,
   97ul,         193ul,        389ul,        769ul,        1543ul,
@@ -119,17 +143,32 @@ static const uint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
 
 static const double __ac_HASH_UPPER = 0.77;
 
-#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
+#define KHASH_DECLARE(name, khkey_t, khval_t)                                                  \
+       typedef struct {                                                                                                        \
+               khint_t n_buckets, size, n_occupied, upper_bound;                               \
+               khint32_t *flags;                                                                                               \
+               khkey_t *keys;                                                                                                  \
+               khval_t *vals;                                                                                                  \
+       } kh_##name##_t;                                                                                                        \
+       extern kh_##name##_t *kh_init_##name();                                                         \
+       extern void kh_destroy_##name(kh_##name##_t *h);                                        \
+       extern void kh_clear_##name(kh_##name##_t *h);                                          \
+       extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key);      \
+       extern void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
+       extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
+       extern void kh_del_##name(kh_##name##_t *h, khint_t x);
+
+#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
        typedef struct {                                                                                                        \
                khint_t n_buckets, size, n_occupied, upper_bound;                               \
-               uint32_t *flags;                                                                                                \
+               khint32_t *flags;                                                                                               \
                khkey_t *keys;                                                                                                  \
                khval_t *vals;                                                                                                  \
        } kh_##name##_t;                                                                                                        \
-       static inline kh_##name##_t *kh_init_##name() {                                         \
+       SCOPE kh_##name##_t *kh_init_##name() {                                                         \
                return (kh_##name##_t*)calloc(1, sizeof(kh_##name##_t));                \
        }                                                                                                                                       \
-       static inline void kh_destroy_##name(kh_##name##_t *h)                          \
+       SCOPE void kh_destroy_##name(kh_##name##_t *h)                                          \
        {                                                                                                                                       \
                if (h) {                                                                                                                \
                        free(h->keys); free(h->flags);                                                          \
@@ -137,14 +176,14 @@ static const double __ac_HASH_UPPER = 0.77;
                        free(h);                                                                                                        \
                }                                                                                                                               \
        }                                                                                                                                       \
-       static inline void kh_clear_##name(kh_##name##_t *h)                            \
+       SCOPE void kh_clear_##name(kh_##name##_t *h)                                            \
        {                                                                                                                                       \
                if (h && h->flags) {                                                                                    \
-                       memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(uint32_t)); \
+                       memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(khint32_t)); \
                        h->size = h->n_occupied = 0;                                                            \
                }                                                                                                                               \
        }                                                                                                                                       \
-       static inline khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
+       SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key)        \
        {                                                                                                                                       \
                if (h->n_buckets) {                                                                                             \
                        khint_t inc, k, i, last;                                                                        \
@@ -158,9 +197,9 @@ static const double __ac_HASH_UPPER = 0.77;
                        return __ac_iseither(h->flags, i)? h->n_buckets : i;            \
                } else return 0;                                                                                                \
        }                                                                                                                                       \
-       static inline void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
+       SCOPE void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
        {                                                                                                                                       \
-               uint32_t *new_flags = 0;                                                                                \
+               khint32_t *new_flags = 0;                                                                               \
                khint_t j = 1;                                                                                                  \
                {                                                                                                                               \
                        khint_t t = __ac_HASH_PRIME_SIZE - 1;                                           \
@@ -168,8 +207,8 @@ static const double __ac_HASH_UPPER = 0.77;
                        new_n_buckets = __ac_prime_list[t+1];                                           \
                        if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \
                        else {                                                                                                          \
-                               new_flags = (uint32_t*)malloc(((new_n_buckets>>4) + 1) * sizeof(uint32_t));     \
-                               memset(new_flags, 0xaa, ((new_n_buckets>>4) + 1) * sizeof(uint32_t)); \
+                               new_flags = (khint32_t*)malloc(((new_n_buckets>>4) + 1) * sizeof(khint32_t));   \
+                               memset(new_flags, 0xaa, ((new_n_buckets>>4) + 1) * sizeof(khint32_t)); \
                                if (h->n_buckets < new_n_buckets) {                                             \
                                        h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
                                        if (kh_is_map)                                                                          \
@@ -218,7 +257,7 @@ static const double __ac_HASH_UPPER = 0.77;
                        h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
                }                                                                                                                               \
        }                                                                                                                                       \
-       static inline khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
+       SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
        {                                                                                                                                       \
                khint_t x;                                                                                                              \
                if (h->n_occupied >= h->upper_bound) {                                                  \
@@ -256,7 +295,7 @@ static const double __ac_HASH_UPPER = 0.77;
                } else *ret = 0;                                                                                                \
                return x;                                                                                                               \
        }                                                                                                                                       \
-       static inline void kh_del_##name(kh_##name##_t *h, khint_t x)           \
+       SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x)                           \
        {                                                                                                                                       \
                if (x != h->n_buckets && !__ac_iseither(h->flags, x)) {                 \
                        __ac_set_isdel_true(h->flags, x);                                                       \
@@ -264,24 +303,27 @@ static const double __ac_HASH_UPPER = 0.77;
                }                                                                                                                               \
        }
 
+#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
+       KHASH_INIT2(name, static inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
+
 /* --- BEGIN OF HASH FUNCTIONS --- */
 
 /*! @function
   @abstract     Integer hash function
-  @param  key   The integer [uint32_t]
+  @param  key   The integer [khint32_t]
   @return       The hash value [khint_t]
  */
-#define kh_int_hash_func(key) (uint32_t)(key)
+#define kh_int_hash_func(key) (khint32_t)(key)
 /*! @function
   @abstract     Integer comparison function
  */
 #define kh_int_hash_equal(a, b) ((a) == (b))
 /*! @function
   @abstract     64-bit integer hash function
-  @param  key   The integer [uint64_t]
+  @param  key   The integer [khint64_t]
   @return       The hash value [khint_t]
  */
-#define kh_int64_hash_func(key) (uint32_t)((key)>>33^(key)^(key)<<11)
+#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11)
 /*! @function
   @abstract     64-bit integer comparison function
  */
@@ -442,7 +484,7 @@ static inline khint_t __ac_X31_hash_string(const char *s)
   @param  name  Name of the hash table [symbol]
  */
 #define KHASH_SET_INIT_INT(name)                                                                               \
-       KHASH_INIT(name, uint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
+       KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
 
 /*! @function
   @abstract     Instantiate a hash map containing integer keys
@@ -450,14 +492,14 @@ static inline khint_t __ac_X31_hash_string(const char *s)
   @param  khval_t  Type of values [type]
  */
 #define KHASH_MAP_INIT_INT(name, khval_t)                                                              \
-       KHASH_INIT(name, uint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
+       KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
 
 /*! @function
   @abstract     Instantiate a hash map containing 64-bit integer keys
   @param  name  Name of the hash table [symbol]
  */
 #define KHASH_SET_INIT_INT64(name)                                                                             \
-       KHASH_INIT(name, uint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
+       KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
 
 /*! @function
   @abstract     Instantiate a hash map containing 64-bit integer keys
@@ -465,7 +507,7 @@ static inline khint_t __ac_X31_hash_string(const char *s)
   @param  khval_t  Type of values [type]
  */
 #define KHASH_MAP_INIT_INT64(name, khval_t)                                                            \
-       KHASH_INIT(name, uint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
+       KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
 
 typedef const char *kh_cstr_t;
 /*! @function
index e3a8845b7aba8e928acaba244a33e5acc66817ec..25bbafe31fb19e45866dbe2855d2a55f5cfbc332 100644 (file)
@@ -2,7 +2,8 @@
 
 /* The MIT License
 
-   Copyright (c) 2008 Genome Research Ltd (GRL).
+   Copyright (c) 2008 by Genome Research Ltd (GRL).
+                 2010 by Attractive Chaos <attractor@live.co.uk>
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    SOFTWARE.
 */
 
-/* Contact: Heng Li <lh3@sanger.ac.uk> */
-
 /* Probably I will not do socket programming in the next few years and
    therefore I decide to heavily annotate this file, for Linux and
-   Windows as well.  -lh3 */
+   Windows as well.  -ac */
 
 #include <time.h>
 #include <stdio.h>
@@ -92,7 +91,7 @@ static int socket_connect(const char *host, const char *port)
 
        int on = 1, fd;
        struct linger lng = { 0, 0 };
-       struct addrinfo hints, *res;
+       struct addrinfo hints, *res = 0;
        memset(&hints, 0, sizeof(struct addrinfo));
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
index 9eb9721eba3ac8889faf13aae8655e7cfb2a0013..c02bce09e3536fb01d77671cd39d23c31c3ee37c 100644 (file)
@@ -31,16 +31,24 @@ char *kstrtok(const char *str, const char *sep, ks_tokaux_t *aux)
        const char *p, *start;
        if (sep) { // set up the table
                if (str == 0 && (aux->tab[0]&1)) return 0; // no need to set up if we have finished
-               aux->tab[0] = aux->tab[1] = aux->tab[2] = aux->tab[3] = 0;
-               for (p = sep; *p; ++p)
-                       aux->tab[*p/64] |= 1ull<<(*p%64);
+               aux->finished = 0;
+               if (sep[1]) {
+                       aux->sep = -1;
+                       aux->tab[0] = aux->tab[1] = aux->tab[2] = aux->tab[3] = 0;
+                       for (p = sep; *p; ++p) aux->tab[*p>>6] |= 1ull<<(*p&0x3f);
+               } else aux->sep = sep[0];
+       }
+       if (aux->finished) return 0;
+       else if (str) aux->p = str - 1, aux->finished = 0;
+       if (aux->sep < 0) {
+               for (p = start = aux->p + 1; *p; ++p)
+                       if (aux->tab[*p>>6]>>(*p&0x3f)&1) break;
+       } else {
+               for (p = start = aux->p + 1; *p; ++p)
+                       if (*p == aux->sep) break;
        }
-       if (str) aux->p = str - 1, aux->tab[0] &= ~1ull;
-       else if (aux->tab[0]&1) return 0;
-       for (p = start = aux->p + 1; *p; ++p)
-               if (aux->tab[*p/64]>>(*p%64)&1) break;
        aux->p = p; // end of token
-       if (*p == 0) aux->tab[0] |= 1; // no more tokens
+       if (*p == 0) aux->finished = 1; // no more tokens
        return (char*)start;
 }
 
index c46a62bc8bd0284826c1c7dd78ff1698d54f54f7..ec5775b485316c4faaa190a2c501a57fc188985c 100644 (file)
@@ -19,6 +19,7 @@ typedef struct __kstring_t {
 
 typedef struct {
        uint64_t tab[4];
+       int sep, finished;
        const char *p; // end of the current token
 } ks_tokaux_t;
 
diff --git a/samtools/misc/md5.c.pysam.c b/samtools/misc/md5.c.pysam.c
new file mode 100644 (file)
index 0000000..7710844
--- /dev/null
@@ -0,0 +1,298 @@
+#include "pysam.h"
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/* Brutally hacked by John Walker back from ANSI C to K&R (no
+   prototypes) to maintain the tradition that Netfone will compile
+   with Sun's original "cc". */
+
+#include <string.h>
+#include "md5.h"
+
+#ifndef HIGHFIRST
+#define byteReverse(buf, len)  /* Nothing */
+#else
+/*
+ * Note: this code is harmless on little-endian machines.
+ */
+void byteReverse(buf, longs)
+    unsigned char *buf; unsigned longs;
+{
+    uint32_t t;
+    do {
+       t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+           ((unsigned) buf[1] << 8 | buf[0]);
+       *(uint32_t *) buf = t;
+       buf += 4;
+    } while (--longs);
+}
+#endif
+
+void MD5Transform(uint32_t buf[4], uint32_t in[16]);
+
+
+/*
+ * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void MD5Init(ctx)
+    struct MD5Context *ctx;
+{
+    ctx->buf[0] = 0x67452301;
+    ctx->buf[1] = 0xefcdab89;
+    ctx->buf[2] = 0x98badcfe;
+    ctx->buf[3] = 0x10325476;
+
+    ctx->bits[0] = 0;
+    ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void MD5Update(ctx, buf, len)
+    struct MD5Context *ctx; unsigned char *buf; unsigned len;
+{
+    uint32_t t;
+
+    /* Update bitcount */
+
+    t = ctx->bits[0];
+    if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
+       ctx->bits[1]++;         /* Carry from low to high */
+    ctx->bits[1] += len >> 29;
+
+    t = (t >> 3) & 0x3f;       /* Bytes already in shsInfo->data */
+
+    /* Handle any leading odd-sized chunks */
+
+    if (t) {
+       unsigned char *p = (unsigned char *) ctx->in + t;
+
+       t = 64 - t;
+       if (len < t) {
+           memcpy(p, buf, len);
+           return;
+       }
+       memcpy(p, buf, t);
+       byteReverse(ctx->in, 16);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+       buf += t;
+       len -= t;
+    }
+    /* Process data in 64-byte chunks */
+
+    while (len >= 64) {
+       memcpy(ctx->in, buf, 64);
+       byteReverse(ctx->in, 16);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+       buf += 64;
+       len -= 64;
+    }
+
+    /* Handle any remaining bytes of data. */
+
+    memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern 
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void MD5Final(digest, ctx)
+    unsigned char digest[16]; struct MD5Context *ctx;
+{
+    unsigned count;
+    unsigned char *p;
+
+    /* Compute number of bytes mod 64 */
+    count = (ctx->bits[0] >> 3) & 0x3F;
+
+    /* Set the first char of padding to 0x80.  This is safe since there is
+       always at least one byte free */
+    p = ctx->in + count;
+    *p++ = 0x80;
+
+    /* Bytes of padding needed to make 64 bytes */
+    count = 64 - 1 - count;
+
+    /* Pad out to 56 mod 64 */
+    if (count < 8) {
+       /* Two lots of padding:  Pad the first block to 64 bytes */
+       memset(p, 0, count);
+       byteReverse(ctx->in, 16);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+
+       /* Now fill the next block with 56 bytes */
+       memset(ctx->in, 0, 56);
+    } else {
+       /* Pad block to 56 bytes */
+       memset(p, 0, count - 8);
+    }
+    byteReverse(ctx->in, 14);
+
+    /* Append length in bits and transform */
+    ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+    ((uint32_t *) ctx->in)[15] = ctx->bits[1];
+
+    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+    byteReverse((unsigned char *) ctx->buf, 4);
+    memcpy(digest, ctx->buf, 16);
+    memset(ctx, 0, sizeof(ctx));        /* In case it's sensitive */
+}
+
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+       ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data.  MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void MD5Transform(buf, in)
+    uint32_t buf[4]; uint32_t in[16];
+{
+    register uint32_t a, b, c, d;
+
+    a = buf[0];
+    b = buf[1];
+    c = buf[2];
+    d = buf[3];
+
+    MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+    MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+    MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+    MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+    MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+    MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+    MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+    MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+    MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+    MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+    MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+    MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+    MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+    MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+    MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+    MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+    MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+    MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+    MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+    MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+    MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+    MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+    MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+    MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+    MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+    MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+    MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+    MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+    MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+    MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+    MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+    MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+    MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+    MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+    MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+    MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+    MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+    MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+    MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+    MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+    MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+    MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+    MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+    MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+    MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+    MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+    MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+    MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+    MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+    MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+    MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+    MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+    MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+    MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+    MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+    MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+    MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+    MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+    MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+    MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+    MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+    MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+    MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+    MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+    buf[0] += a;
+    buf[1] += b;
+    buf[2] += c;
+    buf[3] += d;
+}
+
+/* lh3: the following code is added by me */
+
+#ifdef MD5SUM_MAIN
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define HEX_STR "0123456789abcdef"
+
+static void md5_one(const char *fn)
+{
+       unsigned char buf[4096], digest[16];
+       MD5_CTX md5;
+       int l;
+       FILE *fp;
+
+       fp = strcmp(fn, "-")? fopen(fn, "r") : stdin;
+       if (fp == 0) {
+               fprintf(pysamerr, "md5sum: %s: No such file or directory\n", fn);
+               exit(1);
+       }
+       MD5Init(&md5);
+       while ((l = fread(buf, 1, 4096, fp)) > 0)
+               MD5Update(&md5, buf, l);
+       MD5Final(digest, &md5);
+       if (fp != stdin) fclose(fp);
+       for (l = 0; l < 16; ++l)
+               printf("%c%c", HEX_STR[digest[l]>>4&0xf], HEX_STR[digest[l]&0xf]);
+       printf("  %s\n", fn);
+}
+int main(int argc, char *argv[])
+{
+       int i;
+       if (argc == 1) md5_one("-");
+       else for (i = 1; i < argc; ++i) md5_one(argv[i]);
+       return 0;
+}
+#endif
diff --git a/samtools/misc/md5.h b/samtools/misc/md5.h
new file mode 100644 (file)
index 0000000..44121e4
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+  This file is adapted from a program in this page:
+
+  http://www.fourmilab.ch/md5/
+
+  The original source code does not work on 64-bit machines due to the
+  wrong typedef "uint32". I also added prototypes.
+
+  -lh3
+ */
+
+#ifndef MD5_H
+#define MD5_H
+
+/*  The following tests optimise behaviour on little-endian
+    machines, where there is no need to reverse the byte order
+    of 32 bit words in the MD5 computation.  By default,
+    HIGHFIRST is defined, which indicates we're running on a
+    big-endian (most significant byte first) machine, on which
+    the byteReverse function in md5.c must be invoked. However,
+    byteReverse is coded in such a way that it is an identity
+    function when run on a little-endian machine, so calling it
+    on such a platform causes no harm apart from wasting time. 
+    If the platform is known to be little-endian, we speed
+    things up by undefining HIGHFIRST, which defines
+    byteReverse as a null macro.  Doing things in this manner
+    insures we work on new platforms regardless of their byte
+    order.  */
+
+#define HIGHFIRST
+
+#if __LITTLE_ENDIAN__ != 0
+#undef HIGHFIRST
+#endif
+
+#include <stdint.h>
+
+struct MD5Context {
+        uint32_t buf[4];
+        uint32_t bits[2];
+        unsigned char in[64];
+};
+
+void MD5Init(struct MD5Context *ctx);
+void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len);
+void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
+
+/*
+ * This is needed to make RSAREF happy on some MS-DOS compilers.
+ */
+typedef struct MD5Context MD5_CTX;
+
+/*  Define CHECK_HARDWARE_PROPERTIES to have main,c verify
+    byte order and uint32_t settings.  */
+#define CHECK_HARDWARE_PROPERTIES
+
+#endif /* !MD5_H */
diff --git a/samtools/msvc_compat.h b/samtools/msvc_compat.h
new file mode 100644 (file)
index 0000000..624cc99
--- /dev/null
@@ -0,0 +1,60 @@
+// Windows-specific code, include with:\r
+// #ifdef _MSC_VER\r
+// #include <msvc_compat.h>\r
+// #endif\r
+\r
+//#define _CRT_SECURE_NO_WARNINGS\r
+#ifndef MSVC_COMPAT_H\r
+#define MSVC_COMPAT_H\r
+\r
+#define inline __inline\r
+#define __func__ __FUNCTION__\r
+\r
+#include <float.h>\r
+#define isnan _isnan\r
+static int isinf(double x) {\r
+    int y = _finite(x);\r
+    if(y == 0) {\r
+       return 0;\r
+    } else {\r
+       return 1;\r
+    }\r
+}\r
+#define alloca _alloca\r
+#define atoll _atoi64\r
+\r
+#define ftello ftell\r
+
+typedef int bool;\r
+\r
+static int R_OK = 4;
+\r
+#ifndef lgamma\r
+/* Log gamma function\r
+ * \log{\Gamma(z)}\r
+ * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245\r
+ */\r
+static double lgamma(double z)\r
+{\r
+       double x = 0;\r
+       x += 0.1659470187408462e-06 / (z+7);\r
+       x += 0.9934937113930748e-05 / (z+6);\r
+       x -= 0.1385710331296526     / (z+5);\r
+       x += 12.50734324009056      / (z+4);\r
+       x -= 176.6150291498386      / (z+3);\r
+       x += 771.3234287757674      / (z+2);\r
+       x -= 1259.139216722289      / (z+1);\r
+       x += 676.5203681218835      / z;\r
+       x += 0.9999999999995183;\r
+       return log(x) - 5.58106146679532777 - z + (z-0.5) * log(z+6.5);\r
+}\r
+#endif\r
+\r
+#ifndef M_LN10\r
+#define        M_LN10   2.30258509299404568402\r
+#endif\r
+#ifndef M_LN2\r
+#define        M_LN2   0.69314718055994530942\r
+#endif\r
+
+#endif\r
diff --git a/samtools/phase.c.pysam.c b/samtools/phase.c.pysam.c
new file mode 100644 (file)
index 0000000..d142538
--- /dev/null
@@ -0,0 +1,689 @@
+#include "pysam.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <math.h>
+#include <zlib.h>
+#include "bam.h"
+#include "errmod.h"
+
+#include "kseq.h"
+KSTREAM_INIT(gzFile, gzread, 16384)
+
+#define MAX_VARS 256
+#define FLIP_PENALTY 2
+#define FLIP_THRES 4
+#define MASK_THRES 3
+
+#define FLAG_FIX_CHIMERA 0x1
+#define FLAG_LIST_EXCL   0x4
+#define FLAG_DROP_AMBI   0x8
+
+typedef struct {
+       // configurations, initialized in the main function
+       int flag, k, min_baseQ, min_varLOD, max_depth;
+       // other global variables
+       int vpos_shift;
+       bamFile fp;
+       char *pre;
+       bamFile out[3];
+       // alignment queue
+       int n, m;
+       bam1_t **b;
+} phaseg_t;
+
+typedef struct {
+       int8_t seq[MAX_VARS]; // TODO: change to dynamic memory allocation!
+       int vpos, beg, end;
+       uint32_t vlen:16, single:1, flip:1, phase:1, phased:1, ambig:1;
+       uint32_t in:16, out:16; // in-phase and out-phase
+} frag_t, *frag_p;
+
+#define rseq_lt(a,b) ((a)->vpos < (b)->vpos)
+
+#include "khash.h"
+KHASH_SET_INIT_INT64(set64)
+KHASH_MAP_INIT_INT64(64, frag_t)
+
+typedef khash_t(64) nseq_t;
+
+#include "ksort.h"
+KSORT_INIT(rseq, frag_p, rseq_lt)
+
+static char nt16_nt4_table[] = { 4, 0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4 };
+
+static inline uint64_t X31_hash_string(const char *s)
+{
+       uint64_t h = *s;
+       if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
+       return h;
+}
+
+static void count1(int l, const uint8_t *seq, int *cnt)
+{
+       int i, j, n_ambi;
+       uint32_t z, x;
+       if (seq[l-1] == 0) return; // do nothing is the last base is ambiguous
+       for (i = n_ambi = 0; i < l; ++i) // collect ambiguous bases
+               if (seq[i] == 0) ++n_ambi;
+       if (l - n_ambi <= 1) return; // only one SNP
+       for (x = 0; x < 1u<<n_ambi; ++x) { // count
+               for (i = j = 0, z = 0; i < l; ++i) {
+                       int c;
+                       if (seq[i]) c = seq[i] - 1;
+                       else {
+                               c = x>>j&1;
+                               ++j;
+                       }
+                       z = z<<1 | c;
+               }
+               ++cnt[z];
+       }
+}
+
+static int **count_all(int l, int vpos, nseq_t *hash)
+{
+       khint_t k;
+       int i, j, **cnt;
+       uint8_t *seq;
+       seq = calloc(l, 1);
+       cnt = calloc(vpos, sizeof(void*));
+       for (i = 0; i < vpos; ++i) cnt[i] = calloc(1<<l, sizeof(int));
+       for (k = 0; k < kh_end(hash); ++k) {
+               if (kh_exist(hash, k)) {
+                       frag_t *f = &kh_val(hash, k);
+                       if (f->vpos >= vpos || f->single) continue; // out of region; or singleton
+                       if (f->vlen == 1) { // such reads should be flagged as deleted previously if everything is right
+                               f->single = 1;
+                               continue;
+                       }
+                       for (j = 1; j < f->vlen; ++j) {
+                               for (i = 0; i < l; ++i)
+                                       seq[i] = j < l - 1 - i? 0 : f->seq[j - (l - 1 - i)];
+                               count1(l, seq, cnt[f->vpos + j]);
+                       }
+               }
+       }
+       free(seq);
+       return cnt;
+}
+
+// phasing
+static int8_t *dynaprog(int l, int vpos, int **w)
+{
+       int *f[2], *curr, *prev, max, i;
+       int8_t **b, *h = 0;
+       uint32_t x, z = 1u<<(l-1), mask = (1u<<l) - 1;
+       f[0] = calloc(z, sizeof(int));
+       f[1] = calloc(z, sizeof(int));
+       b = calloc(vpos, sizeof(void*));
+       prev = f[0]; curr = f[1];
+       // fill the backtrack matrix
+       for (i = 0; i < vpos; ++i) {
+               int *wi = w[i], *tmp;
+               int8_t *bi;
+               bi = b[i] = calloc(z, 1);
+               /* In the following, x is the current state, which is the
+                * lexicographically smaller local haplotype. xc is the complement of
+                * x, or the larger local haplotype; y0 and y1 are the two predecessors
+                * of x. */
+               for (x = 0; x < z; ++x) { // x0 is the smaller 
+                       uint32_t y0, y1, xc;
+                       int c0, c1;
+                       xc = ~x&mask; y0 = x>>1; y1 = xc>>1;
+                       c0 = prev[y0] + wi[x] + wi[xc];
+                       c1 = prev[y1] + wi[x] + wi[xc];
+                       if (c0 > c1) bi[x] = 0, curr[x] = c0;
+                       else bi[x] = 1, curr[x] = c1;
+               }
+               tmp = prev; prev = curr; curr = tmp; // swap
+       }
+       { // backtrack
+               uint32_t max_x = 0;
+               int which = 0;
+               h = calloc(vpos, 1);
+               for (x = 0, max = 0, max_x = 0; x < z; ++x)
+                       if (prev[x] > max) max = prev[x], max_x = x;
+               for (i = vpos - 1, x = max_x; i >= 0; --i) {
+                       h[i] = which? (~x&1) : (x&1);
+                       which = b[i][x]? !which : which;
+                       x = b[i][x]? (~x&mask)>>1 : x>>1;
+               }
+       }
+       // free
+       for (i = 0; i < vpos; ++i) free(b[i]);
+       free(f[0]); free(f[1]); free(b);
+       return h;
+}
+
+// phase each fragment
+static uint64_t *fragphase(int vpos, const int8_t *path, nseq_t *hash, int flip)
+{
+       khint_t k;
+       uint64_t *pcnt;
+       uint32_t *left, *rght, max;
+       left = rght = 0; max = 0;
+       pcnt = calloc(vpos, 8);
+       for (k = 0; k < kh_end(hash); ++k) {
+               if (kh_exist(hash, k)) {
+                       int i, c[2];
+                       frag_t *f = &kh_val(hash, k);
+                       if (f->vpos >= vpos) continue;
+                       // get the phase
+                       c[0] = c[1] = 0;
+                       for (i = 0; i < f->vlen; ++i) {
+                               if (f->seq[i] == 0) continue;
+                               ++c[f->seq[i] == path[f->vpos + i] + 1? 0 : 1];
+                       }
+                       f->phase = c[0] > c[1]? 0 : 1;
+                       f->in = c[f->phase]; f->out = c[1 - f->phase];
+                       f->phased = f->in == f->out? 0 : 1;
+                       f->ambig = (f->in && f->out && f->out < 3 && f->in <= f->out + 1)? 1 : 0;
+                       // fix chimera
+                       f->flip = 0;
+                       if (flip && c[0] >= 3 && c[1] >= 3) {
+                               int sum[2], m, mi, md;
+                               if (f->vlen > max) { // enlarge the array
+                                       max = f->vlen;
+                                       kroundup32(max);
+                                       left = realloc(left, max * 4);
+                                       rght = realloc(rght, max * 4);
+                               }
+                               for (i = 0, sum[0] = sum[1] = 0; i < f->vlen; ++i) { // get left counts
+                                       if (f->seq[i]) {
+                                               int c = f->phase? 2 - f->seq[i] : f->seq[i] - 1;
+                                               ++sum[c == path[f->vpos + i]? 0 : 1];
+                                       }
+                                       left[i] = sum[1]<<16 | sum[0];
+                               }
+                               for (i = f->vlen - 1, sum[0] = sum[1] = 0; i >= 0; --i) { // get right counts
+                                       if (f->seq[i]) {
+                                               int c = f->phase? 2 - f->seq[i] : f->seq[i] - 1;
+                                               ++sum[c == path[f->vpos + i]? 0 : 1];
+                                       }
+                                       rght[i] = sum[1]<<16 | sum[0];
+                               }
+                               // find the best flip point
+                               for (i = m = 0, mi = -1, md = -1; i < f->vlen - 1; ++i) {
+                                       int a[2];
+                                       a[0] = (left[i]&0xffff) + (rght[i+1]>>16&0xffff) - (rght[i+1]&0xffff) * FLIP_PENALTY;
+                                       a[1] = (left[i]>>16&0xffff) + (rght[i+1]&0xffff) - (rght[i+1]>>16&0xffff) * FLIP_PENALTY;
+                                       if (a[0] > a[1]) {
+                                               if (a[0] > m) m = a[0], md = 0, mi = i;
+                                       } else {
+                                               if (a[1] > m) m = a[1], md = 1, mi = i;
+                                       }
+                               }
+                               if (m - c[0] >= FLIP_THRES && m - c[1] >= FLIP_THRES) { // then flip
+                                       f->flip = 1;
+                                       if (md == 0) { // flip the tail
+                                               for (i = mi + 1; i < f->vlen; ++i)
+                                                       if (f->seq[i] == 1) f->seq[i] = 2;
+                                                       else if (f->seq[i] == 2) f->seq[i] = 1;
+                                       } else { // flip the head
+                                               for (i = 0; i <= mi; ++i)
+                                                       if (f->seq[i] == 1) f->seq[i] = 2;
+                                                       else if (f->seq[i] == 2) f->seq[i] = 1;
+                                       }
+                               }
+                       }
+                       // update pcnt[]
+                       if (!f->single) {
+                               for (i = 0; i < f->vlen; ++i) {
+                                       int c;
+                                       if (f->seq[i] == 0) continue;
+                                       c = f->phase? 2 - f->seq[i] : f->seq[i] - 1;
+                                       if (c == path[f->vpos + i]) {
+                                               if (f->phase == 0) ++pcnt[f->vpos + i];
+                                               else pcnt[f->vpos + i] += 1ull<<32;
+                                       } else {
+                                               if (f->phase == 0) pcnt[f->vpos + i] += 1<<16;
+                                               else pcnt[f->vpos + i] += 1ull<<48;
+                                       }
+                               }
+                       }
+               }
+       }
+       free(left); free(rght);
+       return pcnt;
+}
+
+static uint64_t *genmask(int vpos, const uint64_t *pcnt, int *_n)
+{
+       int i, max = 0, max_i = -1, m = 0, n = 0, beg = 0, score = 0;
+       uint64_t *list = 0;
+       for (i = 0; i < vpos; ++i) {
+               uint64_t x = pcnt[i];
+               int c[4], pre = score, s;
+               c[0] = x&0xffff; c[1] = x>>16&0xffff; c[2] = x>>32&0xffff; c[3] = x>>48&0xffff;
+               s = (c[1] + c[3] == 0)? -(c[0] + c[2]) : (c[1] + c[3] - 1);
+               if (c[3] > c[2]) s += c[3] - c[2];
+               if (c[1] > c[0]) s += c[1] - c[0];
+               score += s;
+               if (score < 0) score = 0;
+               if (pre == 0 && score > 0) beg = i; // change from zero to non-zero
+               if ((i == vpos - 1 || score == 0) && max >= MASK_THRES) {
+                       if (n == m) {
+                               m = m? m<<1 : 4;
+                               list = realloc(list, m * 8);
+                       }
+                       list[n++] = (uint64_t)beg<<32 | max_i;
+                       i = max_i; // reset i to max_i
+                       score = 0;
+               } else if (score > max) max = score, max_i = i;
+               if (score == 0) max = 0;
+       }
+       *_n = n;
+       return list;
+}
+
+// trim heading and tailing ambiguous bases; mark deleted and remove sequence
+static int clean_seqs(int vpos, nseq_t *hash)
+{
+       khint_t k;
+       int ret = 0;
+       for (k = 0; k < kh_end(hash); ++k) {
+               if (kh_exist(hash, k)) {
+                       frag_t *f = &kh_val(hash, k);
+                       int beg, end, i;
+                       if (f->vpos >= vpos) {
+                               ret = 1;
+                               continue;
+                       }
+                       for (i = 0; i < f->vlen; ++i)
+                               if (f->seq[i] != 0) break;
+                       beg = i;
+                       for (i = f->vlen - 1; i >= 0; --i)
+                               if (f->seq[i] != 0) break;
+                       end = i + 1;
+                       if (end - beg <= 0) kh_del(64, hash, k);
+                       else {
+                               if (beg != 0) memmove(f->seq, f->seq + beg, end - beg);
+                               f->vpos += beg; f->vlen = end - beg;
+                               f->single = f->vlen == 1? 1 : 0;
+                       }
+               }
+       }
+       return ret;
+}
+
+static void dump_aln(phaseg_t *g, int min_pos, const nseq_t *hash)
+{
+       int i, is_flip, drop_ambi;
+       drop_ambi = g->flag & FLAG_DROP_AMBI;
+       is_flip = (drand48() < 0.5);
+       for (i = 0; i < g->n; ++i) {
+               int end, which;
+               uint64_t key;
+               khint_t k;
+               bam1_t *b = g->b[i];
+               key = X31_hash_string(bam1_qname(b));
+               end = bam_calend(&b->core, bam1_cigar(b));
+               if (end > min_pos) break;
+               k = kh_get(64, hash, key);
+               if (k == kh_end(hash)) which = 3;
+               else {
+                       frag_t *f = &kh_val(hash, k);
+                       if (f->ambig) which = drop_ambi? 2 : 3;
+                       else if (f->phased && f->flip) which = 2;
+                       else if (f->phased == 0) which = 3;
+                       else { // phased and not flipped
+                               char c = 'Y';
+                               which = f->phase;
+                               bam_aux_append(b, "ZP", 'A', 1, (uint8_t*)&c);
+                       }
+                       if (which < 2 && is_flip) which = 1 - which; // increase the randomness
+               }
+               if (which == 3) which = (drand48() < 0.5);
+               bam_write1(g->out[which], b);
+               bam_destroy1(b);
+               g->b[i] = 0;
+       }
+       memmove(g->b, g->b + i, (g->n - i) * sizeof(void*));
+       g->n -= i;
+}
+
+static int phase(phaseg_t *g, const char *chr, int vpos, uint64_t *cns, nseq_t *hash)
+{
+       int i, j, n_seqs = kh_size(hash), n_masked = 0, min_pos;
+       khint_t k;
+       frag_t **seqs;
+       int8_t *path, *sitemask;
+       uint64_t *pcnt, *regmask;
+
+       if (vpos == 0) return 0;
+       i = clean_seqs(vpos, hash); // i is true if hash has an element with its vpos >= vpos
+       min_pos = i? cns[vpos]>>32 : 0x7fffffff;
+       if (vpos == 1) {
+               printf("PS\t%s\t%d\t%d\n", chr, (int)(cns[0]>>32) + 1, (int)(cns[0]>>32) + 1);
+               printf("M0\t%s\t%d\t%d\t%c\t%c\t%d\t0\t0\t0\t0\n//\n", chr, (int)(cns[0]>>32) + 1, (int)(cns[0]>>32) + 1,
+                       "ACGTX"[cns[0]&3], "ACGTX"[cns[0]>>16&3], g->vpos_shift + 1);
+               for (k = 0; k < kh_end(hash); ++k) {
+                       if (kh_exist(hash, k)) {
+                               frag_t *f = &kh_val(hash, k);
+                               if (f->vpos) continue;
+                               f->flip = 0;
+                               if (f->seq[0] == 0) f->phased = 0;
+                               else f->phased = 1, f->phase = f->seq[0] - 1;
+                       }
+               }
+               dump_aln(g, min_pos, hash);
+               ++g->vpos_shift;
+               return 1;
+       }
+       { // phase
+               int **cnt;
+               uint64_t *mask;
+               printf("PS\t%s\t%d\t%d\n", chr, (int)(cns[0]>>32) + 1, (int)(cns[vpos-1]>>32) + 1);
+               sitemask = calloc(vpos, 1);
+               cnt = count_all(g->k, vpos, hash);
+               path = dynaprog(g->k, vpos, cnt);
+               for (i = 0; i < vpos; ++i) free(cnt[i]);
+               free(cnt);
+               pcnt = fragphase(vpos, path, hash, 0); // do not fix chimeras when masking
+               mask = genmask(vpos, pcnt, &n_masked);
+               regmask = calloc(n_masked, 8);
+               for (i = 0; i < n_masked; ++i) {
+                       regmask[i] = cns[mask[i]>>32]>>32<<32 | cns[(uint32_t)mask[i]]>>32;
+                       for (j = mask[i]>>32; j <= (int32_t)mask[i]; ++j)
+                               sitemask[j] = 1;
+               }
+               free(mask);
+               if (g->flag & FLAG_FIX_CHIMERA) {
+                       free(pcnt);
+                       pcnt = fragphase(vpos, path, hash, 1);
+               }
+       }
+       for (i = 0; i < n_masked; ++i)
+               printf("FL\t%s\t%d\t%d\n", chr, (int)(regmask[i]>>32) + 1, (int)regmask[i] + 1);
+       for (i = 0; i < vpos; ++i) {
+               uint64_t x = pcnt[i];
+               int8_t c[2];
+               c[0] = (cns[i]&0xffff)>>2 == 0? 4 : (cns[i]&3);
+               c[1] = (cns[i]>>16&0xffff)>>2 == 0? 4 : (cns[i]>>16&3);
+               printf("M%d\t%s\t%d\t%d\t%c\t%c\t%d\t%d\t%d\t%d\t%d\n", sitemask[i]+1, chr, (int)(cns[0]>>32) + 1, (int)(cns[i]>>32) + 1, "ACGTX"[c[path[i]]], "ACGTX"[c[1-path[i]]],
+                       i + g->vpos_shift + 1, (int)(x&0xffff), (int)(x>>16&0xffff), (int)(x>>32&0xffff), (int)(x>>48&0xffff));
+       }
+       free(path); free(pcnt); free(regmask); free(sitemask);
+       seqs = calloc(n_seqs, sizeof(void*));
+       for (k = 0, i = 0; k < kh_end(hash); ++k) 
+               if (kh_exist(hash, k) && kh_val(hash, k).vpos < vpos && !kh_val(hash, k).single)
+                       seqs[i++] = &kh_val(hash, k);
+       n_seqs = i;
+       ks_introsort_rseq(n_seqs, seqs);
+       for (i = 0; i < n_seqs; ++i) {
+               frag_t *f = seqs[i];
+               printf("EV\t0\t%s\t%d\t40\t%dM\t*\t0\t0\t", chr, f->vpos + 1 + g->vpos_shift, f->vlen);
+               for (j = 0; j < f->vlen; ++j) {
+                       uint32_t c = cns[f->vpos + j];
+                       if (f->seq[j] == 0) putchar('N');
+                       else putchar("ACGT"[f->seq[j] == 1? (c&3) : (c>>16&3)]);
+               }
+               printf("\t*\tYP:i:%d\tYF:i:%d\tYI:i:%d\tYO:i:%d\tYS:i:%d\n", f->phase, f->flip, f->in, f->out, f->beg+1);
+       }
+       free(seqs);
+       printf("//\n");
+       fflush(stdout);
+       g->vpos_shift += vpos;
+       dump_aln(g, min_pos, hash);
+       return vpos;
+}
+
+static void update_vpos(int vpos, nseq_t *hash)
+{
+       khint_t k;
+       for (k = 0; k < kh_end(hash); ++k) {
+               if (kh_exist(hash, k)) {
+                       frag_t *f = &kh_val(hash, k);
+                       if (f->vpos < vpos) kh_del(64, hash, k); // TODO: if frag_t::seq is allocated dynamically, free it
+                       else f->vpos -= vpos;
+               }
+       }
+}
+
+static nseq_t *shrink_hash(nseq_t *hash) // TODO: to implement
+{
+       return hash;
+}
+
+static int readaln(void *data, bam1_t *b)
+{
+       phaseg_t *g = (phaseg_t*)data;
+       int ret;
+       ret = bam_read1(g->fp, b);
+       if (ret < 0) return ret;
+       if (!(b->core.flag & (BAM_FUNMAP|BAM_FSECONDARY|BAM_FQCFAIL|BAM_FDUP)) && g->pre) {
+               if (g->n == g->m) {
+                       g->m = g->m? g->m<<1 : 16;
+                       g->b = realloc(g->b, g->m * sizeof(void*));
+               }
+               g->b[g->n++] = bam_dup1(b);
+       }
+       return ret;
+}
+
+static khash_t(set64) *loadpos(const char *fn, bam_header_t *h)
+{
+       gzFile fp;
+       kstream_t *ks;
+       int ret, dret;
+       kstring_t *str;
+       khash_t(set64) *hash;
+
+       hash = kh_init(set64);
+       str = calloc(1, sizeof(kstring_t));
+       fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
+       ks = ks_init(fp);
+       while (ks_getuntil(ks, 0, str, &dret) >= 0) {
+               int tid = bam_get_tid(h, str->s);
+               if (tid >= 0 && dret != '\n') {
+                       if (ks_getuntil(ks, 0, str, &dret) >= 0) {
+                               uint64_t x = (uint64_t)tid<<32 | (atoi(str->s) - 1);
+                               kh_put(set64, hash, x, &ret);
+                       } else break;
+               }
+               if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n');
+               if (dret < 0) break;
+       }
+       ks_destroy(ks);
+       gzclose(fp);
+       free(str->s); free(str);
+       return hash;
+}
+
+static int gl2cns(float q[16])
+{
+       int i, j, min_ij;
+       float min, min2;
+       min = min2 = 1e30; min_ij = -1;
+       for (i = 0; i < 4; ++i) {
+               for (j = i; j < 4; ++j) {
+                       if (q[i<<2|j] < min) min_ij = i<<2|j, min2 = min, min = q[i<<2|j];
+                       else if (q[i<<2|j] < min2) min2 = q[i<<2|j];
+               }
+       }
+       return (min_ij>>2&3) == (min_ij&3)? 0 : 1<<18 | (min_ij>>2&3)<<16 | (min_ij&3) | (int)(min2 - min + .499) << 2;
+}
+
+int main_phase(int argc, char *argv[])
+{
+       extern void bam_init_header_hash(bam_header_t *header);
+       int c, tid, pos, vpos = 0, n, lasttid = -1, max_vpos = 0;
+       const bam_pileup1_t *plp;
+       bam_plp_t iter;
+       bam_header_t *h;
+       nseq_t *seqs;
+       uint64_t *cns = 0;
+       phaseg_t g;
+       char *fn_list = 0;
+       khash_t(set64) *set = 0;
+       errmod_t *em;
+       uint16_t *bases;
+
+       memset(&g, 0, sizeof(phaseg_t));
+       g.flag = FLAG_FIX_CHIMERA;
+       g.min_varLOD = 37; g.k = 13; g.min_baseQ = 13; g.max_depth = 256;
+       while ((c = getopt(argc, argv, "Q:eFq:k:b:l:D:A:")) >= 0) {
+               switch (c) {
+                       case 'D': g.max_depth = atoi(optarg); break;
+                       case 'q': g.min_varLOD = atoi(optarg); break;
+                       case 'Q': g.min_baseQ = atoi(optarg); break;
+                       case 'k': g.k = atoi(optarg); break;
+                       case 'F': g.flag &= ~FLAG_FIX_CHIMERA; break;
+                       case 'e': g.flag |= FLAG_LIST_EXCL; break;
+                       case 'A': g.flag |= FLAG_DROP_AMBI; break;
+                       case 'b': g.pre = strdup(optarg); break;
+                       case 'l': fn_list = strdup(optarg); break;
+               }
+       }
+       if (argc == optind) {
+               fprintf(pysamerr, "\n");
+               fprintf(pysamerr, "Usage:   samtools phase [options] <in.bam>\n\n");
+               fprintf(pysamerr, "Options: -k INT    block length [%d]\n", g.k);
+               fprintf(pysamerr, "         -b STR    prefix of BAMs to output [null]\n");
+               fprintf(pysamerr, "         -q INT    min het phred-LOD [%d]\n", g.min_varLOD);
+               fprintf(pysamerr, "         -Q INT    min base quality in het calling [%d]\n", g.min_baseQ);
+               fprintf(pysamerr, "         -D INT    max read depth [%d]\n", g.max_depth);
+//             fprintf(pysamerr, "         -l FILE   list of sites to phase [null]\n");
+               fprintf(pysamerr, "         -F        do not attempt to fix chimeras\n");
+               fprintf(pysamerr, "         -A        drop reads with ambiguous phase\n");
+//             fprintf(pysamerr, "         -e        do not discover SNPs (effective with -l)\n");
+               fprintf(pysamerr, "\n");
+               return 1;
+       }
+       g.fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r");
+       h = bam_header_read(g.fp);
+       if (fn_list) { // read the list of sites to phase
+               bam_init_header_hash(h);
+               set = loadpos(fn_list, h);
+               free(fn_list);
+       } else g.flag &= ~FLAG_LIST_EXCL;
+       if (g.pre) { // open BAMs to write
+               char *s = malloc(strlen(g.pre) + 20);
+               strcpy(s, g.pre); strcat(s, ".0.bam"); g.out[0] = bam_open(s, "w");
+               strcpy(s, g.pre); strcat(s, ".1.bam"); g.out[1] = bam_open(s, "w");
+               strcpy(s, g.pre); strcat(s, ".chimera.bam"); g.out[2] = bam_open(s, "w");
+               for (c = 0; c <= 2; ++c) bam_header_write(g.out[c], h);
+               free(s);
+       }
+
+       iter = bam_plp_init(readaln, &g);
+       g.vpos_shift = 0;
+       seqs = kh_init(64);
+       em = errmod_init(1. - 0.83);
+       bases = calloc(g.max_depth, 2);
+       printf("CC\n");
+       printf("CC\tDescriptions:\nCC\n");
+       printf("CC\t  CC      comments\n");
+       printf("CC\t  PS      start of a phase set\n");
+       printf("CC\t  FL      filtered region\n");
+       printf("CC\t  M[012]  markers; 0 for singletons, 1 for phased and 2 for filtered\n");
+       printf("CC\t  EV      supporting reads; SAM format\n");
+       printf("CC\t  //      end of a phase set\nCC\n");
+       printf("CC\tFormats of PS, FL and M[012] lines (1-based coordinates):\nCC\n");
+       printf("CC\t  PS  chr  phaseSetStart  phaseSetEnd\n");
+       printf("CC\t  FL  chr  filterStart    filterEnd\n");
+       printf("CC\t  M?  chr  PS  pos  allele0  allele1  hetIndex  #supports0  #errors0  #supp1  #err1\n");
+       printf("CC\nCC\n");
+       fflush(stdout);
+       while ((plp = bam_plp_auto(iter, &tid, &pos, &n)) != 0) {
+               int i, k, c, tmp, dophase = 1, in_set = 0;
+               float q[16];
+               if (tid < 0) break;
+               if (tid != lasttid) { // change of chromosome
+                       g.vpos_shift = 0;
+                       if (lasttid >= 0) {
+                               seqs = shrink_hash(seqs);
+                               phase(&g, h->target_name[lasttid], vpos, cns, seqs);
+                               update_vpos(0x7fffffff, seqs);
+                       }
+                       lasttid = tid;
+                       vpos = 0;
+               }
+               if (set && kh_get(set64, set, (uint64_t)tid<<32 | pos) != kh_end(set)) in_set = 1;
+               if (n > g.max_depth) continue; // do not proceed if the depth is too high
+               // fill the bases array and check if there is a variant
+               for (i = k = 0; i < n; ++i) {
+                       const bam_pileup1_t *p = plp + i;
+                       uint8_t *seq;
+                       int q, baseQ, b;
+                       if (p->is_del || p->is_refskip) continue;
+                       baseQ = bam1_qual(p->b)[p->qpos];
+                       if (baseQ < g.min_baseQ) continue;
+                       seq = bam1_seq(p->b);
+                       b = bam_nt16_nt4_table[bam1_seqi(seq, p->qpos)];
+                       if (b > 3) continue;
+                       q = baseQ < p->b->core.qual? baseQ : p->b->core.qual;
+                       if (q < 4) q = 4;
+                       if (q > 63) q = 63;
+                       bases[k++] = q<<5 | (int)bam1_strand(p->b)<<4 | b;
+               }
+               if (k == 0) continue;
+               errmod_cal(em, k, 4, bases, q); // compute genotype likelihood
+               c = gl2cns(q); // get the consensus
+               // tell if to proceed
+               if (set && (g.flag&FLAG_LIST_EXCL) && !in_set) continue; // not in the list
+               if (!in_set && (c&0xffff)>>2 < g.min_varLOD) continue; // not a variant
+               // add the variant
+               if (vpos == max_vpos) {
+                       max_vpos = max_vpos? max_vpos<<1 : 128;
+                       cns = realloc(cns, max_vpos * 8);
+               }
+               cns[vpos] = (uint64_t)pos<<32 | c;
+               for (i = 0; i < n; ++i) {
+                       const bam_pileup1_t *p = plp + i;
+                       uint64_t key;
+                       khint_t k;
+                       uint8_t *seq = bam1_seq(p->b);
+                       frag_t *f;
+                       if (p->is_del || p->is_refskip) continue;
+                       if (p->b->core.qual == 0) continue;
+                       // get the base code
+                       c = nt16_nt4_table[(int)bam1_seqi(seq, p->qpos)];
+                       if (c == (cns[vpos]&3)) c = 1;
+                       else if (c == (cns[vpos]>>16&3)) c = 2;
+                       else c = 0;
+                       // write to seqs
+                       key = X31_hash_string(bam1_qname(p->b));
+                       k = kh_put(64, seqs, key, &tmp);
+                       f = &kh_val(seqs, k);
+                       if (tmp == 0) { // present in the hash table
+                               if (vpos - f->vpos + 1 < MAX_VARS) {
+                                       f->vlen = vpos - f->vpos + 1;
+                                       f->seq[f->vlen-1] = c;
+                                       f->end = bam_calend(&p->b->core, bam1_cigar(p->b));
+                               }
+                               dophase = 0;
+                       } else { // absent
+                               memset(f->seq, 0, MAX_VARS);
+                               f->beg = p->b->core.pos;
+                               f->end = bam_calend(&p->b->core, bam1_cigar(p->b));
+                               f->vpos = vpos, f->vlen = 1, f->seq[0] = c, f->single = f->phased = f->flip = f->ambig = 0;
+                       }
+               }
+               if (dophase) {
+                       seqs = shrink_hash(seqs);
+                       phase(&g, h->target_name[tid], vpos, cns, seqs);
+                       update_vpos(vpos, seqs);
+                       cns[0] = cns[vpos];
+                       vpos = 0;
+               }
+               ++vpos;
+       }
+       if (tid >= 0) phase(&g, h->target_name[tid], vpos, cns, seqs);
+       bam_header_destroy(h);
+       bam_plp_destroy(iter);
+       bam_close(g.fp);
+       kh_destroy(64, seqs);
+       kh_destroy(set64, set);
+       free(cns);
+       errmod_destroy(em);
+       free(bases);
+       if (g.pre) {
+               for (c = 0; c <= 2; ++c) bam_close(g.out[c]);
+               free(g.pre); free(g.b);
+       }
+       return 0;
+}
index 091b20d97ffad5747410ef779222a119e0cb517b..7f71f7a9818b2a36f5e6f79a21a5daf133bd50c4 100644 (file)
@@ -42,9 +42,9 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
 {
        samfile_t *fp;
        fp = (samfile_t*)calloc(1, sizeof(samfile_t));
-       if (mode[0] == 'r') { // read
+       if (strchr(mode, 'r')) { // read
                fp->type |= TYPE_READ;
-               if (mode[1] == 'b') { // binary
+               if (strchr(mode, 'b')) { // binary
                        fp->type |= TYPE_BAM;
                        fp->x.bam = strcmp(fn, "-")? bam_open(fn, "r") : bam_dopen(fileno(stdin), "r");
                        if (fp->x.bam == 0) goto open_err_ret;
@@ -61,15 +61,19 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
                                        append_header_text(fp->header, textheader->text, textheader->l_text);
                                        bam_header_destroy(textheader);
                                }
-                               if (fp->header->n_targets == 0)
+                               if (fp->header->n_targets == 0 && bam_verbose >= 1)
                                        fprintf(pysamerr, "[samopen] no @SQ lines in the header.\n");
-                       } else fprintf(pysamerr, "[samopen] SAM header is present: %d sequences.\n", fp->header->n_targets);
+                       } else if (bam_verbose >= 2) fprintf(pysamerr, "[samopen] SAM header is present: %d sequences.\n", fp->header->n_targets);
                }
-       } else if (mode[0] == 'w') { // write
+       } else if (strchr(mode, 'w')) { // write
                fp->header = bam_header_dup((const bam_header_t*)aux);
-               if (mode[1] == 'b') { // binary
+               if (strchr(mode, 'b')) { // binary
                        char bmode[3];
-                       bmode[0] = 'w'; bmode[1] = strstr(mode, "u")? 'u' : 0; bmode[2] = 0;
+                       int i, compress_level = -1;
+                       for (i = 0; mode[i]; ++i) if (mode[i] >= '0' && mode[i] <= '9') break;
+                       if (mode[i]) compress_level = mode[i] - '0';
+                       if (strchr(mode, 'u')) compress_level = 0;
+                       bmode[0] = 'w'; bmode[1] = compress_level < 0? 0 : compress_level + '0'; bmode[2] = 0;
                        fp->type |= TYPE_BAM;
                        fp->x.bam = strcmp(fn, "-")? bam_open(fn, bmode) : bam_dopen(fileno(stdout), bmode);
                        if (fp->x.bam == 0) goto open_err_ret;
@@ -78,11 +82,11 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
                        // open file
                        fp->x.tamw = strcmp(fn, "-")? fopen(fn, "w") : stdout;
                        if (fp->x.tamr == 0) goto open_err_ret;
-                       if (strstr(mode, "X")) fp->type |= BAM_OFSTR<<2;
-                       else if (strstr(mode, "x")) fp->type |= BAM_OFHEX<<2;
+                       if (strchr(mode, 'X')) fp->type |= BAM_OFSTR<<2;
+                       else if (strchr(mode, 'x')) fp->type |= BAM_OFHEX<<2;
                        else fp->type |= BAM_OFDEC<<2;
                        // write header
-                       if (strstr(mode, "h")) {
+                       if (strchr(mode, 'h')) {
                                int i;
                                bam_header_t *alt;
                                // parse the header text 
@@ -91,10 +95,10 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
                                sam_header_parse(alt);
                                alt->l_text = 0; alt->text = 0;
                                // check if there are @SQ lines in the header
-                               fwrite(fp->header->text, 1, fp->header->l_text, fp->x.tamw);
+                               fwrite(fp->header->text, 1, fp->header->l_text, fp->x.tamw); // FIXME: better to skip the trailing NULL
                                if (alt->n_targets) { // then write the header text without dumping ->target_{name,len}
-                                       if (alt->n_targets != fp->header->n_targets)
-                                               fprintf(pysamerr, "[samopen] inconsistent number of target sequences.\n");
+                                       if (alt->n_targets != fp->header->n_targets && bam_verbose >= 1)
+                                               fprintf(pysamerr, "[samopen] inconsistent number of target sequences. Output the text header.\n");
                                } else { // then dump ->target_{name,len}
                                        for (i = 0; i < fp->header->n_targets; ++i)
                                                fprintf(fp->x.tamw, "@SQ\tSN:%s\tLN:%d\n", fp->header->target_name[i], fp->header->target_len[i]);
@@ -166,7 +170,7 @@ char *samfaipath(const char *fn_ref)
                if (access(fn_ref, R_OK) == -1) {
                        fprintf(pysamerr, "[samfaipath] fail to read file %s.\n", fn_ref);
                } else {
-                       fprintf(pysamerr, "[samfaipath] build FASTA index...\n");
+                       if (bam_verbose >= 3) fprintf(pysamerr, "[samfaipath] build FASTA index...\n");
                        if (fai_build(fn_ref) == -1) {
                                fprintf(pysamerr, "[samfaipath] fail to build FASTA index.\n");
                                free(fn_list); fn_list = 0;
index 91a4dcbc2bc33242ec645bd96b5da731adffe64b..2178047c838957764d00c81879ebcbee489f533f 100644 (file)
@@ -40,7 +40,7 @@ const char *o_sq_tags[] = {"AS","M5","UR","SP",NULL};
 const char *r_sq_tags[] = {"SN","LN",NULL};
 const char *u_sq_tags[] = {"SN",NULL};
 
-const char *o_rg_tags[] = {"LB","DS","PU","PI","CN","DT","PL",NULL};
+const char *o_rg_tags[] = {"CN","DS","DT","FO","KS","LB","PG","PI","PL","PU","SM",NULL};
 const char *r_rg_tags[] = {"ID",NULL};
 const char *u_rg_tags[] = {"ID",NULL};
 
@@ -565,6 +565,7 @@ void *sam_header_parse2(const char *headerText)
     const char *text;
     char *buf=NULL;
     size_t nbuf = 0;
+       int tovalidate = 0;
 
     if ( !headerText )
                return 0;
@@ -573,7 +574,7 @@ void *sam_header_parse2(const char *headerText)
     while ( (text=nextline(&buf, &nbuf, text)) )
     {
         hline = sam_header_line_parse(buf);
-        if ( hline && sam_header_line_validate(hline) )
+        if ( hline && (!tovalidate || sam_header_line_validate(hline)) )
             // With too many (~250,000) reference sequences the header parsing was too slow with list_append.
             hlines = list_append_to_end(hlines, hline);
         else
index 0a6cbb05b1e11bb797113359ade10f000c1878a6..2c4736336ee2e27150ce47d15d661e190c580888 100644 (file)
@@ -8,6 +8,7 @@
 #include "sam_header.h"
 #include "sam.h"
 #include "faidx.h"
+#include "kstring.h"
 #include "khash.h"
 KHASH_SET_INIT_STR(rg)
 
@@ -20,10 +21,15 @@ typedef struct {
 
 typedef khash_t(rg) *rghash_t;
 
-rghash_t g_rghash = 0;
+static rghash_t g_rghash = 0;
 static int g_min_mapQ = 0, g_flag_on = 0, g_flag_off = 0;
 static char *g_library, *g_rg;
 static int g_sol2sanger_tbl[128];
+static void *g_bed;
+
+void *bed_read(const char *fn);
+void bed_destroy(void *_h);
+int bed_overlap(const void *_h, const char *chr, int beg, int end);
 
 static void sol2sanger(bam1_t *b)
 {
@@ -46,6 +52,8 @@ static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b)
 {
        if (b->core.qual < g_min_mapQ || ((b->core.flag & g_flag_on) != g_flag_on) || (b->core.flag & g_flag_off))
                return 1;
+       if (g_bed && b->core.tid >= 0 && !bed_overlap(g_bed, h->target_name[b->core.tid], b->core.pos, bam_calend(&b->core, bam1_cigar(b))))
+               return 1;
        if (g_rg || g_rghash) {
                uint8_t *s = bam_aux_get(b, "RG");
                if (s) {
@@ -63,6 +71,37 @@ static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b)
        return 0;
 }
 
+static char *drop_rg(char *hdtxt, rghash_t h, int *len)
+{
+       char *p = hdtxt, *q, *r, *s;
+       kstring_t str;
+       memset(&str, 0, sizeof(kstring_t));
+       while (1) {
+               int toprint = 0;
+               q = strchr(p, '\n');
+               if (q == 0) q = p + strlen(p);
+               if (q - p < 3) break; // the line is too short; then stop
+               if (strncmp(p, "@RG\t", 4) == 0) {
+                       int c;
+                       khint_t k;
+                       if ((r = strstr(p, "\tID:")) != 0) {
+                               r += 4;
+                               for (s = r; *s != '\0' && *s != '\n' && *s != '\t'; ++s);
+                               c = *s; *s = '\0';
+                               k = kh_get(rg, h, r);
+                               *s = c;
+                               if (k != kh_end(h)) toprint = 1;
+                       }
+               } else toprint = 1;
+               if (toprint) {
+                       kputsn(p, q - p, &str); kputc('\n', &str);
+               }
+               p = q + 1;
+       }
+       *len = str.l;
+       return str.s;
+}
+
 // callback function for bam_fetch() that prints nonskipped records
 static int view_func(const bam1_t *b, void *data)
 {
@@ -84,7 +123,7 @@ static int usage(int is_long_help);
 
 int main_samview(int argc, char *argv[])
 {
-       int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, is_uncompressed = 0, is_bamout = 0, slx2sngr = 0, is_count = 0;
+       int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, compress_level = -1, is_bamout = 0, slx2sngr = 0, is_count = 0;
        int of_type = BAM_OFDEC, is_long_help = 0;
        int count = 0;
        samfile_t *in = 0, *out = 0;
@@ -92,7 +131,7 @@ int main_samview(int argc, char *argv[])
 
        /* parse command-line options */
        strcpy(in_mode, "r"); strcpy(out_mode, "w");
-       while ((c = getopt(argc, argv, "Sbct:hHo:q:f:F:ul:r:xX?T:CR:")) >= 0) {
+       while ((c = getopt(argc, argv, "Sbct:h1Ho:q:f:F:ul:r:xX?T:CR:L:")) >= 0) {
                switch (c) {
                case 'c': is_count = 1; break;
                case 'C': slx2sngr = 1; break;
@@ -105,8 +144,10 @@ int main_samview(int argc, char *argv[])
                case 'f': g_flag_on = strtol(optarg, 0, 0); break;
                case 'F': g_flag_off = strtol(optarg, 0, 0); break;
                case 'q': g_min_mapQ = atoi(optarg); break;
-               case 'u': is_uncompressed = 1; break;
+               case 'u': compress_level = 0; break;
+               case '1': compress_level = 1; break;
                case 'l': g_library = strdup(optarg); break;
+               case 'L': g_bed = bed_read(optarg); break;
                case 'r': g_rg = strdup(optarg); break;
                case 'R': fn_rg = strdup(optarg); break;
                case 'x': of_type = BAM_OFHEX; break;
@@ -116,7 +157,7 @@ int main_samview(int argc, char *argv[])
                default: return usage(is_long_help);
                }
        }
-       if (is_uncompressed) is_bamout = 1;
+       if (compress_level >= 0) is_bamout = 1;
        if (is_header_only) is_header = 1;
        if (is_bamout) strcat(out_mode, "b");
        else {
@@ -125,7 +166,11 @@ int main_samview(int argc, char *argv[])
        }
        if (is_bamin) strcat(in_mode, "b");
        if (is_header) strcat(out_mode, "h");
-       if (is_uncompressed) strcat(out_mode, "u");
+       if (compress_level >= 0) {
+               char tmp[2];
+               tmp[0] = compress_level + '0'; tmp[1] = '\0';
+               strcat(out_mode, tmp);
+       }
        if (argc == optind) return usage(is_long_help); // potential memory leak...
 
        // read the list of read groups
@@ -153,6 +198,14 @@ int main_samview(int argc, char *argv[])
                ret = 1;
                goto view_end;
        }
+       if (g_rghash) { // FIXME: I do not know what "bam_header_t::n_text" is for...
+               char *tmp;
+               int l;
+               tmp = drop_rg(in->header->text, g_rghash, &l);
+               free(in->header->text);
+               in->header->text = tmp;
+               in->header->l_text = l;
+       }
        if (!is_count && (out = samopen(fn_out? fn_out : "-", out_mode, in->header)) == 0) {
                fprintf(pysamerr, "[main_samview] fail to open \"%s\" for writing.\n", fn_out? fn_out : "standard output");
                ret = 1;
@@ -212,6 +265,7 @@ view_end:
        }
        // close files, free and return
        free(fn_list); free(fn_ref); free(fn_out); free(g_library); free(g_rg); free(fn_rg);
+       if (g_bed) bed_destroy(g_bed);
        if (g_rghash) {
                khint_t k;
                for (k = 0; k < kh_end(g_rghash); ++k)
@@ -233,9 +287,11 @@ static int usage(int is_long_help)
        fprintf(pysamerr, "         -H       print header only (no alignments)\n");
        fprintf(pysamerr, "         -S       input is SAM\n");
        fprintf(pysamerr, "         -u       uncompressed BAM output (force -b)\n");
+       fprintf(pysamerr, "         -1       fast compression (force -b)\n");
        fprintf(pysamerr, "         -x       output FLAG in HEX (samtools-C specific)\n");
        fprintf(pysamerr, "         -X       output FLAG in string (samtools-C specific)\n");
        fprintf(pysamerr, "         -c       print only the count of matching records\n");
+       fprintf(pysamerr, "         -L FILE  output alignments overlapping the input BED FILE [null]\n");
        fprintf(pysamerr, "         -t FILE  list of reference names and lengths (force -S) [null]\n");
        fprintf(pysamerr, "         -T FILE  reference sequence file (force -S) [null]\n");
        fprintf(pysamerr, "         -o FILE  output file name [stdout]\n");
index 4b984a2ef6fdfc3ddade45f598f8b695ec772e76..dc8e627ec5382382d77ac3860c401d88253cf3af 100644 (file)
@@ -77,6 +77,7 @@ int bam_smpl_add(bam_sample_t *sm, const char *fn, const char *txt)
                ++n;
        }
        if (n == 0) add_pair(sm, sm2id, fn, fn);
+//     add_pair(sm, sm2id, fn, fn);
        free(buf.s);
        return 0;
 }
index 81d163a7b2d4c8c09dd219a0ad513143e5acfbaf..b9711b81bb0b4e9b5d4639dab6f1c3c1f685a017 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,8 @@
 [bdist_rpm]
-vendor = TDB
 doc_files = README doc/*.html ChangeLog
-distribution-name = Red Hat Linux
+vendor = TDB
 packager = TDB <email@email.com>
+distribution-name = Red Hat Linux
 requires = python
 
 [egg_info]
index 5d3b51abde017213b927f243546ff18c2aa4020f..4f9b15a8dfa6e3b46ffa3141fc9fd7b0a9d7d305 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@ pysam
 '''
 
 import os, sys, glob, shutil, hashlib, re, fnmatch
+import platform
 
 name = "pysam"
 
@@ -31,6 +32,21 @@ def locate(pattern, root=os.curdir):
        for filename in fnmatch.filter(files, pattern):
           yield os.path.join(path, filename)
 
+def _update_pysam_files(cf, destdir):
+  for filename in cf:
+     if not filename: continue
+     dest = filename + ".pysam.c"
+     with open( filename ) as infile:
+        with open( dest, "w" ) as outfile:
+           outfile.write( '#include "pysam.h"\n\n' )
+           outfile.write( re.sub( "stderr", "pysamerr", "".join(infile.readlines()) ) )
+  with open( os.path.join( destdir, "pysam.h" ), "w" )as outfile:
+     outfile.write ("""#ifndef PYSAM_H
+#define PYSAM_H
+#include "stdio.h"
+extern FILE * pysamerr;
+#endif
+""")
 
 # copy samtools source
 if len(sys.argv) >= 2 and sys.argv[1] == "import":
@@ -80,25 +96,26 @@ if len(sys.argv) >= 2 and sys.argv[1] == "import":
       print "installed latest source code from %s: %i files copied" % (srcdir, ncopied)
       # redirect stderr to pysamerr and replace bam.h with a stub.
       print "applying stderr redirection"
+     
+      _update_pysam_files(cf, destdir)
       
-      for filename in cf:
-         if not filename: continue
-         dest = filename + ".pysam.c"
-         with open( filename ) as infile:
-            with open( dest, "w" ) as outfile:
-               outfile.write( '#include "pysam.h"\n\n' )
-               outfile.write( re.sub( "stderr", "pysamerr", "".join(infile.readlines()) ) )
-      
-      with open( os.path.join( destdir, "pysam.h" ), "w" )as outfile:
-         outfile.write ("""#ifndef PYSAM_H
-#define PYSAM_H
-#include "stdio.h"
-extern FILE * pysamerr;
-#endif
-""")
 
    sys.exit(0)
 
+if len(sys.argv) >= 2 and sys.argv[1] == "refresh":
+    print "refreshing latest source code from .c to .pysam.c"
+# redirect stderr to pysamerr and replace bam.h with a stub.
+    print "applying stderr redirection"
+    for destdir in ('samtools', 'tabix'):
+        pysamcfiles = locate( "*.pysam.c", destdir )
+        for f in pysamcfiles: os.remove(f)
+        cfiles = locate( "*.c", destdir )
+        _update_pysam_files(cfiles, destdir)
+
+    sys.exit(0)
+
+
+
 from ez_setup import use_setuptools
 use_setuptools()
 
@@ -126,15 +143,23 @@ Topic :: Scientific/Engineering
 Topic :: Scientific/Engineering :: Bioinformatics
 """
 
+if platform.system()=='Windows':
+    include_os = ['win32']
+    os_c_files = ['win32/getopt.c']
+else:
+    include_os = []
+    os_c_files = []
+
 samtools = Extension(
     "csamtools",                   # name of extension
     [ "pysam/csamtools.pyx" ]  +\
         [ "pysam/%s" % x for x in (
                 "pysam_util.c", )] +\
         glob.glob( os.path.join( "samtools", "*.pysam.c" )) +\
+        os_c_files + \
         glob.glob( os.path.join( "samtools", "*", "*.pysam.c" ) ),
     library_dirs=[],
-    include_dirs=[ "samtools", "pysam" ],
+    include_dirs=[ "samtools", "pysam" ] + include_os,
     libraries=[ "z", ],
     language="c",
     define_macros = [('_FILE_OFFSET_BITS','64'),
@@ -143,11 +168,30 @@ samtools = Extension(
 
 tabix = Extension(
     "ctabix",                   # name of extension
-    [ "pysam/ctabix.pyx" ]  +\
+    [ "pysam/ctabix.pyx", ]  +\
        [ "pysam/%s" % x for x in ( "tabix_util.c", )] +\
+        os_c_files + \
        glob.glob( os.path.join( "tabix", "*.pysam.c" ) ),
     library_dirs=[],
-    include_dirs=[ "tabix", "pysam" ],
+    include_dirs=[ "tabix", "pysam" ] + include_os,
+    libraries=[ "z", ],
+    language="c",
+    )
+
+tabproxies = Extension(
+    "TabProxies",                   # name of extension
+    [ "pysam/TabProxies.pyx", ] + os_c_files,
+    library_dirs=[],
+    include_dirs= include_os,
+    libraries=[ "z", ],
+    language="c",
+    )
+
+cvcf = Extension(
+    "cvcf",                   # name of extension
+    [ "pysam/cvcf.pyx", ] + os_c_files,
+    library_dirs=[],
+    include_dirs= ["tabix",] + include_os,
     libraries=[ "z", ],
     language="c",
     )
@@ -168,9 +212,11 @@ metadata = {
       "pysam/namedtuple",
       "pysam/version" ],
     'requires' : ['cython (>=0.12)'],
-    'ext_modules': [samtools, tabix],
+    'ext_modules': [samtools, tabix, tabproxies, cvcf ],
     'cmdclass' : {'build_ext': build_ext},
     'install_requires' : ['cython>=0.12.1',], 
+    # do not pack in order to permit linking to csamtools.so
+    'zip_safe' :False,
     }
 
 if __name__=='__main__':
diff --git a/tabix/bedidx.c.pysam.c b/tabix/bedidx.c.pysam.c
new file mode 100644 (file)
index 0000000..c3ab06f
--- /dev/null
@@ -0,0 +1,158 @@
+#include "pysam.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <zlib.h>
+
+#include "ksort.h"
+KSORT_INIT_GENERIC(uint64_t)
+
+#include "kseq.h"
+KSTREAM_INIT(gzFile, gzread, 8192)
+
+typedef struct {
+       int n, m;
+       uint64_t *a;
+       int *idx;
+} bed_reglist_t;
+
+#include "khash.h"
+KHASH_MAP_INIT_STR(reg, bed_reglist_t)
+
+#define LIDX_SHIFT 13
+
+typedef kh_reg_t reghash_t;
+
+int *bed_index_core(int n, uint64_t *a, int *n_idx)
+{
+       int i, j, m, *idx;
+       m = *n_idx = 0; idx = 0;
+       for (i = 0; i < n; ++i) {
+               int beg, end;
+               beg = a[i]>>32 >> LIDX_SHIFT; end = ((uint32_t)a[i]) >> LIDX_SHIFT;
+               if (m < end + 1) {
+                       int oldm = m;
+                       m = end + 1;
+                       kroundup32(m);
+                       idx = realloc(idx, m * sizeof(int));
+                       for (j = oldm; j < m; ++j) idx[j] = -1;
+               }
+               if (beg == end) {
+                       if (idx[beg] < 0) idx[beg] = i;
+               } else {
+                       for (j = beg; j <= end; ++j)
+                               if (idx[j] < 0) idx[j] = i;
+               }
+               *n_idx = end + 1;
+       }
+       return idx;
+}
+
+void bed_index(void *_h)
+{
+       reghash_t *h = (reghash_t*)_h;
+       khint_t k;
+       for (k = 0; k < kh_end(h); ++k) {
+               if (kh_exist(h, k)) {
+                       bed_reglist_t *p = &kh_val(h, k);
+                       if (p->idx) free(p->idx);
+                       ks_introsort(uint64_t, p->n, p->a);
+                       p->idx = bed_index_core(p->n, p->a, &p->m);
+               }
+       }
+}
+
+int bed_overlap_core(const bed_reglist_t *p, int beg, int end)
+{
+       int i, min_off;
+       if (p->n == 0) return 0;
+       min_off = (beg>>LIDX_SHIFT >= p->n)? p->idx[p->n-1] : p->idx[beg>>LIDX_SHIFT];
+       if (min_off < 0) { // TODO: this block can be improved, but speed should not matter too much here
+               int n = beg>>LIDX_SHIFT;
+               if (n > p->n) n = p->n;
+               for (i = n - 1; i >= 0; --i)
+                       if (p->idx[i] >= 0) break;
+               min_off = i >= 0? p->idx[i] : 0;
+       }
+       for (i = min_off; i < p->n; ++i) {
+               if ((int)(p->a[i]>>32) >= end) break; // out of range; no need to proceed
+               if ((int32_t)p->a[i] > beg && (int32_t)(p->a[i]>>32) < end)
+                       return 1; // find the overlap; return
+       }
+       return 0;
+}
+
+int bed_overlap(const void *_h, const char *chr, int beg, int end)
+{
+       const reghash_t *h = (const reghash_t*)_h;
+       khint_t k;
+       if (!h) return 0;
+       k = kh_get(reg, h, chr);
+       if (k == kh_end(h)) return 0;
+       return bed_overlap_core(&kh_val(h, k), beg, end);
+}
+
+void *bed_read(const char *fn)
+{
+       reghash_t *h = kh_init(reg);
+       gzFile fp;
+       kstream_t *ks;
+       int dret;
+       kstring_t *str;
+       // read the list
+       fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
+       if (fp == 0) return 0;
+       str = calloc(1, sizeof(kstring_t));
+       ks = ks_init(fp);
+       while (ks_getuntil(ks, 0, str, &dret) >= 0) { // read the chr name
+               int beg = -1, end = -1;
+               bed_reglist_t *p;
+               khint_t k = kh_get(reg, h, str->s);
+               if (k == kh_end(h)) { // absent from the hash table
+                       int ret;
+                       char *s = strdup(str->s);
+                       k = kh_put(reg, h, s, &ret);
+                       memset(&kh_val(h, k), 0, sizeof(bed_reglist_t));
+               }
+               p = &kh_val(h, k);
+               if (dret != '\n') { // if the lines has other characters
+                       if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0])) {
+                               beg = atoi(str->s); // begin
+                               if (dret != '\n') {
+                                       if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0]))
+                                               end = atoi(str->s); // end
+                               }
+                       }
+               }
+               if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n'); // skip the rest of the line
+               if (end < 0 && beg > 0) end = beg, beg = beg - 1; // if there is only one column
+               if (beg >= 0 && end > beg) {
+                       if (p->n == p->m) {
+                               p->m = p->m? p->m<<1 : 4;
+                               p->a = realloc(p->a, p->m * 8);
+                       }
+                       p->a[p->n++] = (uint64_t)beg<<32 | end;
+               }
+       }
+       ks_destroy(ks);
+       gzclose(fp);
+       free(str->s); free(str);
+       bed_index(h);
+       return h;
+}
+
+void bed_destroy(void *_h)
+{
+       reghash_t *h = (reghash_t*)_h;
+       khint_t k;
+       for (k = 0; k < kh_end(h); ++k) {
+               if (kh_exist(h, k)) {
+                       free(kh_val(h, k).a);
+                       free(kh_val(h, k).idx);
+                       free((char*)kh_key(h, k));
+               }
+       }
+       kh_destroy(reg, h);
+}
index 6d5995f6aa613b42d05a72124fd8e564357de231..067b89d1950d0c677626d77eb608a701bb422b2e 100644 (file)
@@ -113,7 +113,7 @@ report_error(BGZF* fp, const char* message) {
     fp->error = message;
 }
 
-int is_bgzipped(const char *fn)
+int bgzf_check_bgzf(const char *fn)
 {
     BGZF *fp;
     uint8_t buf[10],magic[10]="\037\213\010\4\0\0\0\0\0\377";
@@ -121,7 +121,7 @@ int is_bgzipped(const char *fn)
 
     if ((fp = bgzf_open(fn, "r")) == 0) 
     {
-        fprintf(pysamerr, "[is_bgzipped] failed to open the file: %s\n",fn);
+        fprintf(pysamerr, "[bgzf_check_bgzf] failed to open the file: %s\n",fn);
         return -1;
     }
 
@@ -176,7 +176,7 @@ open_read(int fd)
 
 static
 BGZF*
-open_write(int fd, bool is_uncompressed)
+open_write(int fd, int compress_level) // compress_level==-1 for the default level
 {
     FILE* file = fdopen(fd, "w");
     BGZF* fp;
@@ -184,7 +184,9 @@ open_write(int fd, bool is_uncompressed)
        fp = malloc(sizeof(BGZF));
     fp->file_descriptor = fd;
     fp->open_mode = 'w';
-    fp->owned_file = 0; fp->is_uncompressed = is_uncompressed;
+    fp->owned_file = 0;
+       fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
+       if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
 #ifdef _USE_KNETFILE
     fp->x.fpw = file;
 #else
@@ -205,7 +207,7 @@ BGZF*
 bgzf_open(const char* __restrict path, const char* __restrict mode)
 {
     BGZF* fp = NULL;
-    if (mode[0] == 'r' || mode[0] == 'R') { /* The reading mode is preferred. */
+    if (strchr(mode, 'r') || strchr(mode, 'R')) { /* The reading mode is preferred. */
 #ifdef _USE_KNETFILE
                knetFile *file = knet_open(path, mode);
                if (file == 0) return 0;
@@ -222,18 +224,23 @@ bgzf_open(const char* __restrict path, const char* __restrict mode)
                if (fd == -1) return 0;
         fp = open_read(fd);
 #endif
-    } else if (mode[0] == 'w' || mode[0] == 'W') {
-               int fd, oflag = O_WRONLY | O_CREAT | O_TRUNC;
+    } else if (strchr(mode, 'w') || strchr(mode, 'W')) {
+               int fd, compress_level = -1, oflag = O_WRONLY | O_CREAT | O_TRUNC;
 #ifdef _WIN32
                oflag |= O_BINARY;
 #endif
                fd = open(path, oflag, 0666);
                if (fd == -1) return 0;
-        fp = open_write(fd, strstr(mode, "u")? 1 : 0);
-    }
-    if (fp != NULL) {
-        fp->owned_file = 1;
+               { // set compress_level
+                       int i;
+                       for (i = 0; mode[i]; ++i)
+                               if (mode[i] >= '0' && mode[i] <= '9') break;
+                       if (mode[i]) compress_level = (int)mode[i] - '0';
+                       if (strchr(mode, 'u')) compress_level = 0;
+               }
+        fp = open_write(fd, compress_level);
     }
+    if (fp != NULL) fp->owned_file = 1;
     return fp;
 }
 
@@ -244,7 +251,12 @@ bgzf_fdopen(int fd, const char * __restrict mode)
     if (mode[0] == 'r' || mode[0] == 'R') {
         return open_read(fd);
     } else if (mode[0] == 'w' || mode[0] == 'W') {
-        return open_write(fd, strstr(mode, "u")? 1 : 0);
+               int i, compress_level = -1;
+               for (i = 0; mode[i]; ++i)
+                       if (mode[i] >= '0' && mode[i] <= '9') break;
+               if (mode[i]) compress_level = (int)mode[i] - '0';
+               if (strchr(mode, 'u')) compress_level = 0;
+        return open_write(fd, compress_level);
     } else {
         return NULL;
     }
@@ -284,7 +296,6 @@ deflate_block(BGZF* fp, int block_length)
     int input_length = block_length;
     int compressed_length = 0;
     while (1) {
-               int compress_level = fp->is_uncompressed? 0 : Z_DEFAULT_COMPRESSION;
         z_stream zs;
         zs.zalloc = NULL;
         zs.zfree = NULL;
@@ -293,7 +304,7 @@ deflate_block(BGZF* fp, int block_length)
         zs.next_out = (void*)&buffer[BLOCK_HEADER_LENGTH];
         zs.avail_out = buffer_size - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
 
-        int status = deflateInit2(&zs, compress_level, Z_DEFLATED,
+        int status = deflateInit2(&zs, fp->compress_level, Z_DEFLATED,
                                   GZIP_WINDOW_BITS, Z_DEFAULT_MEM_LEVEL, Z_DEFAULT_STRATEGY);
         if (status != Z_OK) {
             report_error(fp, "deflate init failed");
@@ -360,6 +371,7 @@ inflate_block(BGZF* fp, int block_length)
     // Inflate the block in fp->compressed_block into fp->uncompressed_block
 
     z_stream zs;
+       int status;
     zs.zalloc = NULL;
     zs.zfree = NULL;
     zs.next_in = fp->compressed_block + 18;
@@ -367,7 +379,7 @@ inflate_block(BGZF* fp, int block_length)
     zs.next_out = fp->uncompressed_block;
     zs.avail_out = fp->uncompressed_block_size;
 
-    int status = inflateInit2(&zs, GZIP_WINDOW_BITS);
+    status = inflateInit2(&zs, GZIP_WINDOW_BITS);
     if (status != Z_OK) {
         report_error(fp, "inflate init failed");
         return -1;
@@ -461,15 +473,15 @@ int
 bgzf_read_block(BGZF* fp)
 {
     bgzf_byte_t header[BLOCK_HEADER_LENGTH];
-       int size = 0;
+       int count, size = 0, block_length, remaining;
 #ifdef _USE_KNETFILE
     int64_t block_address = knet_tell(fp->x.fpr);
        if (load_block_from_cache(fp, block_address)) return 0;
-    int count = knet_read(fp->x.fpr, header, sizeof(header));
+    count = knet_read(fp->x.fpr, header, sizeof(header));
 #else
     int64_t block_address = ftello(fp->file);
        if (load_block_from_cache(fp, block_address)) return 0;
-    int count = fread(header, 1, sizeof(header), fp->file);
+    count = fread(header, 1, sizeof(header), fp->file);
 #endif
     if (count == 0) {
         fp->block_length = 0;
@@ -484,10 +496,10 @@ bgzf_read_block(BGZF* fp)
         report_error(fp, "invalid block header");
         return -1;
     }
-    int block_length = unpackInt16((uint8_t*)&header[16]) + 1;
+    block_length = unpackInt16((uint8_t*)&header[16]) + 1;
     bgzf_byte_t* compressed_block = (bgzf_byte_t*) fp->compressed_block;
     memcpy(compressed_block, header, BLOCK_HEADER_LENGTH);
-    int remaining = block_length - BLOCK_HEADER_LENGTH;
+    remaining = block_length - BLOCK_HEADER_LENGTH;
 #ifdef _USE_KNETFILE
     count = knet_read(fp->x.fpr, &compressed_block[BLOCK_HEADER_LENGTH], remaining);
 #else
@@ -499,9 +511,7 @@ bgzf_read_block(BGZF* fp)
     }
        size += count;
     count = inflate_block(fp, block_length);
-    if (count < 0) {
-        return -1;
-    }
+    if (count < 0) return -1;
     if (fp->block_length != 0) {
         // Do not reset offset if this read follows a seek.
         fp->block_offset = 0;
@@ -526,7 +536,8 @@ bgzf_read(BGZF* fp, void* data, int length)
     int bytes_read = 0;
     bgzf_byte_t* output = data;
     while (bytes_read < length) {
-        int available = fp->block_length - fp->block_offset;
+        int copy_length, available = fp->block_length - fp->block_offset;
+               bgzf_byte_t *buffer;
         if (available <= 0) {
             if (bgzf_read_block(fp) != 0) {
                 return -1;
@@ -536,8 +547,8 @@ bgzf_read(BGZF* fp, void* data, int length)
                 break;
             }
         }
-        int copy_length = bgzf_min(length-bytes_read, available);
-        bgzf_byte_t* buffer = fp->uncompressed_block;
+        copy_length = bgzf_min(length-bytes_read, available);
+        buffer = fp->uncompressed_block;
         memcpy(output, buffer + fp->block_offset, copy_length);
         fp->block_offset += copy_length;
         output += copy_length;
@@ -555,19 +566,16 @@ bgzf_read(BGZF* fp, void* data, int length)
     return bytes_read;
 }
 
-static
-int
-flush_block(BGZF* fp)
+int bgzf_flush(BGZF* fp)
 {
     while (fp->block_offset > 0) {
-        int block_length = deflate_block(fp, fp->block_offset);
-        if (block_length < 0) {
-            return -1;
-        }
+        int count, block_length;
+               block_length = deflate_block(fp, fp->block_offset);
+        if (block_length < 0) return -1;
 #ifdef _USE_KNETFILE
-        int count = fwrite(fp->compressed_block, 1, block_length, fp->x.fpw);
+        count = fwrite(fp->compressed_block, 1, block_length, fp->x.fpw);
 #else
-        int count = fwrite(fp->compressed_block, 1, block_length, fp->file);
+        count = fwrite(fp->compressed_block, 1, block_length, fp->file);
 #endif
         if (count != block_length) {
             report_error(fp, "write failed");
@@ -578,21 +586,28 @@ flush_block(BGZF* fp)
     return 0;
 }
 
-int
-bgzf_write(BGZF* fp, const void* data, int length)
+int bgzf_flush_try(BGZF *fp, int size)
 {
+       if (fp->block_offset + size > fp->uncompressed_block_size)
+               return bgzf_flush(fp);
+       return -1;
+}
+
+int bgzf_write(BGZF* fp, const void* data, int length)
+{
+       const bgzf_byte_t *input = data;
+       int block_length, bytes_written;
     if (fp->open_mode != 'w') {
         report_error(fp, "file not open for writing");
         return -1;
     }
 
-    if (fp->uncompressed_block == NULL) {
+    if (fp->uncompressed_block == NULL)
         fp->uncompressed_block = malloc(fp->uncompressed_block_size);
-    }
 
-    const bgzf_byte_t* input = data;
-    int block_length = fp->uncompressed_block_size;
-    int bytes_written = 0;
+    input = data;
+    block_length = fp->uncompressed_block_size;
+    bytes_written = 0;
     while (bytes_written < length) {
         int copy_length = bgzf_min(block_length - fp->block_offset, length - bytes_written);
         bgzf_byte_t* buffer = fp->uncompressed_block;
@@ -601,7 +616,7 @@ bgzf_write(BGZF* fp, const void* data, int length)
         input += copy_length;
         bytes_written += copy_length;
         if (fp->block_offset == block_length) {
-            if (flush_block(fp) != 0) {
+            if (bgzf_flush(fp) != 0) {
                 break;
             }
         }
@@ -609,13 +624,10 @@ bgzf_write(BGZF* fp, const void* data, int length)
     return bytes_written;
 }
 
-int
-bgzf_close(BGZF* fp)
+int bgzf_close(BGZF* fp)
 {
     if (fp->open_mode == 'w') {
-        if (flush_block(fp) != 0) {
-            return -1;
-        }
+        if (bgzf_flush(fp) != 0) return -1;
                { // add an empty block
                        int count, block_length = deflate_block(fp, 0);
 #ifdef _USE_KNETFILE
@@ -640,9 +652,7 @@ bgzf_close(BGZF* fp)
                else ret = knet_close(fp->x.fpr);
         if (ret != 0) return -1;
 #else
-        if (fclose(fp->file) != 0) {
-            return -1;
-        }
+        if (fclose(fp->file) != 0) return -1;
 #endif
     }
     free(fp->uncompressed_block);
@@ -676,9 +686,11 @@ int bgzf_check_EOF(BGZF *fp)
        return (memcmp(magic, buf, 28) == 0)? 1 : 0;
 }
 
-int64_t
-bgzf_seek(BGZF* fp, int64_t pos, int where)
+int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
 {
+       int block_offset;
+       int64_t block_address;
+
     if (fp->open_mode != 'r') {
         report_error(fp, "file not open for read");
         return -1;
@@ -687,8 +699,8 @@ bgzf_seek(BGZF* fp, int64_t pos, int where)
         report_error(fp, "unimplemented seek option");
         return -1;
     }
-    int block_offset = pos & 0xFFFF;
-    int64_t block_address = (pos >> 16) & 0xFFFFFFFFFFFFLL;
+    block_offset = pos & 0xFFFF;
+    block_address = (pos >> 16) & 0xFFFFFFFFFFFFLL;
 #ifdef _USE_KNETFILE
     if (knet_seek(fp->x.fpr, block_address, SEEK_SET) != 0) {
 #else
index 70f497e819442adc843f66c4023012fade6005e8..7295f37425df320199aef87bb7bb80e482cc38bd 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <stdint.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <zlib.h>
 #ifdef _USE_KNETFILE
 #include "knetfile.h"
@@ -37,7 +36,7 @@
 typedef struct {
     int file_descriptor;
     char open_mode;  // 'r' or 'w'
-    bool owned_file, is_uncompressed;
+    int16_t owned_file, compress_level;
 #ifdef _USE_KNETFILE
        union {
                knetFile *fpr;
@@ -62,13 +61,6 @@ typedef struct {
 extern "C" {
 #endif
 
-/* 
- * Checks the magic string of the file. Returns 1
- *  for bgzipped files, -1 on errors and 0 for files
- *  without the bgzip magic string.
- */
-int is_bgzipped(const char *path);
-
 /*
  * Open an existing file descriptor for reading or writing.
  * Mode must be either "r" or "w".
@@ -133,8 +125,10 @@ int64_t bgzf_seek(BGZF* fp, int64_t pos, int where);
 void bgzf_set_cache_size(BGZF *fp, int cache_size);
 
 int bgzf_check_EOF(BGZF *fp);
-
 int bgzf_read_block(BGZF* fp);
+int bgzf_flush(BGZF* fp);
+int bgzf_flush_try(BGZF *fp, int size);
+int bgzf_check_bgzf(const char *fn);
 
 #ifdef __cplusplus
 }
index d0965ec1067f3ff0e03a1d068980131772e47c55..486e26fc1c7e6daf9ed472be9b1d3ba590963fd8 100644 (file)
@@ -158,32 +158,31 @@ static int get_tid(ti_index_t *idx, const char *ss)
        return tid;
 }
 
-static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
+int ti_get_intv(const ti_conf_t *conf, int len, char *line, ti_interval_t *intv)
 {
-       int i, b = 0, id = 1;
+       int i, b = 0, id = 1, ncols = 0;
        char *s;
-       intv->tid = intv->beg = intv->end = intv->bin = -1;
-       for (i = 0; i <= str->l; ++i) {
-               if (str->s[i] == '\t' || str->s[i] == 0) {
-                       if (id == idx->conf.sc) {
-                               str->s[i] = 0;
-                               intv->tid = get_tid(idx, str->s + b);
-                               if (i != str->l) str->s[i] = '\t';
-                       } else if (id == idx->conf.bc) {
+       intv->ss = intv->se = 0; intv->beg = intv->end = -1;
+       for (i = 0; i <= len; ++i) {
+               if (line[i] == '\t' || line[i] == 0) {
+            ++ncols;
+                       if (id == conf->sc) {
+                               intv->ss = line + b; intv->se = line + i;
+                       } else if (id == conf->bc) {
                                // here ->beg is 0-based.
-                               intv->beg = intv->end = strtol(str->s + b, &s, 0);
-                               if (!(idx->conf.preset&TI_FLAG_UCSC)) --intv->beg;
+                               intv->beg = intv->end = strtol(line + b, &s, 0);
+                               if (!(conf->preset&TI_FLAG_UCSC)) --intv->beg;
                                else ++intv->end;
                                if (intv->beg < 0) intv->beg = 0;
                                if (intv->end < 1) intv->end = 1;
                        } else {
-                               if ((idx->conf.preset&0xffff) == TI_PRESET_GENERIC) {
-                                       if (id == idx->conf.ec) intv->end = strtol(str->s + b, &s, 0);
-                               } else if ((idx->conf.preset&0xffff) == TI_PRESET_SAM) {
+                               if ((conf->preset&0xffff) == TI_PRESET_GENERIC) {
+                                       if (id == conf->ec) intv->end = strtol(line + b, &s, 0);
+                               } else if ((conf->preset&0xffff) == TI_PRESET_SAM) {
                                        if (id == 6) { // CIGAR
                                                int l = 0, op;
                                                char *t;
-                                               for (s = str->s + b; s < str->s + i;) {
+                                               for (s = line + b; s < line + i;) {
                                                        long x = strtol(s, &t, 10);
                                                        op = toupper(*t);
                                                        if (op == 'M' || op == 'D' || op == 'N') l += x;
@@ -192,21 +191,21 @@ static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
                                                if (l == 0) l = 1;
                                                intv->end = intv->beg + l;
                                        }
-                               } else if ((idx->conf.preset&0xffff) == TI_PRESET_VCF) {
+                               } else if ((conf->preset&0xffff) == TI_PRESET_VCF) {
                                        // FIXME: the following is NOT tested and is likely to be buggy
                                        if (id == 4) {
                                                if (b < i) intv->end = intv->beg + (i - b);
                                        } else if (id == 8) { // look for "END="
-                                               int c = str->s[i];
-                                               str->s[i] = 0;
-                                               s = strstr(str->s + b, "END=");
-                                               if (s == str->s + b) s += 4;
+                                               int c = line[i];
+                                               line[i] = 0;
+                                               s = strstr(line + b, "END=");
+                                               if (s == line + b) s += 4;
                                                else if (s) {
-                                                       s = strstr(str->s + b, ";END=");
+                                                       s = strstr(line + b, ";END=");
                                                        if (s) s += 5;
                                                }
                                                if (s) intv->end = strtol(s, &s, 0);
-                                               str->s[i] = c;
+                                               line[i] = c;
                                        }
                                }
                        }
@@ -214,11 +213,33 @@ static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
                        ++id;
                }
        }
-       if (intv->tid < 0 || intv->beg < 0 || intv->end < 0) return -1;
-       intv->bin = ti_reg2bin(intv->beg, intv->end);
+/*
+       if (ncols < conf->sc || ncols < conf->bc || ncols < conf->ec) {
+               if (ncols == 1) fprintf(pysamerr,"[get_intv] Is the file tab-delimited? The line has %d field only: %s\n", ncols, line);
+               else fprintf(pysamerr,"[get_intv] The line has %d field(s) only: %s\n", ncols, line);
+               exit(1);
+       }
+*/
+       if (intv->ss == 0 || intv->se == 0 || intv->beg < 0 || intv->end < 0) return -1;
        return 0;
 }
 
+static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
+{
+       ti_interval_t x;
+       intv->tid = intv->beg = intv->end = intv->bin = -1;
+       if (ti_get_intv(&idx->conf, str->l, str->s, &x) == 0) {
+               int c = *x.se;
+               *x.se = '\0'; intv->tid = get_tid(idx, x.ss); *x.se = c;
+               intv->beg = x.beg; intv->end = x.end;
+               intv->bin = ti_reg2bin(intv->beg, intv->end);
+               return (intv->tid >= 0 && intv->beg >= 0 && intv->end >= 0)? 0 : -1;
+       } else {
+               fprintf(pysamerr, "[%s] the following line cannot be parsed and skipped: %s\n", __func__, str->s);
+               return -1;
+       }
+}
+
 /************
  * indexing *
  ************/
@@ -324,10 +345,15 @@ ti_index_t *ti_index_core(BGZF *fp, const ti_conf_t *conf)
                        continue;
                }
                get_intv(idx, str, &intv);
+        if ( intv.beg<0 || intv.end<0 )
+        {
+            fprintf(pysamerr,"[ti_index_core] the indexes overlap or are out of bounds\n");
+            exit(1);
+        }
                if (last_tid != intv.tid) { // change of chromosomes
             if (last_tid>intv.tid )
             {
-                fprintf(pysamerr,"[ti_index_core] the chromosome blocks not continuous at line %llu, is the file sorted?\n",(unsigned long long)lineno);
+                fprintf(pysamerr,"[ti_index_core] the chromosome blocks not continuous at line %llu, is the file sorted? [pos %d]\n",(unsigned long long)lineno,intv.beg+1);
                 exit(1);
             }
                        last_tid = intv.tid;
@@ -904,6 +930,8 @@ int ti_fetch(BGZF *fp, const ti_index_t *idx, int tid, int beg, int end, void *d
        return 0;
 }
 
+const ti_conf_t *ti_get_conf(ti_index_t *idx) { return idx? &idx->conf : 0; }
+
 /*******************
  * High-level APIs *
  *******************/
diff --git a/tabix/kseq.h b/tabix/kseq.h
new file mode 100644 (file)
index 0000000..82face0
--- /dev/null
@@ -0,0 +1,227 @@
+/* The MIT License
+
+   Copyright (c) 2008 Genome Research Ltd (GRL).
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   "Software"), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+   SOFTWARE.
+*/
+
+/* Contact: Heng Li <lh3@sanger.ac.uk> */
+
+/*
+  2009-07-16 (lh3): in kstream_t, change "char*" to "unsigned char*"
+ */
+
+/* Last Modified: 12APR2009 */
+
+#ifndef AC_KSEQ_H
+#define AC_KSEQ_H
+
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define KS_SEP_SPACE 0 // isspace(): \t, \n, \v, \f, \r
+#define KS_SEP_TAB   1 // isspace() && !' '
+#define KS_SEP_MAX   1
+
+#define __KS_TYPE(type_t)                                              \
+       typedef struct __kstream_t {                            \
+               unsigned char *buf;                                             \
+               int begin, end, is_eof;                                 \
+               type_t f;                                                               \
+       } kstream_t;
+
+#define ks_eof(ks) ((ks)->is_eof && (ks)->begin >= (ks)->end)
+#define ks_rewind(ks) ((ks)->is_eof = (ks)->begin = (ks)->end = 0)
+
+#define __KS_BASIC(type_t, __bufsize)                                                          \
+       static inline kstream_t *ks_init(type_t f)                                              \
+       {                                                                                                                               \
+               kstream_t *ks = (kstream_t*)calloc(1, sizeof(kstream_t));       \
+               ks->f = f;                                                                                                      \
+               ks->buf = malloc(__bufsize);                                                            \
+               return ks;                                                                                                      \
+       }                                                                                                                               \
+       static inline void ks_destroy(kstream_t *ks)                                    \
+       {                                                                                                                               \
+               if (ks) {                                                                                                       \
+                       free(ks->buf);                                                                                  \
+                       free(ks);                                                                                               \
+               }                                                                                                                       \
+       }
+
+#define __KS_GETC(__read, __bufsize)                                           \
+       static inline int ks_getc(kstream_t *ks)                                \
+       {                                                                                                               \
+               if (ks->is_eof && ks->begin >= ks->end) return -1;      \
+               if (ks->begin >= ks->end) {                                                     \
+                       ks->begin = 0;                                                                  \
+                       ks->end = __read(ks->f, ks->buf, __bufsize);    \
+                       if (ks->end < __bufsize) ks->is_eof = 1;                \
+                       if (ks->end == 0) return -1;                                    \
+               }                                                                                                       \
+               return (int)ks->buf[ks->begin++];                                       \
+       }
+
+#ifndef KSTRING_T
+#define KSTRING_T kstring_t
+typedef struct __kstring_t {
+       size_t l, m;
+       char *s;
+} kstring_t;
+#endif
+
+#ifndef kroundup32
+#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
+#endif
+
+#define __KS_GETUNTIL(__read, __bufsize)                                                               \
+       static int ks_getuntil(kstream_t *ks, int delimiter, kstring_t *str, int *dret) \
+       {                                                                                                                                       \
+               if (dret) *dret = 0;                                                                                    \
+               str->l = 0;                                                                                                             \
+               if (ks->begin >= ks->end && ks->is_eof) return -1;                              \
+               for (;;) {                                                                                                              \
+                       int i;                                                                                                          \
+                       if (ks->begin >= ks->end) {                                                                     \
+                               if (!ks->is_eof) {                                                                              \
+                                       ks->begin = 0;                                                                          \
+                                       ks->end = __read(ks->f, ks->buf, __bufsize);            \
+                                       if (ks->end < __bufsize) ks->is_eof = 1;                        \
+                                       if (ks->end == 0) break;                                                        \
+                               } else break;                                                                                   \
+                       }                                                                                                                       \
+                       if (delimiter > KS_SEP_MAX) {                                                           \
+                               for (i = ks->begin; i < ks->end; ++i)                                   \
+                                       if (ks->buf[i] == delimiter) break;                                     \
+                       } else if (delimiter == KS_SEP_SPACE) {                                         \
+                               for (i = ks->begin; i < ks->end; ++i)                                   \
+                                       if (isspace(ks->buf[i])) break;                                         \
+                       } else if (delimiter == KS_SEP_TAB) {                                           \
+                               for (i = ks->begin; i < ks->end; ++i)                                   \
+                                       if (isspace(ks->buf[i]) && ks->buf[i] != ' ') break; \
+                       } else i = 0; /* never come to here! */                                         \
+                       if (str->m - str->l < i - ks->begin + 1) {                                      \
+                               str->m = str->l + (i - ks->begin) + 1;                                  \
+                               kroundup32(str->m);                                                                             \
+                               str->s = (char*)realloc(str->s, str->m);                                \
+                       }                                                                                                                       \
+                       memcpy(str->s + str->l, ks->buf + ks->begin, i - ks->begin); \
+                       str->l = str->l + (i - ks->begin);                                                      \
+                       ks->begin = i + 1;                                                                                      \
+                       if (i < ks->end) {                                                                                      \
+                               if (dret) *dret = ks->buf[i];                                                   \
+                               break;                                                                                                  \
+                       }                                                                                                                       \
+               }                                                                                                                               \
+               if (str->l == 0) {                                                                                              \
+                       str->m = 1;                                                                                                     \
+                       str->s = (char*)calloc(1, 1);                                                           \
+               }                                                                                                                               \
+               str->s[str->l] = '\0';                                                                                  \
+               return str->l;                                                                                                  \
+       }
+
+#define KSTREAM_INIT(type_t, __read, __bufsize) \
+       __KS_TYPE(type_t)                                                       \
+       __KS_BASIC(type_t, __bufsize)                           \
+       __KS_GETC(__read, __bufsize)                            \
+       __KS_GETUNTIL(__read, __bufsize)
+
+#define __KSEQ_BASIC(type_t)                                                                                   \
+       static inline kseq_t *kseq_init(type_t fd)                                                      \
+       {                                                                                                                                       \
+               kseq_t *s = (kseq_t*)calloc(1, sizeof(kseq_t));                                 \
+               s->f = ks_init(fd);                                                                                             \
+               return s;                                                                                                               \
+       }                                                                                                                                       \
+       static inline void kseq_rewind(kseq_t *ks)                                                      \
+       {                                                                                                                                       \
+               ks->last_char = 0;                                                                                              \
+               ks->f->is_eof = ks->f->begin = ks->f->end = 0;                                  \
+       }                                                                                                                                       \
+       static inline void kseq_destroy(kseq_t *ks)                                                     \
+       {                                                                                                                                       \
+               if (!ks) return;                                                                                                \
+               free(ks->name.s); free(ks->comment.s); free(ks->seq.s); free(ks->qual.s); \
+               ks_destroy(ks->f);                                                                                              \
+               free(ks);                                                                                                               \
+       }
+
+/* Return value:
+   >=0  length of the sequence (normal)
+   -1   end-of-file
+   -2   truncated quality string
+ */
+#define __KSEQ_READ                                                                                                            \
+       static int kseq_read(kseq_t *seq)                                                                       \
+       {                                                                                                                                       \
+               int c;                                                                                                                  \
+               kstream_t *ks = seq->f;                                                                                 \
+               if (seq->last_char == 0) { /* then jump to the next header line */ \
+                       while ((c = ks_getc(ks)) != -1 && c != '>' && c != '@');        \
+                       if (c == -1) return -1; /* end of file */                                       \
+                       seq->last_char = c;                                                                                     \
+               } /* the first header char has been read */                                             \
+               seq->comment.l = seq->seq.l = seq->qual.l = 0;                                  \
+               if (ks_getuntil(ks, 0, &seq->name, &c) < 0) return -1;                  \
+               if (c != '\n') ks_getuntil(ks, '\n', &seq->comment, 0);                 \
+               while ((c = ks_getc(ks)) != -1 && c != '>' && c != '+' && c != '@') { \
+                       if (isgraph(c)) { /* printable non-space character */           \
+                               if (seq->seq.l + 1 >= seq->seq.m) { /* double the memory */ \
+                                       seq->seq.m = seq->seq.l + 2;                                            \
+                                       kroundup32(seq->seq.m); /* rounded to next closest 2^k */ \
+                                       seq->seq.s = (char*)realloc(seq->seq.s, seq->seq.m); \
+                               }                                                                                                               \
+                               seq->seq.s[seq->seq.l++] = (char)c;                                             \
+                       }                                                                                                                       \
+               }                                                                                                                               \
+               if (c == '>' || c == '@') seq->last_char = c; /* the first header char has been read */ \
+               seq->seq.s[seq->seq.l] = 0;     /* null terminated string */            \
+               if (c != '+') return seq->seq.l; /* FASTA */                                    \
+               if (seq->qual.m < seq->seq.m) { /* allocate enough memory */    \
+                       seq->qual.m = seq->seq.m;                                                                       \
+                       seq->qual.s = (char*)realloc(seq->qual.s, seq->qual.m);         \
+               }                                                                                                                               \
+               while ((c = ks_getc(ks)) != -1 && c != '\n'); /* skip the rest of '+' line */ \
+               if (c == -1) return -2; /* we should not stop here */                   \
+               while ((c = ks_getc(ks)) != -1 && seq->qual.l < seq->seq.l)             \
+                       if (c >= 33 && c <= 127) seq->qual.s[seq->qual.l++] = (unsigned char)c; \
+               seq->qual.s[seq->qual.l] = 0; /* null terminated string */              \
+               seq->last_char = 0;     /* we have not come to the next header line */ \
+               if (seq->seq.l != seq->qual.l) return -2; /* qual string is shorter than seq string */ \
+               return seq->seq.l;                                                                                              \
+       }
+
+#define __KSEQ_TYPE(type_t)                                            \
+       typedef struct {                                                        \
+               kstring_t name, comment, seq, qual;             \
+               int last_char;                                                  \
+               kstream_t *f;                                                   \
+       } kseq_t;
+
+#define KSEQ_INIT(type_t, __read)                              \
+       KSTREAM_INIT(type_t, __read, 4096)                      \
+       __KSEQ_TYPE(type_t)                                                     \
+       __KSEQ_BASIC(type_t)                                            \
+       __KSEQ_READ
+
+#endif
diff --git a/tabix/msvc_compat.h b/tabix/msvc_compat.h
new file mode 100644 (file)
index 0000000..624cc99
--- /dev/null
@@ -0,0 +1,60 @@
+// Windows-specific code, include with:\r
+// #ifdef _MSC_VER\r
+// #include <msvc_compat.h>\r
+// #endif\r
+\r
+//#define _CRT_SECURE_NO_WARNINGS\r
+#ifndef MSVC_COMPAT_H\r
+#define MSVC_COMPAT_H\r
+\r
+#define inline __inline\r
+#define __func__ __FUNCTION__\r
+\r
+#include <float.h>\r
+#define isnan _isnan\r
+static int isinf(double x) {\r
+    int y = _finite(x);\r
+    if(y == 0) {\r
+       return 0;\r
+    } else {\r
+       return 1;\r
+    }\r
+}\r
+#define alloca _alloca\r
+#define atoll _atoi64\r
+\r
+#define ftello ftell\r
+
+typedef int bool;\r
+\r
+static int R_OK = 4;
+\r
+#ifndef lgamma\r
+/* Log gamma function\r
+ * \log{\Gamma(z)}\r
+ * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245\r
+ */\r
+static double lgamma(double z)\r
+{\r
+       double x = 0;\r
+       x += 0.1659470187408462e-06 / (z+7);\r
+       x += 0.9934937113930748e-05 / (z+6);\r
+       x -= 0.1385710331296526     / (z+5);\r
+       x += 12.50734324009056      / (z+4);\r
+       x -= 176.6150291498386      / (z+3);\r
+       x += 771.3234287757674      / (z+2);\r
+       x -= 1259.139216722289      / (z+1);\r
+       x += 676.5203681218835      / z;\r
+       x += 0.9999999999995183;\r
+       return log(x) - 5.58106146679532777 - z + (z-0.5) * log(z+6.5);\r
+}\r
+#endif\r
+\r
+#ifndef M_LN10\r
+#define        M_LN10   2.30258509299404568402\r
+#endif\r
+#ifndef M_LN2\r
+#define        M_LN2   0.69314718055994530942\r
+#endif\r
+
+#endif\r
index 4390c0918023936c5e8f17016d6f5532ac84b313..7b4497a35676b494d8bf1c600601b2945545b8b9 100644 (file)
@@ -58,6 +58,11 @@ typedef struct {
        int32_t meta_char, line_skip;
 } ti_conf_t;
 
+typedef struct {
+       int beg, end;
+       char *ss, *se;
+} ti_interval_t;
+
 extern ti_conf_t ti_conf_gff, ti_conf_bed, ti_conf_psltbl, ti_conf_vcf, ti_conf_sam; // preset
 
 #ifdef __cplusplus
@@ -120,6 +125,9 @@ extern "C" {
        /* Get the data line pointed by the iterator and iterate to the next record. */
        const char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len);
 
+       const ti_conf_t *ti_get_conf(ti_index_t *idx);
+       int ti_get_intv(const ti_conf_t *conf, int len, char *line, ti_interval_t *intv);
+
        /*******************
         * Deprecated APIs *
         *******************/
index 693db0c6372a12d4299eb20a49cfb54ebba94882..9d6b241aa52e76ef3fbe5110c356de06a1935ff3 100644 (file)
Binary files a/tests/example.gtf.gz and b/tests/example.gtf.gz differ
index eb3f24c6ba9cd8cf5c4551ced2edfd08518ce9e7..4e2b56faf242539d584c8c2c710815451b1d0fef 100644 (file)
Binary files a/tests/example.gtf.gz.tbi and b/tests/example.gtf.gz.tbi differ
index 54445374be2196aa62e5885f3402c8e988824cf3..d2bf4150de58551accb107f1822e85912c7c58d5 100755 (executable)
@@ -135,7 +135,7 @@ class BinaryTest(unittest.TestCase):
                 pysam_method, pysam_options = pysam_command
                 output = pysam_method( *pysam_options.split(" "), raw=True)
                 if ">" in samtools_command:
-                    outfile = open( pysam_target, "w" )
+                    outfile = open( pysam_target, "wb" )
                     for line in output: outfile.write( line )
                     outfile.close()
 
@@ -145,6 +145,7 @@ class BinaryTest(unittest.TestCase):
 
         def _r( s ):
             # patch - remove any of the alpha/beta suffixes, i.e., 0.1.12a -> 0.1.12
+            if s.count('-') > 0: s = s[0:s.find('-')]
             return re.sub( "[^0-9.]", "", s )
 
         if _r(samtools_version) != _r( pysam.__samtools_version__):
@@ -271,7 +272,6 @@ class IOTest(unittest.TestCase):
         self.assertRaises( ValueError, samfile.pileup, 'chr1', 100, 120)
         self.assertRaises( ValueError, samfile.getrname, 0 )
         self.assertRaises( ValueError, samfile.tell )
-        self.assertRaises( ValueError, samfile.write, None )
         self.assertRaises( ValueError, samfile.seek, 0 )
         self.assertRaises( ValueError, getattr, samfile, "nreferences" )
         self.assertRaises( ValueError, getattr, samfile, "references" )
@@ -279,11 +279,17 @@ class IOTest(unittest.TestCase):
         self.assertRaises( ValueError, getattr, samfile, "text" )
         self.assertRaises( ValueError, getattr, samfile, "header" )
 
-    def testBinaryReadFromSamfile( self ):
-        pass
-        # needs to re-activated, see issue 19
-        #samfile = pysam.Samfile( "ex1.bam", "r" )
-        #samfile.fetch().next()
+        # write on closed file 
+        self.assertEqual( 0, samfile.write(None) )
+
+    def testAutoDetection( self ):
+        samfile = pysam.Samfile( "ex3.bam" )
+        samfile.fetch()
+        samfile.close()
+
+        samfile = pysam.Samfile( "ex3.sam")
+        samfile.fetch()
+        samfile.close()
 
     def testReadingFromFileWithoutIndex( self ):
         '''read from bam file without index.'''
@@ -640,12 +646,12 @@ class TestExceptions(unittest.TestCase):
         self.assertRaises( ValueError, self.samfile.count, region="chr1:-5--10" )
 
     def testOutOfRangNewFormat(self):
-        self.assertRaises( OverflowError, self.samfile.fetch, "chr1", 9999999999, 99999999999 )
-        self.assertRaises( OverflowError, self.samfile.count, "chr1", 9999999999, 99999999999 )
+        self.assertRaises( ValueError, self.samfile.fetch, "chr1", 9999999999, 99999999999 )
+        self.assertRaises( ValueError, self.samfile.count, "chr1", 9999999999, 99999999999 )
 
     def testOutOfRangeLargeNewFormat(self):
-        self.assertRaises( OverflowError, self.samfile.fetch, "chr1", 9999999999999999999999999999999, 9999999999999999999999999999999999999999 )
-        self.assertRaises( OverflowError, self.samfile.count, "chr1", 9999999999999999999999999999999, 9999999999999999999999999999999999999999 )
+        self.assertRaises( ValueError, self.samfile.fetch, "chr1", 9999999999999999999999999999999, 9999999999999999999999999999999999999999 )
+        self.assertRaises( ValueError, self.samfile.count, "chr1", 9999999999999999999999999999999, 9999999999999999999999999999999999999999 )
 
     def testOutOfRangeLargeOldFormat(self):
         self.assertRaises( ValueError, self.samfile.fetch, "chr1:99999999999999999-999999999999999999" )
@@ -658,7 +664,6 @@ class TestExceptions(unittest.TestCase):
     def tearDown(self):
         self.samfile.close()
 
-
 class TestWrongFormat(unittest.TestCase):
     '''test cases for opening files not in bam/sam format.'''
 
@@ -1245,7 +1250,7 @@ class TestSamfileUtilityFunctions( unittest.TestCase ):
     def testMate( self ):
         '''test mate access.'''
 
-        readnames = [ x.split("\t")[0] for x in open( "ex1.sam", "r" ).readlines() ]
+        readnames = [ x.split("\t")[0] for x in open( "ex1.sam", "rb" ).readlines() ]
         counts = collections.defaultdict( int )
         for x in readnames: counts[x] += 1
 
@@ -1279,6 +1284,23 @@ class TestSamtoolsProxy( unittest.TestCase ):
     def testSort( self ):
         self.assertRaises( pysam.SamtoolsError, pysam.sort, "missing_file" )
 
+class TestSamfileIndex( unittest.TestCase):
+    
+    def testIndex( self ):
+        samfile = pysam.Samfile( "ex1.bam", "rb" )
+        index = pysam.IndexedReads( samfile )
+        index.build()
+
+        reads = collections.defaultdict( int )
+
+        for read in samfile: reads[read.qname] += 1
+            
+        for qname, counts in reads.iteritems():
+            found = list(index.find( qname ))
+            self.assertEqual( len(found), counts )
+            for x in found: self.assertEqual( x.qname, qname )
+            
+
 if __name__ == "__main__":
     # build data files
     print "building data files"
index 8eb8a60a618d4865c07d5c853c7f2e37226e8cd6..207a59c6c125360655ac77192f43640903fc1c1d 100644 (file)
@@ -85,7 +85,7 @@ class TestIteration( unittest.TestCase ):
     def setUp( self ):
 
         self.tabix = pysam.Tabixfile( self.filename )
-        lines = gzip.open(self.filename).readlines()
+        lines = [ x for x in gzip.open(self.filename).readlines() if not x.startswith("#") ]
         # creates index of contig, start, end, adds content without newline.
         self.compare = [ 
             (x[0][0], int(x[0][3]), int(x[0][4]), x[1]) 
@@ -196,6 +196,14 @@ class TestIteration( unittest.TestCase ):
         # check that contigs is read-only
         self.assertRaises( AttributeError, setattr, self.tabix, "contigs", ["chr1", "chr2"] )
 
+    def testHeader( self ):
+        ref = []
+        for x in gzip.open( self.filename ):
+            if not x.startswith("#"): break
+            ref.append( x[:-1] )
+        header = list( self.tabix.header )
+        self.assertEqual( ref, header )
+
 class TestParser( unittest.TestCase ):
 
     filename = "example.gtf.gz" 
@@ -203,23 +211,140 @@ class TestParser( unittest.TestCase ):
     def setUp( self ):
 
         self.tabix = pysam.Tabixfile( self.filename )
-        self.compare = [ x[:-1].split("\t") for x in gzip.open( self.filename, "r") ]
-
-    def testGTF( self ):
-
-        for x, r in enumerate(self.tabix.fetch( parser = pysam.asGTF() )):
-            self.assertEqual( "\t".join( self.compare[x]), str(r) )
+        self.compare = [ x[:-1].split("\t") for x in gzip.open( self.filename, "r") if not x.startswith("#") ]
 
-    def testTuple( self ):
+    def testRead( self ):
 
         for x, r in enumerate(self.tabix.fetch( parser = pysam.asTuple() )):
             self.assertEqual( self.compare[x], list(r) )
-
             self.assertEqual( len(self.compare[x]), len(r) )
+
             for c in range(0,len(r)):
                 self.assertEqual( self.compare[x][c], r[c] )
 
+    def testWrite( self ):
+        
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asTuple() )):
+            self.assertEqual( self.compare[x], list(r) )
+            c = list(r)
+            for y in range(len(r)):
+                r[y] = "test_%05i" % y
+                c[y] = "test_%05i" % y
+            self.assertEqual( c, list(r) )
+            self.assertEqual( "\t".join( c ), str(r) )
+            # check second assignment
+            for y in range(len(r)):
+                r[y] = "test_%05i" % y
+            self.assertEqual( c, list(r) )
+            self.assertEqual( "\t".join( c ), str(r) )
+
+    def testUnset( self ):
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asTuple() )):
+            self.assertEqual( self.compare[x], list(r) )
+            c = list(r)
+            e = list(r)
+            for y in range(len(r)):
+                r[y] = c[y] = None
+                e[y] = ""
+                self.assertEqual( c, list(r) )
+                self.assertEqual( "\t".join(e), str(r) )
+
+class TestGTF( TestParser ):
+    def testRead( self ):
+
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asGTF() )):
+            self.assertEqual( "\t".join( self.compare[x]), str(r) )
+
+class TestBed( unittest.TestCase ):
+    filename = "example.bed.gz"
+
+    def setUp( self ):
+
+        self.tabix = pysam.Tabixfile( self.filename )
+        self.compare = [ x[:-1].split("\t") for x in gzip.open( self.filename, "r") if not x.startswith("#") ]
+
+    def testRead( self ):
+
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asBed() )):
+            c = self.compare[x]
+            self.assertEqual( "\t".join( c ), str(r) )
+            self.assertEqual( list(c), list(r) )
+            self.assertEqual( c[0], r.contig)
+            self.assertEqual( int(c[1]), r.start)
+            self.assertEqual( int(c[2]), r.end)
+
+    def testWrite( self ):
+
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asBed() )):
+            c = self.compare[x]
+            self.assertEqual( "\t".join( c ), str(r) )
+            self.assertEqual( list(c), list(r) )
+
+            r.contig = "test"
+            self.assertEqual( "test", r.contig)
+            self.assertEqual( "test", r[0])
+
+            r.start += 1
+            self.assertEqual( int(c[1]) + 1, r.start )
+            self.assertEqual( str(int(c[1]) + 1), r[1] )
+
+            r.end += 1
+            self.assertEqual( int(c[2]) + 1, r.end )
+            self.assertEqual( str(int(c[2]) + 1), r[2] )
+
+class TestVCF( TestParser ):
+
+    filename = "example.vcf40.gz"
+    columns = ("contig", "pos", "id", 
+               "ref", "alt", "qual", 
+               "filter", "info", "format" )
+
+    def testRead( self ):
+        
+        ncolumns = len(self.columns) 
+
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asVCF() )):
+            c = self.compare[x]
+            for y, field in enumerate( self.columns ):
+                if field == "pos":
+                    self.assertEqual( int(c[y])-1, getattr( r, field ) )
+                    self.assertEqual( int(c[y])-1, r.pos )
+                else:
+                    self.assertEqual( c[y], getattr( r, field ), 
+                                      "mismatch in field %s: %s != %s" %\
+                                          ( field,c[y], getattr( r, field ) ) )
+            self.assertEqual( len(c), len( r ) + ncolumns )
+            
+            for y in range(len(c) - ncolumns):
+                self.assertEqual( c[ncolumns+y], r[y] )
+                
+    def testWrite( self ):
+
+        ncolumns = len(self.columns) 
+
+        for x, r in enumerate(self.tabix.fetch( parser = pysam.asVCF() )):
+            c = self.compare[x]
+            for y, field in enumerate( self.columns ):
+                if field == "pos":
+                    r.pos += 1
+                    self.assertEqual( int(c[y]), getattr( r, field ) )
+                    self.assertEqual( int(c[y]), r.pos )
+                else:
+                    setattr( r, field, "test_%i" % y)
+                    c[y] = "test_%i" % y
+                    self.assertEqual( c[y], getattr( r, field ), 
+                                      "mismatch in field %s: %s != %s" %\
+                                          ( field,c[y], getattr( r, field ) ) )
+
+            self.assertEqual( len(c), len( r ) + ncolumns )
+            
+            for y in range(len(c) - ncolumns):
+                c[ncolumns+y] = "test_%i" % y
+                r[y] = "test_%i" % y
+                self.assertEqual( c[ncolumns+y], r[y] )
+                
 if __name__ == "__main__":
+
     unittest.main()