From d02fe5283ed7a93a2f76a5d6dc6e37b40c11b9b1 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 21 Jul 2011 14:16:36 -0700 Subject: [PATCH] Imported Upstream version 0.5 --- MANIFEST.in | 15 + PKG-INFO | 5 +- ez_setup.py | 284 + pysam.egg-info/PKG-INFO | 16 + pysam.egg-info/SOURCES.txt | 146 + pysam.egg-info/dependency_links.txt | 1 + pysam.egg-info/not-zip-safe | 1 + pysam.egg-info/requires.txt | 1 + pysam.egg-info/top_level.txt | 8 + pysam/Pileup.py | 223 +- pysam/TabProxies.c | 9919 ++++ pysam/TabProxies.pxd | 97 + pysam/TabProxies.pyx | 617 + pysam/VCF.py | 1088 + pysam/__init__.py | 20 +- pysam/csamtools.c | 39457 ++++++++++++++++ pysam/csamtools.pxd | 148 +- pysam/csamtools.pyx | 2117 +- pysam/ctabix.c | 9005 ++++ pysam/ctabix.pxd | 24 +- pysam/ctabix.pyx | 569 +- pysam/cvcf.c | 26340 +++++++++++ pysam/cvcf.pxd | 41 + pysam/cvcf.pyx | 1121 + pysam/pysam_util.c | 108 +- pysam/pysam_util.h | 17 + pysam/tabix_util.c | 4 + pysam/version.py | 6 +- samtools/{bam.c => bam.c.pysam.c} | 66 +- samtools/bam.h | 46 +- samtools/bam2bcf.c.pysam.c | 262 + samtools/bam2bcf.h | 55 + samtools/bam2bcf_indel.c.pysam.c | 471 + samtools/bam2depth.c.pysam.c | 114 + samtools/{bam_aux.c => bam_aux.c.pysam.c} | 25 +- samtools/bam_cat.c.pysam.c | 186 + samtools/{bam_color.c => bam_color.c.pysam.c} | 2 + .../{bam_import.c => bam_import.c.pysam.c} | 43 +- samtools/{bam_index.c => bam_index.c.pysam.c} | 77 +- .../{bam_lpileup.c => bam_lpileup.c.pysam.c} | 12 +- .../{bam_maqcns.c => bam_maqcns.c.pysam.c} | 104 +- samtools/bam_maqcns.h | 6 +- samtools/{bam_mate.c => bam_mate.c.pysam.c} | 4 +- samtools/bam_md.c | 175 - samtools/bam_md.c.pysam.c | 359 + .../{bam_pileup.c => bam_pileup.c.pysam.c} | 167 +- samtools/bam_plcmd.c | 570 - samtools/bam_plcmd.c.pysam.c | 982 + samtools/bam_reheader.c | 60 - samtools/{bam_rmdup.c => bam_rmdup.c.pysam.c} | 20 +- .../{bam_rmdupse.c => bam_rmdupse.c.pysam.c} | 4 +- samtools/{bam_sort.c => bam_sort.c.pysam.c} | 225 +- samtools/bam_stat.c | 78 - samtools/bam_stat.c.pysam.c | 79 + samtools/{bam_tview.c => bam_tview.c.pysam.c} | 14 +- samtools/bcftools/bcf.c.pysam.c | 330 + samtools/bcftools/bcf.h | 184 + samtools/bcftools/bcf2qcall.c.pysam.c | 93 + samtools/bcftools/bcfutils.c.pysam.c | 312 + samtools/bcftools/call1.c.pysam.c | 529 + samtools/bcftools/em.c.pysam.c | 308 + samtools/bcftools/fet.c.pysam.c | 114 + samtools/bcftools/index.c.pysam.c | 337 + samtools/bcftools/kfunc.c.pysam.c | 164 + samtools/bcftools/kmin.c.pysam.c | 211 + samtools/bcftools/kmin.h | 46 + samtools/bcftools/prob1.c.pysam.c | 538 + samtools/bcftools/prob1.h | 41 + samtools/bcftools/vcf.c.pysam.c | 246 + samtools/bedidx.c.pysam.c | 158 + samtools/{bgzf.c => bgzf.c.pysam.c} | 83 +- samtools/bgzf.h | 4 +- samtools/cut_target.c.pysam.c | 195 + samtools/errmod.c.pysam.c | 132 + samtools/errmod.h | 24 + samtools/{faidx.c => faidx.c.pysam.c} | 29 +- samtools/{glf.c => glf.c.pysam.c} | 10 +- samtools/{kaln.c => kaln.c.pysam.c} | 146 +- samtools/kaln.h | 20 +- samtools/khash.h | 98 +- samtools/{knetfile.c => knetfile.c.pysam.c} | 40 +- samtools/kprobaln.c.pysam.c | 280 + samtools/kprobaln.h | 49 + samtools/ksort.h | 10 + samtools/{kstring.c => kstring.c.pysam.c} | 99 +- samtools/kstring.h | 33 +- samtools/misc/md5.c.pysam.c | 298 + samtools/misc/md5.h | 57 + samtools/msvc_compat.h | 60 + samtools/phase.c.pysam.c | 689 + samtools/pysam.h | 5 + samtools/{razf.c => razf.c.pysam.c} | 16 +- samtools/{sam.c => sam.c.pysam.c} | 40 +- .../{sam_header.c => sam_header.c.pysam.c} | 13 +- samtools/{sam_view.c => sam_view.c.pysam.c} | 178 +- samtools/sample.c.pysam.c | 95 + samtools/sample.h | 17 + samtools/win32/xcurses.h | 1377 + samtools/win32/zconf.h | 332 + samtools/win32/zlib.h | 1357 + setup.cfg | 6 + setup.py | 155 +- tabix/bedidx.c.pysam.c | 158 + tabix/{bgzf.c => bgzf.c.pysam.c} | 146 +- tabix/bgzf.h | 7 +- tabix/{bgzip.c => bgzip.c.pysam.c} | 57 +- tabix/{index.c => index.c.pysam.c} | 134 +- tabix/{knetfile.c => knetfile.c.pysam.c} | 26 +- tabix/kseq.h | 227 + tabix/{kstring.c => kstring.c.pysam.c} | 2 + tabix/msvc_compat.h | 60 + tabix/pysam.h | 5 + tabix/tabix.h | 8 + tests/Makefile | 15 +- tests/ex10.sam | 19 + tests/ex9_fail.bam | Bin 0 -> 10280 bytes tests/ex9_nofail.bam | Bin 0 -> 10270 bytes tests/example.gtf.gz | Bin 3778 -> 3825 bytes tests/example.gtf.gz.tbi | Bin 260 -> 260 bytes tests/pysam_test.py | 367 +- tests/tabix_test.py | 143 +- 121 files changed, 104096 insertions(+), 2440 deletions(-) create mode 100644 ez_setup.py create mode 100644 pysam.egg-info/PKG-INFO create mode 100644 pysam.egg-info/SOURCES.txt create mode 100644 pysam.egg-info/dependency_links.txt create mode 100644 pysam.egg-info/not-zip-safe create mode 100644 pysam.egg-info/requires.txt create mode 100644 pysam.egg-info/top_level.txt create mode 100644 pysam/TabProxies.c create mode 100644 pysam/TabProxies.pxd create mode 100644 pysam/TabProxies.pyx create mode 100644 pysam/VCF.py create mode 100644 pysam/csamtools.c create mode 100644 pysam/ctabix.c create mode 100644 pysam/cvcf.c create mode 100644 pysam/cvcf.pxd create mode 100644 pysam/cvcf.pyx create mode 100644 pysam/tabix_util.c rename samtools/{bam.c => bam.c.pysam.c} (82%) create mode 100644 samtools/bam2bcf.c.pysam.c create mode 100644 samtools/bam2bcf.h create mode 100644 samtools/bam2bcf_indel.c.pysam.c create mode 100644 samtools/bam2depth.c.pysam.c rename samtools/{bam_aux.c => bam_aux.c.pysam.c} (90%) create mode 100644 samtools/bam_cat.c.pysam.c rename samtools/{bam_color.c => bam_color.c.pysam.c} (99%) rename samtools/{bam_import.c => bam_import.c.pysam.c} (84%) rename samtools/{bam_index.c => bam_index.c.pysam.c} (89%) rename samtools/{bam_lpileup.c => bam_lpileup.c.pysam.c} (95%) rename samtools/{bam_maqcns.c => bam_maqcns.c.pysam.c} (87%) rename samtools/{bam_mate.c => bam_mate.c.pysam.c} (96%) delete mode 100644 samtools/bam_md.c create mode 100644 samtools/bam_md.c.pysam.c rename samtools/{bam_pileup.c => bam_pileup.c.pysam.c} (65%) delete mode 100644 samtools/bam_plcmd.c create mode 100644 samtools/bam_plcmd.c.pysam.c delete mode 100644 samtools/bam_reheader.c rename samtools/{bam_rmdup.c => bam_rmdup.c.pysam.c} (86%) rename samtools/{bam_rmdupse.c => bam_rmdupse.c.pysam.c} (96%) rename samtools/{bam_sort.c => bam_sort.c.pysam.c} (52%) delete mode 100644 samtools/bam_stat.c create mode 100644 samtools/bam_stat.c.pysam.c rename samtools/{bam_tview.c => bam_tview.c.pysam.c} (97%) create mode 100644 samtools/bcftools/bcf.c.pysam.c create mode 100644 samtools/bcftools/bcf.h create mode 100644 samtools/bcftools/bcf2qcall.c.pysam.c create mode 100644 samtools/bcftools/bcfutils.c.pysam.c create mode 100644 samtools/bcftools/call1.c.pysam.c create mode 100644 samtools/bcftools/em.c.pysam.c create mode 100644 samtools/bcftools/fet.c.pysam.c create mode 100644 samtools/bcftools/index.c.pysam.c create mode 100644 samtools/bcftools/kfunc.c.pysam.c create mode 100644 samtools/bcftools/kmin.c.pysam.c create mode 100644 samtools/bcftools/kmin.h create mode 100644 samtools/bcftools/prob1.c.pysam.c create mode 100644 samtools/bcftools/prob1.h create mode 100644 samtools/bcftools/vcf.c.pysam.c create mode 100644 samtools/bedidx.c.pysam.c rename samtools/{bgzf.c => bgzf.c.pysam.c} (89%) create mode 100644 samtools/cut_target.c.pysam.c create mode 100644 samtools/errmod.c.pysam.c create mode 100644 samtools/errmod.h rename samtools/{faidx.c => faidx.c.pysam.c} (89%) rename samtools/{glf.c => glf.c.pysam.c} (95%) rename samtools/{kaln.c => kaln.c.pysam.c} (70%) rename samtools/{knetfile.c => knetfile.c.pysam.c} (94%) create mode 100644 samtools/kprobaln.c.pysam.c create mode 100644 samtools/kprobaln.h rename samtools/{kstring.c => kstring.c.pysam.c} (61%) create mode 100644 samtools/misc/md5.c.pysam.c create mode 100644 samtools/misc/md5.h create mode 100644 samtools/msvc_compat.h create mode 100644 samtools/phase.c.pysam.c create mode 100644 samtools/pysam.h rename samtools/{razf.c => razf.c.pysam.c} (97%) rename samtools/{sam.c => sam.c.pysam.c} (78%) rename samtools/{sam_header.c => sam_header.c.pysam.c} (98%) rename samtools/{sam_view.c => sam_view.c.pysam.c} (54%) create mode 100644 samtools/sample.c.pysam.c create mode 100644 samtools/sample.h create mode 100644 samtools/win32/xcurses.h create mode 100644 samtools/win32/zconf.h create mode 100644 samtools/win32/zlib.h create mode 100644 tabix/bedidx.c.pysam.c rename tabix/{bgzf.c => bgzf.c.pysam.c} (83%) rename tabix/{bgzip.c => bgzip.c.pysam.c} (72%) rename tabix/{index.c => index.c.pysam.c} (85%) rename tabix/{knetfile.c => knetfile.c.pysam.c} (95%) create mode 100644 tabix/kseq.h rename tabix/{kstring.c => kstring.c.pysam.c} (99%) create mode 100644 tabix/msvc_compat.h create mode 100644 tabix/pysam.h create mode 100644 tests/ex10.sam create mode 100644 tests/ex9_fail.bam create mode 100644 tests/ex9_nofail.bam diff --git a/MANIFEST.in b/MANIFEST.in index ac9e5c8..efb1d3e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,10 +8,22 @@ include COPYING include INSTALL include KNOWN_BUGS include THANKS +include ez_setup.py include pysam/csamtools.pxd +include pysam/csamtools.pyx +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 include tabix/*.h # pysam tests @@ -25,6 +37,9 @@ include tests/ex5.sam include tests/ex6.sam include tests/ex7.sam include tests/ex8.sam +include tests/ex9_fail.bam +include tests/ex9_nofail.bam +include tests/ex10.sam include tests/example.py include tests/pysam_test.py include tests/segfault_tests.py diff --git a/PKG-INFO b/PKG-INFO index 8c788c7..c90139f 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: pysam -Version: 0.3.1 +Version: 0.5 Summary: pysam Home-page: http://code.google.com/p/pysam/ Author: Andreas Heger @@ -13,3 +13,4 @@ Description: Platform: ALL +Requires: cython (>=0.12) diff --git a/ez_setup.py b/ez_setup.py new file mode 100644 index 0000000..1ff1d3e --- /dev/null +++ b/ez_setup.py @@ -0,0 +1,284 @@ +#!python +"""Bootstrap setuptools installation + +If you want to use setuptools in your package's setup.py, just include this +file in the same directory with it, and add this to the top of your setup.py:: + + from ez_setup import use_setuptools + use_setuptools() + +If you want to require a specific version of setuptools, set a download +mirror, or use an alternate download directory, you can do so by supplying +the appropriate options to ``use_setuptools()``. + +This file can also be run as a script to install or upgrade setuptools. +""" +import sys +DEFAULT_VERSION = "0.6c11" +DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] + +md5_data = { + 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', + 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', + 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', + 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', + 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', + 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', + 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', + 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', + 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', + 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', + 'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090', + 'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4', + 'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7', + 'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5', + 'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de', + 'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b', + 'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2', + 'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086', + 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', + 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', + 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', + 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', + 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', + 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', + 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', + 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', + 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', + 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', + 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', + 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20', + 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab', + 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53', + 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2', + 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', + 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', + 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', + 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', + 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', + 'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03', + 'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a', + 'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6', + 'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a', +} + +import sys, os +try: from hashlib import md5 +except ImportError: from md5 import md5 + +def _validate_md5(egg_name, data): + if egg_name in md5_data: + digest = md5(data).hexdigest() + if digest != md5_data[egg_name]: + print >>sys.stderr, ( + "md5 validation of %s failed! (Possible download problem?)" + % egg_name + ) + sys.exit(2) + return data + +def use_setuptools( + version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, + download_delay=15 +): + """Automatically find/download setuptools and make it available on sys.path + + `version` should be a valid setuptools version number that is available + as an egg for download under the `download_base` URL (which should end with + a '/'). `to_dir` is the directory where setuptools will be downloaded, if + it is not already available. If `download_delay` is specified, it should + be the number of seconds that will be paused before initiating a download, + should one be required. If an older version of setuptools is installed, + this routine will print a message to ``sys.stderr`` and raise SystemExit in + an attempt to abort the calling script. + """ + was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules + def do_download(): + egg = download_setuptools(version, download_base, to_dir, download_delay) + sys.path.insert(0, egg) + import setuptools; setuptools.bootstrap_install_from = egg + try: + import pkg_resources + except ImportError: + return do_download() + try: + pkg_resources.require("setuptools>="+version); return + except pkg_resources.VersionConflict, e: + if was_imported: + print >>sys.stderr, ( + "The required version of setuptools (>=%s) is not available, and\n" + "can't be installed while this script is running. Please install\n" + " a more recent version first, using 'easy_install -U setuptools'." + "\n\n(Currently using %r)" + ) % (version, e.args[0]) + sys.exit(2) + else: + del pkg_resources, sys.modules['pkg_resources'] # reload ok + return do_download() + except pkg_resources.DistributionNotFound: + return do_download() + +def download_setuptools( + version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, + delay = 15 +): + """Download setuptools from a specified location and return its filename + + `version` should be a valid setuptools version number that is available + as an egg for download under the `download_base` URL (which should end + with a '/'). `to_dir` is the directory where the egg will be downloaded. + `delay` is the number of seconds to pause before an actual download attempt. + """ + import urllib2, shutil + egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) + url = download_base + egg_name + saveto = os.path.join(to_dir, egg_name) + src = dst = None + if not os.path.exists(saveto): # Avoid repeated downloads + try: + from distutils import log + if delay: + log.warn(""" +--------------------------------------------------------------------------- +This script requires setuptools version %s to run (even to display +help). I will attempt to download it for you (from +%s), but +you may need to enable firewall access for this script first. +I will start the download in %d seconds. + +(Note: if this machine does not have network access, please obtain the file + + %s + +and place it in this directory before rerunning this script.) +---------------------------------------------------------------------------""", + version, download_base, delay, url + ); from time import sleep; sleep(delay) + log.warn("Downloading %s", url) + src = urllib2.urlopen(url) + # Read/write all in one block, so we don't create a corrupt file + # if the download is interrupted. + data = _validate_md5(egg_name, src.read()) + dst = open(saveto,"wb"); dst.write(data) + finally: + if src: src.close() + if dst: dst.close() + return os.path.realpath(saveto) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +def main(argv, version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + try: + import setuptools + except ImportError: + egg = None + try: + egg = download_setuptools(version, delay=0) + sys.path.insert(0,egg) + from setuptools.command.easy_install import main + return main(list(argv)+[egg]) # we're done here + finally: + if egg and os.path.exists(egg): + os.unlink(egg) + else: + if setuptools.__version__ == '0.0.1': + print >>sys.stderr, ( + "You have an obsolete version of setuptools installed. Please\n" + "remove it from your system entirely before rerunning this script." + ) + sys.exit(2) + + req = "setuptools>="+version + import pkg_resources + try: + pkg_resources.require(req) + except pkg_resources.VersionConflict: + try: + from setuptools.command.easy_install import main + except ImportError: + from easy_install import main + main(list(argv)+[download_setuptools(delay=0)]) + sys.exit(0) # try to force an exit + else: + if argv: + from setuptools.command.easy_install import main + main(argv) + else: + print "Setuptools version",version,"or greater has been installed." + print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' + +def update_md5(filenames): + """Update our built-in md5 registry""" + + import re + + for name in filenames: + base = os.path.basename(name) + f = open(name,'rb') + md5_data[base] = md5(f.read()).hexdigest() + f.close() + + data = [" %r: %r,\n" % it for it in md5_data.items()] + data.sort() + repl = "".join(data) + + import inspect + srcfile = inspect.getsourcefile(sys.modules[__name__]) + f = open(srcfile, 'rb'); src = f.read(); f.close() + + match = re.search("\nmd5_data = {\n([^}]+)}", src) + if not match: + print >>sys.stderr, "Internal error!" + sys.exit(2) + + src = src[:match.start(1)] + repl + src[match.end(1):] + f = open(srcfile,'w') + f.write(src) + f.close() + + +if __name__=='__main__': + if len(sys.argv)>2 and sys.argv[1]=='--md5update': + update_md5(sys.argv[2:]) + else: + main(sys.argv[1:]) + + + + + + diff --git a/pysam.egg-info/PKG-INFO b/pysam.egg-info/PKG-INFO new file mode 100644 index 0000000..c90139f --- /dev/null +++ b/pysam.egg-info/PKG-INFO @@ -0,0 +1,16 @@ +Metadata-Version: 1.1 +Name: pysam +Version: 0.5 +Summary: pysam +Home-page: http://code.google.com/p/pysam/ +Author: Andreas Heger +Author-email: andreas.heger@gmail.com +License: MIT +Description: + + pysam + ***** + + +Platform: ALL +Requires: cython (>=0.12) diff --git a/pysam.egg-info/SOURCES.txt b/pysam.egg-info/SOURCES.txt new file mode 100644 index 0000000..6f8ca43 --- /dev/null +++ b/pysam.egg-info/SOURCES.txt @@ -0,0 +1,146 @@ +COPYING +INSTALL +KNOWN_BUGS +MANIFEST.in +THANKS +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 +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 +pysam/tabix_util.c +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 +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 +samtools/bam_index.c.pysam.c +samtools/bam_lpileup.c.pysam.c +samtools/bam_maqcns.c.pysam.c +samtools/bam_maqcns.h +samtools/bam_mate.c.pysam.c +samtools/bam_md.c.pysam.c +samtools/bam_pileup.c.pysam.c +samtools/bam_plcmd.c.pysam.c +samtools/bam_rmdup.c.pysam.c +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 +samtools/faidx.h +samtools/glf.c.pysam.c +samtools/glf.h +samtools/kaln.c.pysam.c +samtools/kaln.h +samtools/khash.h +samtools/klist.h +samtools/knetfile.c.pysam.c +samtools/knetfile.h +samtools/kprobaln.c.pysam.c +samtools/kprobaln.h +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 +samtools/sam.c.pysam.c +samtools/sam.h +samtools/sam_header.c.pysam.c +samtools/sam_header.h +samtools/sam_view.c.pysam.c +samtools/sample.c.pysam.c +samtools/sample.h +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 +samtools/bcftools/fet.c.pysam.c +samtools/bcftools/index.c.pysam.c +samtools/bcftools/kfunc.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 +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 +tests/Makefile +tests/ex1.fa +tests/ex1.sam.gz +tests/ex10.sam +tests/ex3.sam +tests/ex4.sam +tests/ex5.sam +tests/ex6.sam +tests/ex7.sam +tests/ex8.sam +tests/ex9_fail.bam +tests/ex9_nofail.bam +tests/example.gtf.gz +tests/example.gtf.gz.tbi +tests/example.py +tests/pysam_test.py +tests/segfault_tests.py +tests/tabix_test.py \ No newline at end of file diff --git a/pysam.egg-info/dependency_links.txt b/pysam.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pysam.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/pysam.egg-info/not-zip-safe b/pysam.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pysam.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/pysam.egg-info/requires.txt b/pysam.egg-info/requires.txt new file mode 100644 index 0000000..98f0172 --- /dev/null +++ b/pysam.egg-info/requires.txt @@ -0,0 +1 @@ +cython>=0.12.1 \ No newline at end of file diff --git a/pysam.egg-info/top_level.txt b/pysam.egg-info/top_level.txt new file mode 100644 index 0000000..a57e36c --- /dev/null +++ b/pysam.egg-info/top_level.txt @@ -0,0 +1,8 @@ +pysam/namedtuple +ctabix +pysam/Pileup +csamtools +cvcf +TabProxies +pysam/version +pysam/__init__ diff --git a/pysam/Pileup.py b/pysam/Pileup.py index e182d12..998127b 100644 --- a/pysam/Pileup.py +++ b/pysam/Pileup.py @@ -5,12 +5,12 @@ import pysam PileupSubstitution = collections.namedtuple( "PileupSubstitution", " ".join( (\ "chromosome", - "position", + "pos", "reference_base", - "consensus_base", + "genotype", "consensus_quality", "snp_quality", - "rms_mapping_quality", + "mapping_quality", "coverage", "read_bases", "base_qualities" ) ) ) @@ -18,14 +18,14 @@ PileupSubstitution = collections.namedtuple( "PileupSubstitution", PileupIndel = collections.namedtuple( "PileupIndel", " ".join( (\ "chromosome", - "position", + "pos", "reference_base", "genotype", "consensus_quality", "snp_quality", - "rms_mapping_quality", + "mapping_quality", "coverage", - "first_allelle", + "first_allele", "second_allele", "reads_first", "reads_second", @@ -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 index 0000000..dc9e21c --- /dev/null +++ b/pysam/TabProxies.c @@ -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 /* 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 +#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 = 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 = 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 = 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 = malloc( s ) + * if self.data == NULL: + * raise ValueError("out of memory" ) # <<<<<<<<<<<<<< + * self.nbytes = nbytes + * memcpy( 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( 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( 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( 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 = 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 = 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 = 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 = 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 = memchr( pos, '\t', nbytes ) + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/TabProxies.pyx":130 + * while 1: + * + * pos = 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 = 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 = 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] = 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] = 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] = 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] = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 , */ + 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 index 0000000..32597af --- /dev/null +++ b/pysam/TabProxies.pxd @@ -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 index 0000000..36295eb --- /dev/null +++ b/pysam/TabProxies.pyx @@ -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 = malloc( s ) + if self.data == NULL: + raise ValueError("out of memory" ) + self.nbytes = nbytes + memcpy( 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 = 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 = 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] = 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 = 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 = 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 = 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 index 0000000..115aa2b --- /dev/null +++ b/pysam/VCF.py @@ -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'] = '' + 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 and D + 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 and D + 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 + + + + diff --git a/pysam/__init__.py b/pysam/__init__.py index 282ef29..ec0439f 100644 --- a/pysam/__init__.py +++ b/pysam/__init__.py @@ -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 @@ -42,8 +44,8 @@ class SamtoolsDispatcher(object): self.parsers = parsers self.stderr = [] - def __call__(self,*args, **kwargs): - '''execute the samtools command + def __call__(self, *args, **kwargs): + '''execute a samtools command ''' retval, stderr, stdout = csamtools._samtools_dispatch( self.dispatch, args ) if retval: raise SamtoolsError( "\n".join( stderr ) ) @@ -54,10 +56,10 @@ class SamtoolsDispatcher(object): # for example: [sam_header_read2] 2 sequences loaded. # Ignore messages like these stderr = [ x for x in stderr \ - if not x.startswith( "[sam_header_read2]" ) or \ - x.startswith("[bam_index_load]") or \ - x.startswith("[bam_sort_core]") or \ - x.startswith("[samopen] SAM header is present") + if not (x.startswith( "[sam_header_read2]" ) or \ + x.startswith("[bam_index_load]") or \ + x.startswith("[bam_sort_core]") or \ + x.startswith("[samopen] SAM header is present") ) ] if stderr: raise SamtoolsError( "\n".join( stderr ) ) @@ -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__ diff --git a/pysam/csamtools.c b/pysam/csamtools.c new file mode 100644 index 0000000..6e18ed6 --- /dev/null +++ b/pysam/csamtools.c @@ -0,0 +1,39457 @@ +/* Generated by Cython 0.13 on Tue Jun 7 17:24:36 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 /* 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 +#define __PYX_HAVE_API__csamtools +#include "string.h" +#include "stdlib.h" +#include "math.h" +#include "stdio.h" +#include "ctype.h" +#include "unistd.h" +#include "fileobject.h" +#include "razf.h" +#include "stdint.h" +#include "bam.h" +#include "sam.h" +#include "glf.h" +#include "bam_maqcns.h" +#include "faidx.h" +#include "pysam_util.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[] = { + "csamtools.pyx", + "csamtools.pxd", + "bool.pxd", +}; + +/* Type declarations */ + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":388 + * counter[0] += 1; + * + * ctypedef struct MateData: # <<<<<<<<<<<<<< + * char * name + * bam1_t * mate + */ + +typedef struct { + char *name; + bam1_t *mate; + uint32_t flag; +} __pyx_t_9csamtools_MateData; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1478 + * ##------------------------------------------------------------------- + * ##------------------------------------------------------------------- + * ctypedef struct __iterdata: # <<<<<<<<<<<<<< + * samfile_t * samfile + * bam_iter_t iter + */ + +typedef struct { + samfile_t *samfile; + bam_iter_t iter; + faidx_t *fastafile; + int tid; + char *seq; + int seq_len; +} __pyx_t_9csamtools___iterdata; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655 + * bam_plp_set_mask( self.pileup_iter, self.mask ) + * + * cdef setupIteratorData( self, # <<<<<<<<<<<<<< + * int tid, + * int start, + */ + +struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData { + int __pyx_n; + int reopen; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3192 + * bam_maqindel_ret_destroy(self._r) + * + * cdef class IndelCallerBase: # <<<<<<<<<<<<<< + * '''Base class for SNP callers. + * + */ + +struct __pyx_obj_9csamtools_IndelCallerBase { + PyObject_HEAD + bam_maqindel_opt_t *options; + struct __pyx_obj_9csamtools_IteratorColumn *iter; + int cap_mapQ; + int max_depth; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3330 + * return self._call() + * + * cdef class IteratorIndelCalls( IndelCallerBase ): # <<<<<<<<<<<<<< + * """*(IteratorColumn iterator)* + * + */ + +struct __pyx_obj_9csamtools_IteratorIndelCalls { + struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244 + * ## Public methods + * ###################################################################### + * cdef class Fastafile: # <<<<<<<<<<<<<< + * '''*(filename)* + * + */ + +struct __pyx_obj_9csamtools_Fastafile { + PyObject_HEAD + struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtab; + char *_filename; + faidx_t *fastafile; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3103 + * return call + * + * cdef class IndelCall: # <<<<<<<<<<<<<< + * '''the results of an indel call.''' + * cdef int _tid + */ + +struct __pyx_obj_9csamtools_IndelCall { + PyObject_HEAD + int _tid; + int _pos; + int _coverage; + int _rms_mapping_quality; + bam_maqindel_ret_t *_r; +}; + +/* "pysam/csamtools.pxd":388 + * cdef bam1_t * _delegate + * + * cdef class Samfile: # <<<<<<<<<<<<<< + * cdef char * _filename + * # pointer to samfile + */ + +struct __pyx_obj_9csamtools_Samfile { + 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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3287 + * return call + * + * cdef class IndelCaller( IndelCallerBase ): # <<<<<<<<<<<<<< + * '''*(IteratorColumn iterator_column )* + * + */ + +struct __pyx_obj_9csamtools_IndelCaller { + struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":91 + * 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; +}; + +/* "/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_SNPCall { + PyObject_HEAD + int _tid; + int _pos; + char _reference_base; + char _genotype; + int _consensus_quality; + int _snp_quality; + int _rms_mapping_quality; + int _coverage; +}; + +/* "pysam/csamtools.pxd":383 + * + * # need to declare all C fields and methods here + * cdef class AlignedRead: # <<<<<<<<<<<<<< + * + * # object that this AlignedRead represents + */ + +struct __pyx_obj_9csamtools_AlignedRead { + PyObject_HEAD + bam1_t *_delegate; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542 + * return ret + * + * cdef class IteratorColumn: # <<<<<<<<<<<<<< + * '''abstract base class for iterators over columns. + * + */ + +struct __pyx_obj_9csamtools_IteratorColumn { + PyObject_HEAD + struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtab; + struct __pyx_obj_9csamtools_IteratorRowRegion *iter; + int tid; + int pos; + int n_plp; + int mask; + const bam_pileup1_t * plp; + bam_plp_t pileup_iter; + __pyx_t_9csamtools___iterdata iterdata; + struct __pyx_obj_9csamtools_Samfile *samfile; + struct __pyx_obj_9csamtools_Fastafile *fastafile; + PyObject *stepper; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712 + * self.iterdata.seq = NULL + * + * cdef class IteratorColumnRegion(IteratorColumn): # <<<<<<<<<<<<<< + * '''iterates over a region only. + * ''' + */ + +struct __pyx_obj_9csamtools_IteratorColumnRegion { + struct __pyx_obj_9csamtools_IteratorColumn __pyx_base; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1187 + * ##------------------------------------------------------------------- + * ##------------------------------------------------------------------- + * cdef class IteratorRow: # <<<<<<<<<<<<<< + * '''abstract base class for iterators over mapped reads. + * + */ + +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_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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741 + * self.n_plp ) + * + * cdef class IteratorColumnAllRefs(IteratorColumn): # <<<<<<<<<<<<<< + * """iterates over all columns by chaining iterators over each reference + * """ + */ + +struct __pyx_obj_9csamtools_IteratorColumnAllRefs { + struct __pyx_obj_9csamtools_IteratorColumn __pyx_base; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402 + * raise StopIteration + * + * cdef class IteratorRowSelection(IteratorRow): # <<<<<<<<<<<<<< + * """*(Samfile samfile)* + * + */ + +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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873 + * + * + * cdef class SNPCallerBase: # <<<<<<<<<<<<<< + * '''Base class for SNP callers. + * + */ + +struct __pyx_obj_9csamtools_SNPCallerBase { + PyObject_HEAD + struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtab; + bam_maqcns_t *c; + struct __pyx_obj_9csamtools_IteratorColumn *iter; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021 + * return call + * + * cdef class SNPCaller( SNPCallerBase ): # <<<<<<<<<<<<<< + * '''*(IteratorColumn iterator_column )* + * + */ + +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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292 + * if self.owns_samfile: samclose( self.fp ) + * + * cdef class IteratorRowAll(IteratorRow): # <<<<<<<<<<<<<< + * """*(Samfile samfile, int reopen = True)* + * + */ + +struct __pyx_obj_9csamtools_IteratorRowAll { + struct __pyx_obj_9csamtools_IteratorRow __pyx_base; + struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtab; + bam1_t *b; + samfile_t *fp; + int owns_samfile; +}; + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3370 + * + * + * cdef class IndexedReads: # <<<<<<<<<<<<<< + * """index a bamfile by read. + * + */ + +struct __pyx_obj_9csamtools_IndexedReads { + PyObject_HEAD + struct __pyx_obj_9csamtools_Samfile *samfile; + samfile_t *fp; + PyObject *index; + int owns_samfile; +}; + +/* "/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. + * + */ + +struct __pyx_vtabstruct_9csamtools_IteratorColumn { + int (*cnext)(struct __pyx_obj_9csamtools_IteratorColumn *); + char *(*getSequence)(struct __pyx_obj_9csamtools_IteratorColumn *); + PyObject *(*setMask)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *); + PyObject *(*setupIteratorData)(struct __pyx_obj_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args); + PyObject *(*reset)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *); +}; +static struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtabptr_9csamtools_IteratorColumn; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712 + * self.iterdata.seq = NULL + * + * cdef class IteratorColumnRegion(IteratorColumn): # <<<<<<<<<<<<<< + * '''iterates over a region only. + * ''' + */ + +struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion { + struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_base; +}; +static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *__pyx_vtabptr_9csamtools_IteratorColumnRegion; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873 + * + * + * cdef class SNPCallerBase: # <<<<<<<<<<<<<< + * '''Base class for SNP callers. + * + */ + +struct __pyx_vtabstruct_9csamtools_SNPCallerBase { + PyObject *(*__dump)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int); +}; +static struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtabptr_9csamtools_SNPCallerBase; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021 + * return call + * + * cdef class SNPCaller( SNPCallerBase ): # <<<<<<<<<<<<<< + * '''*(IteratorColumn iterator_column )* + * + */ + +struct __pyx_vtabstruct_9csamtools_SNPCaller { + struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base; +}; +static struct __pyx_vtabstruct_9csamtools_SNPCaller *__pyx_vtabptr_9csamtools_SNPCaller; + + +/* "/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_vtabstruct_9csamtools_IteratorRowRegion { + bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowRegion *); + int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowRegion *); +}; +static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtabptr_9csamtools_IteratorRowRegion; + + +/* "/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): # <<<<<<<<<<<<<< + * """iterates over all columns by chaining iterators over each reference + * """ + */ + +struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs { + struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_base; +}; +static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *__pyx_vtabptr_9csamtools_IteratorColumnAllRefs; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":415 + * + * + * cdef class Samfile: # <<<<<<<<<<<<<< + * '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)* + * + */ + +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; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244 + * ## Public methods + * ###################################################################### + * cdef class Fastafile: # <<<<<<<<<<<<<< + * '''*(filename)* + * + */ + +struct __pyx_vtabstruct_9csamtools_Fastafile { + char *(*_fetch)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *); +}; +static struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtabptr_9csamtools_Fastafile; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292 + * if self.owns_samfile: samclose( self.fp ) + * + * cdef class IteratorRowAll(IteratorRow): # <<<<<<<<<<<<<< + * """*(Samfile samfile, int reopen = True)* + * + */ + +struct __pyx_vtabstruct_9csamtools_IteratorRowAll { + bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowAll *); + int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowAll *); +}; +static struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtabptr_9csamtools_IteratorRowAll; + + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946 + * sys.stdout.flush() + * + * cdef class IteratorSNPCalls( SNPCallerBase ): # <<<<<<<<<<<<<< + * """*(IteratorColumn iterator)* + * + */ + +struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls { + struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base; +}; +static struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls *__pyx_vtabptr_9csamtools_IteratorSNPCalls; + +#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*/ + +#ifndef CYTHON_PROFILE + #define CYTHON_PROFILE 1 +#endif + +#ifndef CYTHON_PROFILE_REUSE_FRAME + #define CYTHON_PROFILE_REUSE_FRAME 0 +#endif + +#if CYTHON_PROFILE + + #include "compile.h" + #include "frameobject.h" + #include "traceback.h" + + #if CYTHON_PROFILE_REUSE_FRAME + #define CYTHON_FRAME_MODIFIER static + #define CYTHON_FRAME_DEL + #else + #define CYTHON_FRAME_MODIFIER + #define CYTHON_FRAME_DEL Py_DECREF(__pyx_frame) + #endif + + #define __Pyx_TraceDeclarations \ + static PyCodeObject *__pyx_frame_code = NULL; \ + CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL; \ + int __Pyx_use_tracing = 0; + + #define __Pyx_TraceCall(funcname, srcfile, firstlineno) \ + if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) { \ + __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno); \ + } + + #define __Pyx_TraceException() \ + if (unlikely(__Pyx_use_tracing( && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \ + PyObject *exc_info = __Pyx_GetExceptionTuple(); \ + if (exc_info) { \ + PyThreadState_GET()->c_profilefunc( \ + PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info); \ + Py_DECREF(exc_info); \ + } \ + } + + #define __Pyx_TraceReturn(result) \ + if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) { \ + PyThreadState_GET()->c_profilefunc( \ + PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result); \ + CYTHON_FRAME_DEL; \ + } + + static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/ + static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/ + +#else + + #define __Pyx_TraceDeclarations + #define __Pyx_TraceCall(funcname, srcfile, firstlineno) + #define __Pyx_TraceException() + #define __Pyx_TraceReturn(result) + +#endif /* CYTHON_PROFILE */ + +static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) { + return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new( + (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL)); +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +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 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 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 void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + +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; + 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 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_RaiseNoneNotIterableError(void); + +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; + } +} + +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 PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { + PyObject* value; +#if PY_MAJOR_VERSION >= 3 + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (unlikely(PyErr_Occurred())) + return NULL; + value = default_value; + } + Py_INCREF(value); +#else + if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { + /* these presumably have safe hash functions */ + value = PyDict_GetItem(d, key); + if (unlikely(!value)) { + value = default_value; + } + Py_INCREF(value); + } else { + PyObject *m; + m = __Pyx_GetAttrString(d, "get"); + if (!m) return NULL; + value = PyObject_CallFunctionObjArgs(m, key, + (default_value == Py_None) ? NULL : default_value, NULL); + Py_DECREF(m); + } +#endif + return value; +} + +static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */ + +static CYTHON_INLINE long __Pyx_mod_long(long, long); /* proto */ + +#define __Pyx_DelItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_DelItemInt_Fast(o, i) : \ + __Pyx_DelItem_Generic(o, to_py_func(i))) + +static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) { + int r; + if (!j) return -1; + r = PyObject_DelItem(o, j); + Py_DECREF(j); + return r; +} + +static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i) { + if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && likely(i >= 0)) + return PySequence_DelItem(o, i); + else { + PyObject *j = PyInt_FromSsize_t(i); + return __Pyx_DelItem_Generic(o, j); + } +} + +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 PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t); + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *); + +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); + +static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/ +#if PY_MAJOR_VERSION >= 3 +static PyObject* __pyx_print = 0; +static PyObject* __pyx_print_kwargs = 0; +#endif + +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 *); + +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 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_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 __builtin__ */ + +/* 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 csamtools */ + +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_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; +static PyTypeObject *__pyx_ptype_9csamtools_SNPCall = 0; +static PyTypeObject *__pyx_ptype_9csamtools_SNPCallerBase = 0; +static PyTypeObject *__pyx_ptype_9csamtools_IteratorSNPCalls = 0; +static PyTypeObject *__pyx_ptype_9csamtools_SNPCaller = 0; +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*/ +static PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *, int, int, int); /*proto*/ +static PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *); /*proto*/ +static int __pyx_f_9csamtools_fetch_callback(bam1_t *, void *); /*proto*/ +static int __pyx_f_9csamtools_pileup_callback(uint32_t, uint32_t, int, bam_pileup1_t *, void *); /*proto*/ +static int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *, void *); /*proto*/ +static int __pyx_f_9csamtools_count_callback(bam1_t *, void *); /*proto*/ +static int __pyx_f_9csamtools_mate_callback(bam1_t *, void *); /*proto*/ +static int __pyx_f_9csamtools___advance_all(void *, bam1_t *); /*proto*/ +static int __pyx_f_9csamtools___advance_snpcalls(void *, bam1_t *); /*proto*/ +static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *); /*proto*/ +static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *, uint32_t, uint32_t); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *, uint32_t, uint32_t); /*proto*/ +#define __Pyx_MODULE_NAME "csamtools" +int __pyx_module_is_main_csamtools = 0; + +/* Implementation of csamtools */ +static PyObject *__pyx_builtin_open; +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; +static PyObject *__pyx_builtin_cmp; +static PyObject *__pyx_builtin_chr; +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_range; +static char __pyx_k_1[] = "\t"; +static char __pyx_k_2[] = "\n"; +static char __pyx_k_3[] = "calling len() on closed file"; +static char __pyx_k_4[] = "could not open file `%s`"; +static char __pyx_k_5[] = "I/O operation on closed file"; +static char __pyx_k_6[] = "no sequence/region supplied."; +static char __pyx_k_7[] = "invalid region: start (%i) > end (%i)"; +static char __pyx_k_8[] = ""; +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[] = "%s:%i-%i"; +static char __pyx_k_12[] = "invalid file opening mode `%s`"; +static char __pyx_k_13[] = "http:"; +static char __pyx_k_14[] = "ftp:"; +static char __pyx_k_15[] = "either supply options `template`, `header` or both `referencenames` and `referencelengths` for writing"; +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 (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[] = "_delegate = bam_dup1(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":80 + * cdef AlignedRead dest = AlignedRead.__new__(AlignedRead) + * dest._delegate = bam_dup1(src) + * return dest # <<<<<<<<<<<<<< + * + * cdef class PileupProxy + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_dest)); + __pyx_r = ((PyObject *)__pyx_v_dest); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.makeAlignedRead"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_dest); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":83 + * + * cdef class PileupProxy + * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ): # <<<<<<<<<<<<<< + * cdef PileupProxy dest = PileupProxy.__new__(PileupProxy) + * dest.plp = plp + */ + +static PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp, int __pyx_v_tid, int __pyx_v_pos, int __pyx_v_n) { + struct __pyx_obj_9csamtools_PileupProxy *__pyx_v_dest = 0; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("makePileupProxy"); + __Pyx_TraceCall("makePileupProxy", __pyx_f[0], 83); + + /* "/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 = 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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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 # <<<<<<<<<<<<<< + * dest.tid = tid + * dest.pos = pos + */ + __pyx_v_dest->plp = __pyx_v_plp; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":86 + * cdef PileupProxy dest = PileupProxy.__new__(PileupProxy) + * dest.plp = plp + * dest.tid = tid # <<<<<<<<<<<<<< + * dest.pos = pos + * dest.n = n + */ + __pyx_v_dest->tid = __pyx_v_tid; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":87 + * dest.plp = plp + * dest.tid = tid + * dest.pos = pos # <<<<<<<<<<<<<< + * dest.n = n + * return dest + */ + __pyx_v_dest->pos = __pyx_v_pos; + + /* "/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 = 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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":89 + * dest.pos = pos + * dest.n = n + * return dest # <<<<<<<<<<<<<< + * + * cdef class PileupRead + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_dest)); + __pyx_r = ((PyObject *)__pyx_v_dest); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.makePileupProxy"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_dest); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":92 + * + * cdef class PileupRead + * cdef makePileupRead( bam_pileup1_t * src ): # <<<<<<<<<<<<<< + * '''fill a PileupRead object from a bam_pileup1_t * object.''' + * cdef PileupRead dest = PileupRead.__new__(PileupRead) + */ + +static PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src) { + struct __pyx_obj_9csamtools_PileupRead *__pyx_v_dest = 0; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("makePileupRead"); + __Pyx_TraceCall("makePileupRead", __pyx_f[0], 92); + + /* "/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 = 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 = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupRead *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":96 + * cdef PileupRead dest = PileupRead.__new__(PileupRead) + * dest._alignment = makeAlignedRead( src.b ) + * dest._qpos = src.qpos # <<<<<<<<<<<<<< + * dest._indel = src.indel + * dest._level = src.level + */ + __pyx_v_dest->_qpos = __pyx_v_src->qpos; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":97 + * dest._alignment = makeAlignedRead( src.b ) + * dest._qpos = src.qpos + * dest._indel = src.indel # <<<<<<<<<<<<<< + * dest._level = src.level + * dest._is_del = src.is_del + */ + __pyx_v_dest->_indel = __pyx_v_src->indel; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":98 + * dest._qpos = src.qpos + * dest._indel = src.indel + * dest._level = src.level # <<<<<<<<<<<<<< + * dest._is_del = src.is_del + * dest._is_head = src.is_head + */ + __pyx_v_dest->_level = __pyx_v_src->level; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":99 + * dest._indel = src.indel + * dest._level = src.level + * dest._is_del = src.is_del # <<<<<<<<<<<<<< + * dest._is_head = src.is_head + * dest._is_tail = src.is_tail + */ + __pyx_v_dest->_is_del = __pyx_v_src->is_del; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":100 + * dest._level = src.level + * dest._is_del = src.is_del + * dest._is_head = src.is_head # <<<<<<<<<<<<<< + * dest._is_tail = src.is_tail + * return dest + */ + __pyx_v_dest->_is_head = __pyx_v_src->is_head; + + /* "/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 # <<<<<<<<<<<<<< + * return dest + * + */ + __pyx_v_dest->_is_tail = __pyx_v_src->is_tail; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":102 + * dest._is_head = src.is_head + * dest._is_tail = src.is_tail + * return dest # <<<<<<<<<<<<<< + * + * ##################################################################### + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_dest)); + __pyx_r = ((PyObject *)__pyx_v_dest); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.makePileupRead"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_dest); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":109 + * ## Generic callbacks for inserting python callbacks. + * ##################################################################### + * cdef int fetch_callback( bam1_t *alignment, void *f): # <<<<<<<<<<<<<< + * '''callback for bam_fetch. + * + */ + +static int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) { + PyObject *__pyx_v_a; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("fetch_callback"); + __Pyx_TraceCall("fetch_callback", __pyx_f[0], 109); + __pyx_v_a = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":114 + * calls function in *f* with a new :class:`AlignedRead` object as parameter. + * ''' + * a = makeAlignedRead( alignment ) # <<<<<<<<<<<<<< + * (f)(a) + * + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":115 + * ''' + * a = makeAlignedRead( alignment ) + * (f)(a) # <<<<<<<<<<<<<< + * + * class PileupColumn(object): + */ + __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 = 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; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("csamtools.fetch_callback"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_a); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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) ) + */ + +static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__str__"); + __Pyx_TraceCall("__str__", __pyx_f[0], 130); + __pyx_self = __pyx_self; + + /* "/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_XDECREF(__pyx_r); + + /* "/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 = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "/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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __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 = 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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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 = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "/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 = 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 = 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 = 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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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 = 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; + __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_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("csamtools.PileupColumn.__str__"); + __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":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): # <<<<<<<<<<<<<< + * '''callback for pileup. + * + */ + +static int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __pyx_v_pos, int __pyx_v_n, bam_pileup1_t *__pyx_v_pl, void *__pyx_v_f) { + PyObject *__pyx_v_p; + PyObject *__pyx_v_pileups; + int __pyx_v_x; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("pileup_callback"); + __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); + + /* "/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 = 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 = 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; + + /* "/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 = 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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/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 = 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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/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 = 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 = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":158 + * + * cdef int x + * for x from 0 <= x < n: # <<<<<<<<<<<<<< + * pileups.append( makePileupRead( &(pl[x]) ) ) + * p.pileups = pileups + */ + __pyx_t_3 = __pyx_v_n; + for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":159 + * cdef int x + * for x from 0 <= x < n: + * pileups.append( makePileupRead( &(pl[x]) ) ) # <<<<<<<<<<<<<< + * p.pileups = pileups + * + */ + if (unlikely(__pyx_v_pileups == Py_None)) { + 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 = 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 = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":160 + * for x from 0 <= x < n: + * pileups.append( makePileupRead( &(pl[x]) ) ) + * p.pileups = pileups # <<<<<<<<<<<<<< + * + * (f)(p) + */ + 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;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":162 + * p.pileups = pileups + * + * (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 = 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 = 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; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("csamtools.pileup_callback"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_p); + __Pyx_DECREF(__pyx_v_pileups); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":164 + * (f)(p) + * + * cdef int pileup_fetch_callback( bam1_t *b, void *data): # <<<<<<<<<<<<<< + * '''callback for bam_fetch. + * + */ + +static int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__pyx_v_data) { + bam_plbuf_t *__pyx_v_buf; + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("pileup_fetch_callback"); + __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 164); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":170 + * ''' + * cdef bam_plbuf_t * buf + * buf = data # <<<<<<<<<<<<<< + * bam_plbuf_push(b, buf) + * return 0 + */ + __pyx_v_buf = ((bam_plbuf_t *)__pyx_v_data); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":171 + * cdef bam_plbuf_t * buf + * buf = data + * bam_plbuf_push(b, buf) # <<<<<<<<<<<<<< + * return 0 + * + */ + bam_plbuf_push(__pyx_v_b, __pyx_v_buf); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":172 + * buf = data + * bam_plbuf_push(b, buf) + * return 0 # <<<<<<<<<<<<<< + * + * class StderrStore(): + */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178 + * stderr is captured. + * ''' + * def __init__(self): # <<<<<<<<<<<<<< + * return + * self.stderr_h, self.stderr_f = tempfile.mkstemp() + */ + +static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__init__"); + __Pyx_TraceCall("__init__", __pyx_f[0], 178); + __pyx_self = __pyx_self; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":179 + * ''' + * def __init__(self): + * return # <<<<<<<<<<<<<< + * self.stderr_h, self.stderr_f = tempfile.mkstemp() + * self.stderr_save = Outs( sys.stderr.fileno() ) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "/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 = 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 = 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 = 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)) { + PyObject* tuple = __pyx_t_1; + __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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/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 = 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 = 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 = 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 = 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 = 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; + __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_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("csamtools.StderrStore.__init__"); + __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":184 + * self.stderr_save.setfd( self.stderr_h ) + * + * def readAndRelease( self ): # <<<<<<<<<<<<<< + * return [] + * self.stderr_save.restore() + */ + +static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("readAndRelease"); + __Pyx_TraceCall("readAndRelease", __pyx_f[0], 184); + __pyx_self = __pyx_self; + __pyx_v_lines = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":185 + * + * def readAndRelease( self ): + * return [] # <<<<<<<<<<<<<< + * self.stderr_save.restore() + * lines = [] + */ + __Pyx_XDECREF(__pyx_r); + __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; + + /* "/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 = 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 = 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 = 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; + + /* "/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 = 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; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 188; __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/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 = 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 = 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); + __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_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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":191 + * lines = open( self.stderr_f, "r" ).readlines() + * os.remove( self.stderr_f ) + * return lines # <<<<<<<<<<<<<< + * + * def release(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_lines); + __pyx_r = __pyx_v_lines; + 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("csamtools.StderrStore.readAndRelease"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_lines); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193 + * return lines + * + * def release(self): # <<<<<<<<<<<<<< + * return + * self.stderr_save.restore() + */ + +static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("release"); + __Pyx_TraceCall("release", __pyx_f[0], 193); + __pyx_self = __pyx_self; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":194 + * + * def release(self): + * return # <<<<<<<<<<<<<< + * self.stderr_save.restore() + * if os.path.exists(self.stderr_f): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "/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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 196; __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/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 = 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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + 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_AddTraceback("csamtools.StderrStore.release"); + __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":199 + * os.remove( self.stderr_f ) + * + * def __del__(self): # <<<<<<<<<<<<<< + * self.release() + * + */ + +static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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], 199); + __pyx_self = __pyx_self; + + /* "/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 = 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 = 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; + + __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.StderrStore.__del__"); + __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":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 ): # <<<<<<<<<<<<<< + * self.fastafile = NULL + * self._filename = NULL + */ + +static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_args = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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; + __Pyx_GOTREF(__pyx_v_kwargs); + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":261 + * + * def __cinit__(self, *args, **kwargs ): + * self.fastafile = NULL # <<<<<<<<<<<<<< + * self._filename = NULL + * self._open( *args, **kwargs ) + */ + ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":262 + * def __cinit__(self, *args, **kwargs ): + * self.fastafile = NULL + * self._filename = NULL # <<<<<<<<<<<<<< + * self._open( *args, **kwargs ) + * + */ + ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = NULL; + + /* "/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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_AddTraceback("csamtools.Fastafile.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_args); + __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":265 + * self._open( *args, **kwargs ) + * + * def _isOpen( self ): # <<<<<<<<<<<<<< + * '''return true if samfile has been opened.''' + * return self.fastafile != NULL + */ + +static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +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], 265); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":267 + * def _isOpen( self ): + * '''return true if samfile has been opened.''' + * return self.fastafile != NULL # <<<<<<<<<<<<<< + * + * 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 = 267; __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.Fastafile._isOpen"); + __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":269 + * return self.fastafile != NULL + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.fastafile == NULL: + * raise ValueError( "calling len() on closed file" ) + */ + +static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__len__"); + __Pyx_TraceCall("__len__", __pyx_f[0], 269); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":270 + * + * def __len__(self): + * if self.fastafile == NULL: # <<<<<<<<<<<<<< + * raise ValueError( "calling len() on closed file" ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL); + if (__pyx_t_1) { + + /* "/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 = 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 = 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 = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":273 + * raise ValueError( "calling len() on closed file" ) + * + * return faidx_fetch_nseq(self.fastafile) # <<<<<<<<<<<<<< + * + * def _open( self, + */ + __pyx_r = faidx_fetch_nseq(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.Fastafile.__len__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":275 + * return faidx_fetch_nseq(self.fastafile) + * + * def _open( self, # <<<<<<<<<<<<<< + * char * filename ): + * '''open an indexed fasta file. + */ + +static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/ +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; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("_open"); + __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 = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.Fastafile._open"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":283 + * + * # close a previously opened file + * if self.fastafile != NULL: self.close() # <<<<<<<<<<<<<< + * if self._filename != NULL: free(self._filename) + * self._filename = strdup(filename) + */ + __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 = 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 = 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; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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) # <<<<<<<<<<<<<< + * self._filename = strdup(filename) + * self.fastafile = fai_load( filename ) + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename != NULL); + if (__pyx_t_1) { + free(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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) # <<<<<<<<<<<<<< + * self.fastafile = fai_load( filename ) + * + */ + ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":286 + * if self._filename != NULL: free(self._filename) + * self._filename = strdup(filename) + * self.fastafile = fai_load( filename ) # <<<<<<<<<<<<<< + * + * if self.fastafile == NULL: + */ + ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = fai_load(__pyx_v_filename); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":288 + * self.fastafile = fai_load( filename ) + * + * if self.fastafile == NULL: # <<<<<<<<<<<<<< + * raise IOError("could not open file `%s`" % filename ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL); + if (__pyx_t_1) { + + /* "/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 = 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 = 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 = 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 = 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 = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + __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.Fastafile._open"); + __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":291 + * raise IOError("could not open file `%s`" % filename ) + * + * def close( self ): # <<<<<<<<<<<<<< + * if self.fastafile != NULL: + * fai_destroy( self.fastafile ) + */ + +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], 291); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":292 + * + * def close( self ): + * if self.fastafile != NULL: # <<<<<<<<<<<<<< + * fai_destroy( self.fastafile ) + * self.fastafile = NULL + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":293 + * def close( self ): + * if self.fastafile != NULL: + * fai_destroy( self.fastafile ) # <<<<<<<<<<<<<< + * self.fastafile = NULL + * + */ + fai_destroy(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":294 + * if self.fastafile != NULL: + * fai_destroy( self.fastafile ) + * self.fastafile = NULL # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL; + goto __pyx_L5; + } + __pyx_L5:; + + __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":296 + * self.fastafile = NULL + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * self.close() + * if self._filename != NULL: free(self._filename) + */ + +static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self) { + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 296); + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":298 + * def __dealloc__(self): + * self.close() + * if self._filename != NULL: free(self._filename) # <<<<<<<<<<<<<< + * + * property filename: + */ + __pyx_t_3 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename != NULL); + if (__pyx_t_3) { + free(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); + goto __pyx_L5; + } + __pyx_L5:; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Fastafile.__dealloc__"); + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":302 + * property filename: + * '''number of :term:`filename` associated with this object.''' + * def __get__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * return self._filename + */ + +static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 302); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 # <<<<<<<<<<<<<< + * + * 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 = 304; __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_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Fastafile.filename.__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":306 + * return self._filename + * + * def fetch( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +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[] = "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; + PyObject *__pyx_v_end = 0; + PyObject *__pyx_v_region = 0; + int __pyx_v_length; + char *__pyx_v_seq; + PyObject *__pyx_v_py_seq; + PyObject *__pyx_r = NULL; + 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__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], 306); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[4] = {0,0,0,0}; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None): + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None): + * + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310 + * start = None, + * end = None, + * region = None): # <<<<<<<<<<<<<< + * + * '''*(reference = None, start = None, end = None, region = None)* + */ + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + 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), "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]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None): + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None): + * + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310 + * start = None, + * end = None, + * region = None): # <<<<<<<<<<<<<< + * + * '''*(reference = None, start = None, end = None, region = None)* + */ + __pyx_v_region = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.Fastafile.fetch"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_start); + __Pyx_INCREF(__pyx_v_end); + __Pyx_INCREF(__pyx_v_region); + __pyx_v_py_seq = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = (!__pyx_t_4); + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":334 + * + * if not region: + * if reference is None: raise ValueError( 'no sequence/region supplied.' ) # <<<<<<<<<<<<<< + * if start is None: start = 0 + * if end is None: end = max_pos -1 + */ + __pyx_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 = 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 = 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 = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 # <<<<<<<<<<<<<< + * if end is None: end = max_pos -1 + * + */ + __pyx_t_3 = (__pyx_v_start == Py_None); + if (__pyx_t_3) { + __Pyx_INCREF(__pyx_int_0); + __Pyx_DECREF(__pyx_v_start); + __pyx_v_start = __pyx_int_0; + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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 # <<<<<<<<<<<<<< + * + * if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) ) + */ + __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 = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_v_end); + __pyx_v_end = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L10; + } + __pyx_L10:; + + /* "/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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_start); + __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 = 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 = 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 = 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 = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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 = 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 = 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); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_8)); + __pyx_r = ((PyObject *)__pyx_kp_s_8); + goto __pyx_L0; + goto __pyx_L12; + } + __pyx_L12:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L13; + } + __pyx_L13:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L14; + } + __pyx_L14:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_end); + 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 = 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; + + /* "/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 = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":354 + * seq = fai_fetch( self.fastafile, + * region, + * &length ) # <<<<<<<<<<<<<< + * else: + * # samtools adds a '\0' at the end + */ + __pyx_v_seq = fai_fetch(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile, __pyx_t_5, (&__pyx_v_length)); + goto __pyx_L7; + } + /*else*/ { + + /* "/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 = 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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":360 + * + * # copy to python + * if seq == NULL: # <<<<<<<<<<<<<< + * return "" + * else: + */ + __pyx_t_3 = (__pyx_v_seq == NULL); + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":361 + * # copy to python + * if seq == NULL: + * return "" # <<<<<<<<<<<<<< + * else: + * try: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_8)); + __pyx_r = ((PyObject *)__pyx_kp_s_8); + goto __pyx_L0; + goto __pyx_L15; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":363 + * return "" + * else: + * try: # <<<<<<<<<<<<<< + * py_seq = PyString_FromStringAndSize(seq, length) + * finally: + */ + /*try:*/ { + + /* "/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 = 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; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":366 + * py_seq = PyString_FromStringAndSize(seq, length) + * finally: + * free(seq) # <<<<<<<<<<<<<< + * + * return py_seq + */ + /*finally:*/ { + int __pyx_why; + PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; + int __pyx_exc_lineno; + __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; + __pyx_why = 0; goto __pyx_L18; + __pyx_L17: { + __pyx_why = 4; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); + __pyx_exc_lineno = __pyx_lineno; + goto __pyx_L18; + } + __pyx_L18:; + free(__pyx_v_seq); + switch (__pyx_why) { + case 4: { + __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); + __pyx_lineno = __pyx_exc_lineno; + __pyx_exc_type = 0; + __pyx_exc_value = 0; + __pyx_exc_tb = 0; + goto __pyx_L1_error; + } + } + } + } + __pyx_L15:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":368 + * free(seq) + * + * return py_seq # <<<<<<<<<<<<<< + * + * cdef char * _fetch( self, char * reference, int start, int end, int * length ): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_py_seq); + __pyx_r = __pyx_v_py_seq; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Fastafile.fetch"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_py_seq); + __Pyx_DECREF(__pyx_v_start); + __Pyx_DECREF(__pyx_v_end); + __Pyx_DECREF(__pyx_v_region); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":370 + * return py_seq + * + * cdef char * _fetch( self, char * reference, int start, int end, int * length ): # <<<<<<<<<<<<<< + * '''fetch sequence for reference, start and end''' + * + */ + +static char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_Fastafile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_start, int __pyx_v_end, int *__pyx_v_length) { + char *__pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("_fetch"); + __Pyx_TraceCall("_fetch", __pyx_f[0], 370); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":377 + * start, + * end-1, + * length ) # <<<<<<<<<<<<<< + * + * #------------------------------------------------------------------------ + */ + __pyx_r = faidx_fetch_seq(__pyx_v_self->fastafile, __pyx_v_reference, __pyx_v_start, (__pyx_v_end - 1), __pyx_v_length); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":382 + * #------------------------------------------------------------------------ + * #------------------------------------------------------------------------ + * cdef int count_callback( bam1_t *alignment, void *f): # <<<<<<<<<<<<<< + * '''callback for bam_fetch - count number of reads. + * ''' + */ + +static int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) { + int *__pyx_v_counter; + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("count_callback"); + __Pyx_TraceCall("count_callback", __pyx_f[0], 382); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":385 + * '''callback for bam_fetch - count number of reads. + * ''' + * cdef int* counter = (f) # <<<<<<<<<<<<<< + * counter[0] += 1; + * + */ + __pyx_v_counter = ((int *)__pyx_v_f); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":386 + * ''' + * cdef int* counter = (f) + * counter[0] += 1; # <<<<<<<<<<<<<< + * + * ctypedef struct MateData: + */ + (__pyx_v_counter[0]) += 1; + + __pyx_r = 0; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":396 + * #------------------------------------------------------------------------ + * #------------------------------------------------------------------------ + * cdef int mate_callback( bam1_t *alignment, void *f): # <<<<<<<<<<<<<< + * '''callback for bam_fetch = filter mate + * ''' + */ + +static int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) { + __pyx_t_9csamtools_MateData *__pyx_v_d; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("mate_callback"); + __Pyx_TraceCall("mate_callback", __pyx_f[0], 396); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":399 + * '''callback for bam_fetch = filter mate + * ''' + * cdef MateData * d = (f) # <<<<<<<<<<<<<< + * # printf("mate = %p, name1 = %s, name2=%s\t%i\t%i\t%i\n", + * # d.mate, d.name, bam1_qname(alignment), + */ + __pyx_v_d = ((__pyx_t_9csamtools_MateData *)__pyx_v_f); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":404 + * # d.flag, alignment.core.flag, alignment.core.flag & d.flag) + * + * if d.mate == NULL: # <<<<<<<<<<<<<< + * # could be sped up by comparing the lengths of query strings first + * # using l_qname + */ + __pyx_t_1 = (__pyx_v_d->mate == NULL); + if (__pyx_t_1) { + + /* "/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 \ # <<<<<<<<<<<<<< + * strcmp( bam1_qname( alignment ), d.name ) == 0: + * d.mate = bam_dup1( alignment ) + */ + __pyx_t_1 = ((__pyx_v_alignment->core.flag & __pyx_v_d->flag) != 0); + if (__pyx_t_1) { + + /* "/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: # <<<<<<<<<<<<<< + * d.mate = bam_dup1( alignment ) + * + */ + __pyx_t_2 = (strcmp(bam1_qname(__pyx_v_alignment), __pyx_v_d->name) == 0); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "/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 ) # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_d->mate = bam_dup1(__pyx_v_alignment); + goto __pyx_L4; + } + __pyx_L4:; + goto __pyx_L3; + } + __pyx_L3:; + + __pyx_r = 0; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":455 + * ''' + * + * def __cinit__(self, *args, **kwargs ): # <<<<<<<<<<<<<< + * self.samfile = NULL + * self._filename = NULL + */ + +static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_args = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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; + __Pyx_GOTREF(__pyx_v_kwargs); + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":456 + * + * def __cinit__(self, *args, **kwargs ): + * self.samfile = NULL # <<<<<<<<<<<<<< + * self._filename = NULL + * self.isbam = False + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":457 + * def __cinit__(self, *args, **kwargs ): + * self.samfile = NULL + * self._filename = NULL # <<<<<<<<<<<<<< + * self.isbam = False + * self._open( *args, **kwargs ) + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":458 + * self.samfile = NULL + * self._filename = NULL + * self.isbam = False # <<<<<<<<<<<<<< + * self._open( *args, **kwargs ) + * + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = 0; + + /* "/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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":462 + * + * # allocate memory for iterator + * self.b = calloc(1, sizeof(bam1_t)) # <<<<<<<<<<<<<< + * + * def _isOpen( self ): + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t)))); + + __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_AddTraceback("csamtools.Samfile.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_args); + __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":464 + * self.b = calloc(1, sizeof(bam1_t)) + * + * def _isOpen( self ): # <<<<<<<<<<<<<< + * '''return true if samfile has been opened.''' + * return self.samfile != NULL + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +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], 464); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":466 + * def _isOpen( self ): + * '''return true if samfile has been opened.''' + * return self.samfile != NULL # <<<<<<<<<<<<<< + * + * 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 = 466; __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.Samfile._isOpen"); + __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":468 + * return self.samfile != NULL + * + * def _hasIndex( self ): # <<<<<<<<<<<<<< + * '''return true if samfile has an existing (and opened) index.''' + * return self.index != NULL + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +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], 468); + + /* "/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 # <<<<<<<<<<<<<< + * + * 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 = 470; __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.Samfile._hasIndex"); + __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":472 + * return self.index != NULL + * + * def _open( self, # <<<<<<<<<<<<<< + * char * filename, + * 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[] = "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; + struct __pyx_obj_9csamtools_Samfile *__pyx_v_template = 0; + PyObject *__pyx_v_referencenames = 0; + PyObject *__pyx_v_referencelengths = 0; + 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; + PyObject *__pyx_v_x; + PyObject *__pyx_v_name; + PyObject *__pyx_v_store; + PyObject *__pyx_r = NULL; + int __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; + int __pyx_t_7; + int __pyx_t_8; + Py_ssize_t __pyx_t_9; + 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], 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}; + + /* "/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 = None, + * Samfile template = None, # <<<<<<<<<<<<<< + * referencenames = None, + * referencelengths = None, + */ + values[2] = (PyObject *)((struct __pyx_obj_9csamtools_Samfile *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476 + * mode = None, + * Samfile template = None, + * referencenames = None, # <<<<<<<<<<<<<< + * referencelengths = None, + * text = None, + */ + values[3] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477 + * Samfile template = None, + * referencenames = None, + * referencelengths = None, # <<<<<<<<<<<<<< + * text = None, + * header = None, + */ + values[4] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478 + * referencenames = None, + * referencelengths = None, + * text = None, # <<<<<<<<<<<<<< + * header = None, + * port = None, + */ + values[5] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479 + * referencelengths = None, + * text = None, + * header = None, # <<<<<<<<<<<<<< + * port = None, + * ): + */ + values[6] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480 + * text = None, + * header = None, + * port = None, # <<<<<<<<<<<<<< + * ): + * '''open a sam/bam file. + */ + values[7] = ((PyObject *)Py_None); + 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); + 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__filename); + 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__mode); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__template); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__referencenames); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__referencelengths); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__text); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__header); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__port); + if (value) { values[7] = value; kw_args--; } + } + } + 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 = 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 = 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]; + __pyx_v_referencelengths = values[4]; + __pyx_v_text = values[5]; + __pyx_v_header = values[6]; + __pyx_v_port = values[7]; + } else { + + /* "/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 = None, + * Samfile template = None, # <<<<<<<<<<<<<< + * referencenames = None, + * referencelengths = None, + */ + __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476 + * mode = None, + * Samfile template = None, + * referencenames = None, # <<<<<<<<<<<<<< + * referencelengths = None, + * text = None, + */ + __pyx_v_referencenames = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477 + * Samfile template = None, + * referencenames = None, + * referencelengths = None, # <<<<<<<<<<<<<< + * text = None, + * header = None, + */ + __pyx_v_referencelengths = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478 + * referencenames = None, + * referencelengths = None, + * text = None, # <<<<<<<<<<<<<< + * header = None, + * port = None, + */ + __pyx_v_text = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479 + * referencelengths = None, + * text = None, + * header = None, # <<<<<<<<<<<<<< + * port = None, + * ): + */ + __pyx_v_header = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480 + * text = None, + * header = None, + * port = None, # <<<<<<<<<<<<<< + * ): + * '''open a sam/bam file. + */ + __pyx_v_port = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 8: __pyx_v_port = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: __pyx_v_header = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: __pyx_v_referencelengths = PyTuple_GET_ITEM(__pyx_args, 4); + 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 = 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 = 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 = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/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 + * + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + __Pyx_INCREF(__pyx_v_mode); + __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_1 = __pyx_t_7; + } + 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_7 = __pyx_t_1; + } + 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_1 = __pyx_t_7; + } + 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_7 = __pyx_t_1; + } + 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_1 = __pyx_t_7; + } + __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 + + /* "/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 # <<<<<<<<<<<<<< + * + * # close a previously opened file + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + if (unlikely(!(__pyx_v_filename != NULL))) { + PyErr_SetNone(PyExc_AssertionError); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":508 + * + * # close a previously opened file + * if self.samfile != NULL: self.close() # <<<<<<<<<<<<<< + * self.samfile = NULL + * + */ + __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_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; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L17; + } + __pyx_L17:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":509 + * # close a previously opened file + * if self.samfile != NULL: self.close() + * self.samfile = NULL # <<<<<<<<<<<<<< + * + * cdef bam_header_t * header_to_write + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":512 + * + * cdef bam_header_t * header_to_write + * header_to_write = NULL # <<<<<<<<<<<<<< + * + * if self._filename != NULL: free(self._filename ) + */ + __pyx_v_header_to_write = NULL; + + /* "/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_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_L18; + } + __pyx_L18:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":515 + * + * if self._filename != NULL: free(self._filename ) + * self._filename = strdup( filename ) # <<<<<<<<<<<<<< + * + * self.isbam = len(mode) > 1 and mode[1] == 'b' + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename); + + /* "/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_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_2 = __pyx_t_5; + __pyx_t_5 = 0; + } else { + __pyx_t_2 = __pyx_t_3; + __pyx_t_3 = 0; + } + __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; + + /* "/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_1 = (strncmp(__pyx_v_filename, __pyx_k_13, 5) == 0); + if (!__pyx_t_1) { + + /* "/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_7 = (strncmp(__pyx_v_filename, __pyx_k_14, 4) == 0); + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_1; + } + + /* "/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_8; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":523 + * + * cdef char * ctext + * ctext = NULL # <<<<<<<<<<<<<< + * + * if mode[0] == 'w': + */ + __pyx_v_ctext = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":525 + * ctext = NULL + * + * if mode[0] == 'w': # <<<<<<<<<<<<<< + * # open file for writing + * + */ + __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_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; + __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) { + + /* "/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_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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":531 + * if template: + * # copy header from another file + * header_to_write = template.samfile.header # <<<<<<<<<<<<<< + * + * elif header: + */ + __pyx_v_header_to_write = __pyx_v_template->samfile->header; + goto __pyx_L20; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":533 + * header_to_write = template.samfile.header + * + * elif header: # <<<<<<<<<<<<<< + * header_to_write = self._buildHeader( header ) + * + */ + __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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":534 + * + * elif header: + * header_to_write = self._buildHeader( header ) # <<<<<<<<<<<<<< + * + * 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_L20; + } + /*else*/ { + + /* "/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" # <<<<<<<<<<<<<< + * assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences" + * + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + __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_7 = __pyx_t_8; + } + if (unlikely(!__pyx_t_7)) { + PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_15)); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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" # <<<<<<<<<<<<<< + * + * # allocate and fill header + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + __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 = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":542 + * + * # allocate and fill header + * header_to_write = bam_header_init() # <<<<<<<<<<<<<< + * header_to_write.n_targets = len(referencenames) + * n = 0 + */ + __pyx_v_header_to_write = bam_header_init(); + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":544 + * header_to_write = bam_header_init() + * header_to_write.n_targets = len(referencenames) + * n = 0 # <<<<<<<<<<<<<< + * for x in referencenames: n += len(x) + 1 + * header_to_write.target_name = calloc(n, sizeof(char*)) + */ + __Pyx_INCREF(__pyx_int_0); + __Pyx_DECREF(__pyx_v_n); + __pyx_v_n = __pyx_int_0; + + /* "/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 # <<<<<<<<<<<<<< + * header_to_write.target_name = calloc(n, sizeof(char*)) + * header_to_write.target_len = calloc(n, sizeof(uint32_t)) + */ + if (PyList_CheckExact(__pyx_v_referencenames) || PyTuple_CheckExact(__pyx_v_referencenames)) { + __pyx_t_10 = 0; __pyx_t_3 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_3); + } else { + __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_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_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_2); + } + __Pyx_DECREF(__pyx_v_x); + __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_5; + __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":546 + * n = 0 + * for x in referencenames: n += len(x) + 1 + * header_to_write.target_name = calloc(n, sizeof(char*)) # <<<<<<<<<<<<<< + * header_to_write.target_len = calloc(n, sizeof(uint32_t)) + * for x from 0 <= x < header_to_write.n_targets: + */ + __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 *)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":547 + * for x in referencenames: n += len(x) + 1 + * header_to_write.target_name = calloc(n, sizeof(char*)) + * header_to_write.target_len = 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_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)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548 + * header_to_write.target_name = calloc(n, sizeof(char*)) + * header_to_write.target_len = 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_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_3; + __pyx_t_3 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":549 + * header_to_write.target_len = 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] = calloc(len(name)+1, sizeof(char)) + */ + __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; + + /* "/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] = calloc(len(name)+1, sizeof(char)) + * strncpy( header_to_write.target_name[x], name, len(name) ) + */ + __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_3; + __pyx_t_3 = 0; + + /* "/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] = calloc(len(name)+1, sizeof(char)) # <<<<<<<<<<<<<< + * strncpy( header_to_write.target_name[x], name, len(name) ) + * + */ + __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)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":552 + * name = referencenames[x] + * header_to_write.target_name[x] = calloc(len(name)+1, sizeof(char)) + * strncpy( header_to_write.target_name[x], name, len(name) ) # <<<<<<<<<<<<<< + * + * if text != None: + */ + __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;} + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548 + * header_to_write.target_name = calloc(n, sizeof(char*)) + * header_to_write.target_len = 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_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_3; + __pyx_t_3 = 0; + + /* "/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_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) { + + /* "/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 = calloc( strlen(ctext), sizeof(char) ) + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":557 + * # copy without \0 + * ctext = text + * header_to_write.l_text = strlen(ctext) # <<<<<<<<<<<<<< + * header_to_write.text = calloc( strlen(ctext), sizeof(char) ) + * memcpy( header_to_write.text, ctext, strlen(ctext) ) + */ + __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":558 + * ctext = text + * header_to_write.l_text = strlen(ctext) + * header_to_write.text = calloc( strlen(ctext), sizeof(char) ) # <<<<<<<<<<<<<< + * memcpy( header_to_write.text, ctext, strlen(ctext) ) + * + */ + __pyx_v_header_to_write->text = ((char *)calloc(strlen(__pyx_v_ctext), (sizeof(char)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":559 + * header_to_write.l_text = strlen(ctext) + * header_to_write.text = calloc( strlen(ctext), sizeof(char) ) + * memcpy( header_to_write.text, ctext, strlen(ctext) ) # <<<<<<<<<<<<<< + * + * header_to_write.hash = NULL + */ + memcpy(__pyx_v_header_to_write->text, __pyx_v_ctext, strlen(__pyx_v_ctext)); + goto __pyx_L25; + } + __pyx_L25:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":561 + * memcpy( header_to_write.text, ctext, strlen(ctext) ) + * + * header_to_write.hash = NULL # <<<<<<<<<<<<<< + * header_to_write.rg2lib = NULL + * + */ + __pyx_v_header_to_write->hash = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":562 + * + * header_to_write.hash = NULL + * header_to_write.rg2lib = NULL # <<<<<<<<<<<<<< + * + * # open file. Header gets written to file at the same time for bam files + */ + __pyx_v_header_to_write->rg2lib = NULL; + } + __pyx_L20:; + + /* "/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_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_5; + __pyx_t_5 = 0; + + /* "/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_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); + + /* "/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_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; + + /* "/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_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_1 = __pyx_t_8; + } + if (__pyx_t_1) { + + /* "/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 ) # <<<<<<<<<<<<<< + * + * elif mode[0] == "r": + */ + bam_header_destroy(__pyx_v_header_to_write); + goto __pyx_L26; + } + __pyx_L26:; + goto __pyx_L19; + } + + /* "/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_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) { + + /* "/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_1 = (strncmp(__pyx_v_filename, __pyx_k_17, 1) != 0); + if (__pyx_t_1) { + + /* "/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_8 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote); + if (__pyx_t_8) { + + /* "/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_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); + 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_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_7 = __pyx_t_8; + } + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_1; + } + if (__pyx_t_8) { + + /* "/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_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_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); + __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 = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L27; + } + __pyx_L27:; + + /* "/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 (mode='%s') - is it SAM/BAM format?" % mode) + */ + __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); + + /* "/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 (mode='%s') - is it SAM/BAM format?" % mode) + * + */ + __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL); + if (__pyx_t_8) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":584 + * self.samfile = samopen( filename, mode, NULL ) + * if self.samfile == NULL: + * raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode) # <<<<<<<<<<<<<< + * + * if self.samfile.header == NULL: + */ + __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_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 = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L28; + } + __pyx_L28:; + + /* "/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( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode ) + * + */ + __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL); + if (__pyx_t_8) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":587 + * + * if self.samfile.header == NULL: + * raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode ) # <<<<<<<<<<<<<< + * + * #disabled for autodetection to work + */ + __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_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 = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L29; + } + __pyx_L29:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":590 + * + * #disabled for autodetection to work + * if self.samfile.header.n_targets == 0: # <<<<<<<<<<<<<< + * raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode) + * + */ + __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0); + if (__pyx_t_8) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":591 + * #disabled for autodetection to work + * if self.samfile.header.n_targets == 0: + * raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode) # <<<<<<<<<<<<<< + * + * if self.samfile == NULL: + */ + __pyx_t_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_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 = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L30; + } + __pyx_L30:; + goto __pyx_L19; + } + __pyx_L19:; + + /* "/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_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL); + if (__pyx_t_8) { + + /* "/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 = 594; __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 = 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 = 594; __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 = 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_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_L31:; + + /* "/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_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_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_8) { + __pyx_t_1 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam; + } else { + __pyx_t_1 = __pyx_t_8; + } + if (__pyx_t_1) { + + /* "/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_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote); + if (__pyx_t_1) { + + /* "/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 = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_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_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_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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":601 + * if not self.isremote: + * if not os.path.exists(filename +".bai"): + * self.index = NULL # <<<<<<<<<<<<<< + * else: + * # 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_L34; + } + /*else*/ { + + /* "/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) # <<<<<<<<<<<<<< + * if self.index == NULL: + * raise IOError("error while opening index `%s` " % filename ) + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename); + + /* "/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_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL); + if (__pyx_t_8) { + + /* "/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_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_L35:; + } + __pyx_L34:; + goto __pyx_L33; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":608 + * raise IOError("error while opening index `%s` " % filename ) + * else: + * self.index = bam_index_load(filename) # <<<<<<<<<<<<<< + * if self.index == NULL: + * raise IOError("error while opening index `%s` " % filename ) + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename); + + /* "/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_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL); + if (__pyx_t_8) { + + /* "/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 gettid( self, reference ): + */ + __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_L36:; + } + __pyx_L33:; + goto __pyx_L32; + } + __pyx_L32:; + + __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("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); + __Pyx_DECREF(__pyx_v_store); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":612 + * raise IOError("error while opening index `%s` " % filename ) + * + * def gettid( self, reference ): # <<<<<<<<<<<<<< + * ''' + * convert :term:`reference` name into numerical :term:`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; + char *__pyx_t_5; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("gettid"); + __Pyx_TraceCall("gettid", __pyx_f[0], 612); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":618 + * 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 ) + * + */ + __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 = 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 = 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 = 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 = 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 = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 %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 = 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 = 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 = 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 = 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) { + + /* "/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 %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 = 626; __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 = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":627 + * 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] # <<<<<<<<<<<<<< + * + * 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 = 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); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.getrname"); + __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":629 + * return self.samfile.header.target_name[tid] + * + * cdef char * _getrname( self, int tid ): # <<<<<<<<<<<<<< + * ''' + * convert numerical :term:`tid` into :term:`reference` name.''' + */ + +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; + PyObject *__pyx_t_5 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("_getrname"); + __Pyx_TraceCall("_getrname", __pyx_f[0], 629); + + /* "/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" ) # <<<<<<<<<<<<<< + * if not 0 <= tid < self.samfile.header.n_targets: + * raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) ) + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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 = 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 = 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 = 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 = 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 = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/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" ) + * 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_r = (__pyx_v_self->samfile->header->target_name[__pyx_v_tid]); + 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_5); + __Pyx_WriteUnraisable("csamtools.Samfile._getrname"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":637 + * return self.samfile.header.target_name[tid] + * + * def _parseRegion( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +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[] = "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; + 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; + PY_LONG_LONG __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + 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], 637); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[4] = {0,0,0,0}; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638 + * + * def _parseRegion( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639 + * def _parseRegion( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None ): + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None ): + * ''' + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641 + * start = None, + * end = None, + * region = None ): # <<<<<<<<<<<<<< + * ''' + * parse region information. + */ + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + 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), "_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]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638 + * + * def _parseRegion( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639 + * def _parseRegion( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None ): + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None ): + * ''' + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641 + * start = None, + * end = None, + * region = None ): # <<<<<<<<<<<<<< + * ''' + * parse region information. + */ + __pyx_v_region = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.Samfile._parseRegion"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_reference); + __pyx_v_parts = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":660 + * cdef long long rend + * + * rtid = -1 # <<<<<<<<<<<<<< + * rstart = 0 + * rend = max_pos + */ + __pyx_v_rtid = -1; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":661 + * + * rtid = -1 + * rstart = 0 # <<<<<<<<<<<<<< + * rend = max_pos + * if start != None: + */ + __pyx_v_rstart = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":662 + * rtid = -1 + * rstart = 0 + * rend = max_pos # <<<<<<<<<<<<<< + * if start != None: + * try: + */ + __pyx_v_rend = __pyx_v_9csamtools_max_pos; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":663 + * rstart = 0 + * rend = max_pos + * 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 = 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 = 663; __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/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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":669 + * raise ValueError( 'start out of range (%i)' % start ) + * + * if end != None: # <<<<<<<<<<<<<< + * try: + * rend = end + */ + __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) { + + /* "/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 = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_2) { + + /* "/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 = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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_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_6; + __pyx_t_6 = 0; + + /* "/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_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_6; + __pyx_t_6 = 0; + + /* "/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_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_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_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_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_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_L29; + } + __pyx_L29:; + + /* "/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_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 = 679; __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 = 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_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_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_L30; + } + __pyx_L30:; + goto __pyx_L28; + } + __pyx_L28:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L31; + } + __pyx_L31:; + + /* "/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 = 683; __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 = 683; __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); + __Pyx_GIVEREF(__pyx_v_reference); + __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_v_rtid = __pyx_t_4; + + /* "/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_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); + __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 = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L32; + } + __pyx_L32:; + + /* "/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_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_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_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_5 = 0; + __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 = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + 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_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_L33:; + + /* "/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_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_10); + if (__pyx_t_2) { + __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_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_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_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 = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L34; + } + __pyx_L34:; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * return 1, rtid, rstart, rend + */ + __pyx_t_2 = (0 <= __pyx_v_rend); + if (__pyx_t_2) { + __pyx_t_2 = (__pyx_v_rend <= __pyx_v_9csamtools_max_pos); + } + __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_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 = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + 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_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_L35:; + + /* "/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 # <<<<<<<<<<<<<< + * + * def seek( self, uint64_t offset, int where = 0): + */ + __Pyx_XDECREF(__pyx_r); + __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_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_7, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_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_7, 3, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_6 = 0; + __pyx_t_1 = 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_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("csamtools.Samfile._parseRegion"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_parts); + __Pyx_DECREF(__pyx_v_reference); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":691 + * return 1, rtid, rstart, rend + * + * def seek( self, uint64_t offset, int where = 0): # <<<<<<<<<<<<<< + * ''' + * move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`. + */ + +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[] = "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; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__offset,&__pyx_n_s__where,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("seek"); + __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}; + 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__offset); + 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__where); + 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), "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 = 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 = 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 = 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 = 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:; + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":698 + * if not self._isOpen(): + * 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_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam); + if (__pyx_t_4) { + + /* "/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 = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * 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 = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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("csamtools.Samfile.seek"); + __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":702 + * return bam_seek( self.samfile.x.bam, offset, where ) + * + * def tell( self ): # <<<<<<<<<<<<<< + * ''' + * return current file position + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +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; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("tell"); + __Pyx_TraceCall("tell", __pyx_f[0], 702); + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":708 + * 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_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam); + if (__pyx_t_4) { + + /* "/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 = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":711 + * raise NotImplementedError("seek only available in bam files") + * + * return bam_tell( self.samfile.x.bam ) # <<<<<<<<<<<<<< + * + * 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 = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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("csamtools.Samfile.tell"); + __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":713 + * return bam_tell( self.samfile.x.bam ) + * + * def fetch( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +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[] = "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; + PyObject *__pyx_v_end = 0; + PyObject *__pyx_v_region = 0; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_until_eof = 0; + int __pyx_v_rtid; + int __pyx_v_rstart; + int __pyx_v_rend; + int __pyx_v_has_coord; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + int __pyx_t_14; + 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], 713); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[6] = {0,0,0,0,0,0}; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * callback = None, + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * callback = None, + * until_eof = False ): + */ + values[3] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718 + * end = None, + * region = None, + * callback = None, # <<<<<<<<<<<<<< + * until_eof = False ): + * ''' + */ + values[4] = ((PyObject *)Py_None); + 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); + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__until_eof); + 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), "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]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + __pyx_v_callback = values[4]; + __pyx_v_until_eof = values[5]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * callback = None, + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * callback = None, + * until_eof = False ): + */ + __pyx_v_region = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718 + * end = None, + * region = None, + * callback = None, # <<<<<<<<<<<<<< + * until_eof = False ): + * ''' + */ + __pyx_v_callback = ((PyObject *)Py_None); + __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); + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 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:; + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + __Pyx_INCREF(__pyx_v_start); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start); + __Pyx_GIVEREF(__pyx_v_start); + __Pyx_INCREF(__pyx_v_end); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end); + __Pyx_GIVEREF(__pyx_v_end); + __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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_rtid = __pyx_t_9; + __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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_rstart = __pyx_t_9; + __pyx_v_rend = __pyx_t_8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":747 + * has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + * + * if self.isbam: # <<<<<<<<<<<<<< + * if not until_eof and not self._hasIndex() and not self.isremote: + * raise ValueError( "fetch called on bamfile without index" ) + */ + if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) { + + /* "/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 = 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 = 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 = 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 = 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) { + __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote); + __pyx_t_14 = __pyx_t_4; + } else { + __pyx_t_14 = __pyx_t_13; + } + __pyx_t_13 = __pyx_t_14; + } else { + __pyx_t_13 = __pyx_t_3; + } + if (__pyx_t_13) { + + /* "/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 = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __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 = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_13) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":752 + * + * if callback: + * if not has_coord: raise ValueError( "callback functionality requires a region/reference" ) # <<<<<<<<<<<<<< + * if not self._hasIndex(): raise ValueError( "no index available for fetch" ) + * return bam_fetch(self.samfile.x.bam, + */ + __pyx_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 = 752; __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_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 = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L10; + } + __pyx_L10:; + + /* "/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 = 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 = 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 = 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 = 753; __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_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 = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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, # <<<<<<<<<<<<<< + * self.index, + * rtid, + */ + __Pyx_XDECREF(__pyx_r); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":760 + * rend, + * 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 = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + goto __pyx_L9; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":762 + * fetch_callback ) + * else: + * if has_coord: # <<<<<<<<<<<<<< + * return IteratorRowRegion( self, rtid, rstart, rend ) + * else: + */ + if (__pyx_v_has_coord) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":763 + * else: + * if has_coord: + * return IteratorRowRegion( self, rtid, rstart, rend ) # <<<<<<<<<<<<<< + * else: + * 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_self); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __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 = 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; + __pyx_t_6 = 0; + goto __pyx_L0; + goto __pyx_L12; + } + /*else*/ { + + /* "/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 = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":766 + * else: + * if until_eof: + * return IteratorRowAll( self ) # <<<<<<<<<<<<<< + * else: + * 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 = 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 = 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; + __pyx_t_1 = 0; + goto __pyx_L0; + goto __pyx_L13; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":768 + * return IteratorRowAll( self ) + * else: + * return IteratorRowAllRefs(self) # <<<<<<<<<<<<<< + * else: + * # 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 = 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 = 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; + __pyx_t_6 = 0; + goto __pyx_L0; + } + __pyx_L13:; + } + __pyx_L12:; + } + __pyx_L9:; + goto __pyx_L7; + } + /*else*/ { + + /* "/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: # <<<<<<<<<<<<<< + * raise ValueError( "fetch called for samfile without header") + * + */ + __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0); + if (__pyx_t_3) { + + /* "/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 = 773; __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_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 = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L14; + } + __pyx_L14:; + + /* "/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 = 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 = 775; __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/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 = 776; __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_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 = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L15; + } + __pyx_L15:; + + /* "/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 = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + + /* "/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 = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L16; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":780 + * raise NotImplementedError( "callback not implemented yet" ) + * else: + * return IteratorRowAll( self ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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; + __pyx_t_6 = 0; + goto __pyx_L0; + } + __pyx_L16:; + } + __pyx_L7:; + + __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_7); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_AddTraceback("csamtools.Samfile.fetch"); + __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":782 + * return IteratorRowAll( self ) + * + * def mate( self, # <<<<<<<<<<<<<< + * AlignedRead read ): + * '''return the mate of :class:`AlignedRead` *read*. + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/ +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; + 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], 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;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":795 + * + * ''' + * cdef uint32_t flag = read._delegate.core.flag # <<<<<<<<<<<<<< + * + * if flag & BAM_FPAIRED == 0: + */ + __pyx_v_flag = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.flag; + + /* "/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 = ((__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:; + + /* "/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_1 = ((__pyx_v_flag & 8) != 0); + if (__pyx_t_1) { + + /* "/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_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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":804 + * cdef MateData mate_data + * + * mate_data.name = bam1_qname(read._delegate) # <<<<<<<<<<<<<< + * mate_data.mate = NULL + * # xor flags to get the other mate + */ + __pyx_v_mate_data.name = bam1_qname(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":805 + * + * mate_data.name = bam1_qname(read._delegate) + * mate_data.mate = NULL # <<<<<<<<<<<<<< + * # xor flags to get the other mate + * cdef int x = BAM_FREAD1 + BAM_FREAD2 + */ + __pyx_v_mate_data.mate = NULL; + + /* "/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 = ( flag ^ x) & x + * + */ + __pyx_v_x = 192; + + /* "/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 = ( flag ^ x) & x # <<<<<<<<<<<<<< + * + * bam_fetch(self.samfile.x.bam, + */ + __pyx_v_mate_data.flag = ((__pyx_v_flag ^ __pyx_v_x) & __pyx_v_x); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":816 + * read._delegate.core.mpos + 1, + * &mate_data, + * mate_callback ) # <<<<<<<<<<<<<< + * + * if mate_data.mate == NULL: + */ + 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":818 + * mate_callback ) + * + * if mate_data.mate == NULL: # <<<<<<<<<<<<<< + * raise ValueError( "mate not found" ) + * + */ + __pyx_t_1 = (__pyx_v_mate_data.mate == NULL); + if (__pyx_t_1) { + + /* "/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_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:; + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":822 + * + * cdef AlignedRead dest = AlignedRead.__new__(AlignedRead) + * dest._delegate = mate_data.mate # <<<<<<<<<<<<<< + * return dest + * + */ + __pyx_v_dest->_delegate = __pyx_v_mate_data.mate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":823 + * cdef AlignedRead dest = AlignedRead.__new__(AlignedRead) + * dest._delegate = mate_data.mate + * return dest # <<<<<<<<<<<<<< + * + * def count( self, + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_dest)); + __pyx_r = ((PyObject *)__pyx_v_dest); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.Samfile.mate"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_dest); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":825 + * return dest + * + * def count( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +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[] = "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; + PyObject *__pyx_v_end = 0; + PyObject *__pyx_v_region = 0; + PyObject *__pyx_v_until_eof = 0; + int __pyx_v_rtid; + int __pyx_v_rstart; + int __pyx_v_rend; + int __pyx_v_counter; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + int __pyx_t_13; + 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], 825); + 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/csamtools.pyx":826 + * + * def count( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827 + * def count( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * until_eof = False ): + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * until_eof = False ): + * '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)* + */ + values[3] = ((PyObject *)Py_None); + 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); + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__until_eof); + 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), "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]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + __pyx_v_until_eof = values[4]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826 + * + * def count( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827 + * def count( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * until_eof = False ): + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * until_eof = False ): + * '''*(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_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); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.Samfile.count"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_region); + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + __Pyx_INCREF(__pyx_v_start); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start); + __Pyx_GIVEREF(__pyx_v_start); + __Pyx_INCREF(__pyx_v_end); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end); + __Pyx_GIVEREF(__pyx_v_end); + __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 = 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; + 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_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 = 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 = 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 = 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); + __pyx_v_region = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_v_rtid = __pyx_t_8; + __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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_t_2 = 0; + __pyx_v_rtid = __pyx_t_10; + __pyx_v_rstart = __pyx_t_9; + __pyx_v_rend = __pyx_t_8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":849 + * + * cdef int counter + * counter = 0; # <<<<<<<<<<<<<< + * + * if self.isbam: + */ + __pyx_v_counter = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":851 + * counter = 0; + * + * if self.isbam: # <<<<<<<<<<<<<< + * if not until_eof and not self._hasIndex() and not self.isremote: + * raise ValueError( "fetch called on bamfile without index" ) + */ + if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) { + + /* "/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 = 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 = 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 = 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 = 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) { + __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote); + __pyx_t_13 = __pyx_t_4; + } else { + __pyx_t_13 = __pyx_t_12; + } + __pyx_t_12 = __pyx_t_13; + } else { + __pyx_t_12 = __pyx_t_3; + } + if (__pyx_t_12) { + + /* "/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 = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __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 = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = (!__pyx_t_12); + if (__pyx_t_3) { + + /* "/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 = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __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 = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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 = 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 = 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 = 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 = 857; __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_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 = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L10; + } + __pyx_L10:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":864 + * rend, + * &counter, + * count_callback ) # <<<<<<<<<<<<<< + * return counter + * else: + */ + 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":865 + * &counter, + * count_callback ) + * return counter # <<<<<<<<<<<<<< + * else: + * 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 = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + goto __pyx_L7; + } + /*else*/ { + + /* "/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 = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __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 = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L7:; + + __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_7); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("csamtools.Samfile.count"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_region); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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, + * start = None, + */ + +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[] = "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; + PyObject *__pyx_v_end = 0; + PyObject *__pyx_v_region = 0; + PyObject *__pyx_v_callback = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_v_rtid; + int __pyx_v_rstart; + int __pyx_v_rend; + int __pyx_v_has_coord; + bam_plbuf_t *__pyx_v_buf; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + 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], 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}; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870 + * + * def pileup( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871 + * def pileup( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * callback = None, + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * callback = None, + * **kwargs ): + */ + values[3] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874 + * end = None, + * region = None, + * callback = None, # <<<<<<<<<<<<<< + * **kwargs ): + * ''' + */ + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback); + if (value) { values[4] = value; kw_args--; } + } + } + 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 = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_reference = values[0]; + __pyx_v_start = values[1]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + __pyx_v_callback = values[4]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870 + * + * def pileup( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871 + * def pileup( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * callback = None, + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * callback = None, + * **kwargs ): + */ + __pyx_v_region = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874 + * end = None, + * region = None, + * callback = None, # <<<<<<<<<<<<<< + * **kwargs ): + * ''' + */ + __pyx_v_callback = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_AddTraceback("csamtools.Samfile.pileup"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + __Pyx_INCREF(__pyx_v_start); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start); + __Pyx_GIVEREF(__pyx_v_start); + __Pyx_INCREF(__pyx_v_end); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end); + __Pyx_GIVEREF(__pyx_v_end); + __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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_rtid = __pyx_t_9; + __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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_rstart = __pyx_t_9; + __pyx_v_rend = __pyx_t_8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":926 + * has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + * + * if self.isbam: # <<<<<<<<<<<<<< + * if not self._hasIndex(): raise ValueError( "no index available for pileup" ) + * + */ + if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) { + + /* "/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 = 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 = 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 = 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 = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __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 = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":930 + * + * if callback: + * if not has_coord: raise ValueError( "callback functionality requires a region/reference" ) # <<<<<<<<<<<<<< + * + * buf = bam_plbuf_init( pileup_callback, callback ) + */ + __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 = 930; __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_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 = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L10; + } + __pyx_L10:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":932 + * if not has_coord: raise ValueError( "callback functionality requires a region/reference" ) + * + * buf = bam_plbuf_init( pileup_callback, callback ) # <<<<<<<<<<<<<< + * bam_fetch(self.samfile.x.bam, + * self.index, rtid, rstart, rend, + */ + __pyx_v_buf = bam_plbuf_init(((bam_pileup_f)__pyx_f_9csamtools_pileup_callback), ((void *)__pyx_v_callback)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":935 + * bam_fetch(self.samfile.x.bam, + * self.index, rtid, rstart, rend, + * buf, pileup_fetch_callback ) # <<<<<<<<<<<<<< + * + * # finalize pileup + */ + 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":938 + * + * # finalize pileup + * bam_plbuf_push( NULL, buf) # <<<<<<<<<<<<<< + * bam_plbuf_destroy(buf) + * else: + */ + bam_plbuf_push(NULL, __pyx_v_buf); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":939 + * # finalize pileup + * bam_plbuf_push( NULL, buf) + * bam_plbuf_destroy(buf) # <<<<<<<<<<<<<< + * else: + * if has_coord: + */ + bam_plbuf_destroy(__pyx_v_buf); + goto __pyx_L9; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":941 + * bam_plbuf_destroy(buf) + * else: + * if has_coord: # <<<<<<<<<<<<<< + * return IteratorColumnRegion( self, + * tid = rtid, + */ + if (__pyx_v_has_coord) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":942 + * else: + * if has_coord: + * return IteratorColumnRegion( self, # <<<<<<<<<<<<<< + * tid = rtid, + * start = rstart, + */ + __Pyx_XDECREF(__pyx_r); + __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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + + /* "/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 = 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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 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 = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 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; + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L0; + goto __pyx_L11; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":948 + * **kwargs ) + * else: + * return IteratorColumnAllRefs(self, **kwargs ) # <<<<<<<<<<<<<< + * + * else: + */ + __Pyx_XDECREF(__pyx_r); + __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 = 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; + __pyx_t_5 = 0; + goto __pyx_L0; + } + __pyx_L11:; + } + __pyx_L9:; + goto __pyx_L7; + } + /*else*/ { + + /* "/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 = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __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 = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L7:; + + __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_7); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_AddTraceback("csamtools.Samfile.pileup"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":953 + * raise NotImplementedError( "pileup of samfiles not implemented yet" ) + * + * def close( self ): # <<<<<<<<<<<<<< + * ''' + * closes the :class:`pysam.Samfile`.''' + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +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], 953); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":956 + * ''' + * closes the :class:`pysam.Samfile`.''' + * if self.samfile != NULL: # <<<<<<<<<<<<<< + * samclose( self.samfile ) + * bam_index_destroy(self.index); + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":957 + * closes the :class:`pysam.Samfile`.''' + * if self.samfile != NULL: + * samclose( self.samfile ) # <<<<<<<<<<<<<< + * bam_index_destroy(self.index); + * self.samfile = NULL + */ + samclose(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":958 + * if self.samfile != NULL: + * samclose( self.samfile ) + * bam_index_destroy(self.index); # <<<<<<<<<<<<<< + * self.samfile = NULL + * + */ + bam_index_destroy(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":959 + * samclose( self.samfile ) + * bam_index_destroy(self.index); + * self.samfile = NULL # <<<<<<<<<<<<<< + * + * def __dealloc__( self ): + */ + ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL; + goto __pyx_L5; + } + __pyx_L5:; + + __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":961 + * self.samfile = NULL + * + * def __dealloc__( self ): # <<<<<<<<<<<<<< + * # remember: dealloc cannot call other methods + * # note: no doc string + */ + +static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) { + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 961); + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":966 + * # note: __del__ is not called. + * self.close() + * bam_destroy1(self.b) # <<<<<<<<<<<<<< + * if self._filename != NULL: free( self._filename ) + * + */ + bam_destroy1(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":967 + * self.close() + * bam_destroy1(self.b) + * if self._filename != NULL: free( self._filename ) # <<<<<<<<<<<<<< + * + * 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) { + free(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename); + goto __pyx_L5; + } + __pyx_L5:; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.__dealloc__"); + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/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 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; + 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], 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; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":975 + * returns the number of bytes written. + * ''' + * if not self._isOpen(): # <<<<<<<<<<<<<< + * return 0 + * + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __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 = 975; __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 = 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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":976 + * ''' + * if not self._isOpen(): + * return 0 # <<<<<<<<<<<<<< + * + * return samwrite( self.samfile, read._delegate ) + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/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(((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; + 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.Samfile.write"); + __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":980 + * return samwrite( self.samfile, read._delegate ) + * + * def __enter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +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], 980); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":981 + * + * def __enter__(self): + * return self # <<<<<<<<<<<<<< + * + * def __exit__(self, exc_type, exc_value, traceback): + */ + __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":983 + * return self + * + * def __exit__(self, exc_type, exc_value, traceback): # <<<<<<<<<<<<<< + * self.close() + * return False + */ + +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; + PyObject *__pyx_v_traceback = 0; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + 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], 983); + 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__exc_type); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + 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 = 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 = 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 = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_exc_type = values[0]; + __pyx_v_exc_value = values[1]; + __pyx_v_traceback = values[2]; + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + __pyx_v_exc_type = PyTuple_GET_ITEM(__pyx_args, 0); + __pyx_v_exc_value = PyTuple_GET_ITEM(__pyx_args, 1); + __pyx_v_traceback = PyTuple_GET_ITEM(__pyx_args, 2); + } + 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 = 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:; + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":985 + * def __exit__(self, exc_type, exc_value, traceback): + * self.close() + * return False # <<<<<<<<<<<<<< + * + * ############################################################### + */ + __Pyx_XDECREF(__pyx_r); + __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; + 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.__exit__"); + __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":994 + * property filename: + * '''number of :term:`filename` associated with this object.''' + * def __get__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * return self._filename + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 994); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 # <<<<<<<<<<<<<< + * + * 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 = 996; __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_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.filename.__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":1000 + * property nreferences: + * '''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 + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 1000); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 # <<<<<<<<<<<<<< + * + * 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 = 1002; __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.nreferences.__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":1006 + * property references: + * """tuple with the names of :term:`reference` sequences.""" + * def __get__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * t = [] + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_t; + long __pyx_v_x; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int32_t __pyx_t_5; + int __pyx_t_6; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 1006); + __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 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; + + /* "/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: # <<<<<<<<<<<<<< + * t.append( self.samfile.header.target_name[x] ) + * return tuple(t) + */ + __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++) { + + /* "/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] ) # <<<<<<<<<<<<<< + * return tuple(t) + * + */ + if (unlikely(__pyx_v_t == Py_None)) { + 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 = 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 = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + } + + /* "/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) # <<<<<<<<<<<<<< + * + * property lengths: + */ + __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 = 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 = 1011; __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_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.references.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_t); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1017 + * :attr:`pysam.Samfile.references` + * """ + * def __get__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * t = [] + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_t; + long __pyx_v_x; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int32_t __pyx_t_5; + int __pyx_t_6; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 1017); + __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 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; + + /* "/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: # <<<<<<<<<<<<<< + * t.append( self.samfile.header.target_len[x] ) + * return tuple(t) + */ + __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++) { + + /* "/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] ) # <<<<<<<<<<<<<< + * return tuple(t) + * + */ + if (unlikely(__pyx_v_t == Py_None)) { + 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 = 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 = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "/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) # <<<<<<<<<<<<<< + * + * property text: + */ + __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 = 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 = 1022; __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_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.lengths.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_t); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1026 + * property text: + * '''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) + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 1026); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 1028; __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.text.__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":1034 + * a two-level dictionary. + * ''' + * def __get__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_result; + PyObject *__pyx_v_t; + PyObject *__pyx_v_line; + PyObject *__pyx_v_fields; + PyObject *__pyx_v_record; + PyObject *__pyx_v_x; + PyObject *__pyx_v_field; + PyObject *__pyx_v_key; + PyObject *__pyx_v_value; + 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; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __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); + __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_record = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_x = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + __pyx_v_field = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_key = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_value = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1039 + * result = {} + * + * if self.samfile.header.text != NULL: # <<<<<<<<<<<<<< + * # convert to python string (note: call self.text to create 0-terminated string) + * t = self.text + */ + __pyx_t_4 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text != NULL); + if (__pyx_t_4) { + + /* "/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 = 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; + + /* "/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 = 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 = 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 = 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 = 1042; __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_5 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; + } else if (likely(PyTuple_CheckExact(__pyx_t_2))) { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; + } else { + __pyx_t_6 = PyIter_Next(__pyx_t_2); + if (!__pyx_t_6) { + 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); + } + __Pyx_DECREF(__pyx_v_line); + __pyx_v_line = __pyx_t_6; + __pyx_t_6 = 0; + + /* "/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 = 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 = 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 = 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) { + goto __pyx_L7_continue; + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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 # <<<<<<<<<<<<<< + * fields = line[1:].split("\t") + * 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 = 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 = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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_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 = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_v_fields); + __pyx_v_fields = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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 = 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; + + /* "/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) # <<<<<<<<<<<<<< + * + * # 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_record); + __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_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 = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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 = 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 = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1051 + * # treat comments + * if record == "CO": + * if record not in result: result[record] = [] # <<<<<<<<<<<<<< + * result[record].append( "\t".join( fields[1:] ) ) + * continue + */ + if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) { + __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 = 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 = 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 = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1053 + * if record not in result: result[record] = [] + * result[record].append( "\t".join( fields[1:] ) ) + * continue # <<<<<<<<<<<<<< + * + * # the following is clumsy as generators do not work? + */ + goto __pyx_L7_continue; + goto __pyx_L10; + } + __pyx_L10:; + + /* "/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 = 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; + + /* "/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) + * # 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 = 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 = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_6))) { + if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break; + __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++; + } else if (likely(PyTuple_CheckExact(__pyx_t_6))) { + if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_6)) break; + __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++; + } else { + __pyx_t_8 = PyIter_Next(__pyx_t_6); + if (!__pyx_t_8) { + 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); + } + __Pyx_DECREF(__pyx_v_field); + __pyx_v_field = __pyx_t_8; + __pyx_t_8 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1058 + * x = {} + * for field in fields[1:]: + * key, value = field.split(":",1) # <<<<<<<<<<<<<< + * # 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 = 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 = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __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 = 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; + if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) { + PyObject* tuple = __pyx_t_1; + __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7); + __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_key); + __pyx_v_key = __pyx_t_7; + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_v_value); + __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 = 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 = 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 = 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 = 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; + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_v_value); + __pyx_v_value = __pyx_t_8; + __pyx_t_8 = 0; + } + + /* "/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 = 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 = 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 = ((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) { + + /* "/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 = __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_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 = 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); + __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_DECREF(__pyx_t_1); __pyx_t_1 = 0; + 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; + } + + /* "/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) ) + */ + 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 = 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; + + /* "/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 = 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 = 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 = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __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_4) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1069 + * + * if VALID_HEADER_TYPES[record] == dict: + * if record in result: # <<<<<<<<<<<<<< + * raise ValueError( "multiple '%s' lines are not permitted" % record ) + * result[record] = x + */ + if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else { + __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_4) { + + /* "/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_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 = 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 = 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 = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L16; + } + __pyx_L16:; + + /* "/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 = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L15; + } + + /* "/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 = 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 = 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 = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __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_4) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1073 + * result[record] = x + * elif VALID_HEADER_TYPES[record] == list: + * if record not in result: result[record] = [] # <<<<<<<<<<<<<< + * result[record].append( x ) + * + */ + if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else { + __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_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 = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + goto __pyx_L17; + } + __pyx_L17:; + + /* "/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 = 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 = 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; + goto __pyx_L15; + } + __pyx_L15:; + __pyx_L7_continue:; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1076 + * result[record].append( x ) + * + * return result # <<<<<<<<<<<<<< + * + * def _buildLine( self, fields, record ): + */ + __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_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("csamtools.Samfile.header.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_result); + __Pyx_DECREF(__pyx_v_t); + __Pyx_DECREF(__pyx_v_line); + __Pyx_DECREF(__pyx_v_fields); + __Pyx_DECREF(__pyx_v_record); + __Pyx_DECREF(__pyx_v_x); + __Pyx_DECREF(__pyx_v_field); + __Pyx_DECREF(__pyx_v_key); + __Pyx_DECREF(__pyx_v_value); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1078 + * return result + * + * def _buildLine( self, fields, record ): # <<<<<<<<<<<<<< + * '''build 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); /*proto*/ +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; + PyObject *__pyx_v_line; + PyObject *__pyx_v_key; + 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; + 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], 1078); + 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__fields); + 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("_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 = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_fields = values[0]; + __pyx_v_record = values[1]; + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + __pyx_v_fields = 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("_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(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_line = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + __pyx_v_key = Py_None; __Pyx_INCREF(Py_None); + + /* "/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_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 = 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)); + __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_line)); + __pyx_v_line = __pyx_t_2; + __pyx_t_2 = 0; + + /* "/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 = 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 = 1083; __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/csamtools.pyx":1084 + * line = ["@%s" % record ] + * if record == "CO": + * line.append( fields ) # <<<<<<<<<<<<<< + * else: + * # 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 = 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 = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + /*else*/ { + + /* "/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 = 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 = 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 = 1087; __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_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 = 1087; __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":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]))) + * # 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 = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_3) { + + /* "/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]))) # <<<<<<<<<<<<<< + * # 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 = 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_key); + 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_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 = 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:; + + /* "/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 = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_6, 0, ((PyObject *)__pyx_v_line)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_line)); + __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_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); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("csamtools.Samfile._buildLine"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_line); + __Pyx_DECREF(__pyx_v_key); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1097 + * return "\t".join( line ) + * + * cdef bam_header_t * _buildHeader( self, new_header ): # <<<<<<<<<<<<<< + * '''return a new header built from a dictionary in *new_header*. + * + */ + +static bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, PyObject *__pyx_v_new_header) { + PyObject *__pyx_v_lines; + bam_header_t *__pyx_v_dest; + PyObject *__pyx_v_record; + PyObject *__pyx_v_ttype; + PyObject *__pyx_v_data; + PyObject *__pyx_v_fields; + PyObject *__pyx_v_text; + PyObject *__pyx_v_seqs; + long __pyx_v_x; + PyObject *__pyx_v_seqname; + PyObject *__pyx_v_seqlen; + bam_header_t *__pyx_r; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + char *__pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int32_t __pyx_t_12; + uint32_t __pyx_t_13; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("_buildHeader"); + __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); + __pyx_v_data = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_text = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_seqs = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + __pyx_v_seqname = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_seqlen = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1110 + * cdef bam_header_t * dest + * + * dest = bam_header_init() # <<<<<<<<<<<<<< + * + * for record in VALID_HEADERS: + */ + __pyx_v_dest = bam_header_init(); + + /* "/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 = 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 = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + } else if (likely(PyTuple_CheckExact(__pyx_t_3))) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + } else { + __pyx_t_1 = PyIter_Next(__pyx_t_3); + if (!__pyx_t_1) { + 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); + } + __Pyx_DECREF(__pyx_v_record); + __pyx_v_record = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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 = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { + + /* "/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 = 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 = 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; + + /* "/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 = 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; + + /* "/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 = 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 = 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 = 1116; __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/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_record); + __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_data))); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)Py_TYPE(__pyx_v_data))); + __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_data))); + __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_t_1))); + 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_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 = 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 = 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 = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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 = 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 = 1118; __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/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 ) ) # <<<<<<<<<<<<<< + * else: + * 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_data); + __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 = 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 = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L7; + } + /*else*/ { + + /* "/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 = 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 = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_5))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else if (likely(PyTuple_CheckExact(__pyx_t_5))) { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; + } else { + __pyx_t_6 = PyIter_Next(__pyx_t_5); + if (!__pyx_t_6) { + 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); + } + __Pyx_DECREF(__pyx_v_fields); + __pyx_v_fields = __pyx_t_6; + __pyx_t_6 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1122 + * else: + * for fields in new_header[record]: + * lines.append( self._buildLine( fields, record ) ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_fields); + __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 = 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 = 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; + } + __pyx_L7:; + goto __pyx_L5; + } + __pyx_L5:; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "/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 = 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 = 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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1125 + * + * text = "\n".join(lines) + "\n" + * if dest.text != NULL: free( dest.text ) # <<<<<<<<<<<<<< + * dest.text = calloc( len(text), sizeof(char)) + * dest.l_text = len(text) + */ + __pyx_t_4 = (__pyx_v_dest->text != NULL); + if (__pyx_t_4) { + free(__pyx_v_dest->text); + goto __pyx_L10; + } + __pyx_L10:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1126 + * text = "\n".join(lines) + "\n" + * if dest.text != NULL: free( dest.text ) + * dest.text = 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 = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_dest->text = ((char *)calloc(__pyx_t_2, (sizeof(char)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1127 + * if dest.text != NULL: free( dest.text ) + * dest.text = 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 = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_dest->l_text = __pyx_t_2; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1128 + * dest.text = 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 = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + strncpy(__pyx_v_dest->text, __pyx_t_10, __pyx_v_dest->l_text); + + /* "/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 = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { + + /* "/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 = 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; + + /* "/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 = 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 = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_9))) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_9)) break; + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; + } else if (likely(PyTuple_CheckExact(__pyx_t_9))) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_9)) break; + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; + } else { + __pyx_t_5 = PyIter_Next(__pyx_t_9); + if (!__pyx_t_5) { + 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); + } + __Pyx_DECREF(__pyx_v_fields); + __pyx_v_fields = __pyx_t_5; + __pyx_t_5 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1134 + * seqs = [] + * for fields in new_header["SQ"]: + * try: # <<<<<<<<<<<<<< + * seqs.append( (fields["SN"], fields["LN"] ) ) + * except KeyError: + */ + { + 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":1135 + * for fields in new_header["SQ"]: + * try: + * seqs.append( (fields["SN"], fields["LN"] ) ) # <<<<<<<<<<<<<< + * except KeyError: + * 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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); + __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 = 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; + __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0; + __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0; + goto __pyx_L21_try_end; + __pyx_L14_error:; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1136 + * try: + * seqs.append( (fields["SN"], fields["LN"] ) ) + * except KeyError: # <<<<<<<<<<<<<< + * raise KeyError( "incomplete sequence information in '%s'" % str(fields)) + * + */ + __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 = 1136; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_5); + + /* "/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 = 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 = 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_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 = 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 = 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 = 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; + goto __pyx_L15_exception_handled; + } + __pyx_L16_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_L15_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_L21_try_end:; + } + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1139 + * raise KeyError( "incomplete sequence information in '%s'" % str(fields)) + * + * dest.n_targets = len(seqs) # <<<<<<<<<<<<<< + * dest.target_name = calloc( dest.n_targets, sizeof(char*) ) + * dest.target_len = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1140 + * + * dest.n_targets = len(seqs) + * dest.target_name = calloc( dest.n_targets, sizeof(char*) ) # <<<<<<<<<<<<<< + * dest.target_len = calloc( dest.n_targets, sizeof(uint32_t) ) + * + */ + __pyx_v_dest->target_name = ((char **)calloc(__pyx_v_dest->n_targets, (sizeof(char *)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1141 + * dest.n_targets = len(seqs) + * dest.target_name = calloc( dest.n_targets, sizeof(char*) ) + * dest.target_len = calloc( dest.n_targets, sizeof(uint32_t) ) # <<<<<<<<<<<<<< + * + * for x from 0 <= x < dest.n_targets: + */ + __pyx_v_dest->target_len = ((uint32_t *)calloc(__pyx_v_dest->n_targets, (sizeof(uint32_t)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1143 + * dest.target_len = calloc( dest.n_targets, sizeof(uint32_t) ) + * + * for x from 0 <= x < dest.n_targets: # <<<<<<<<<<<<<< + * seqname, seqlen = seqs[x] + * dest.target_name[x] = calloc( len( seqname ) + 1, sizeof(char) ) + */ + __pyx_t_12 = __pyx_v_dest->n_targets; + for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_12; __pyx_v_x++) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1144 + * + * for x from 0 <= x < dest.n_targets: + * seqname, seqlen = seqs[x] # <<<<<<<<<<<<<< + * dest.target_name[x] = 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 = 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; + __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5); + __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_v_seqname); + __pyx_v_seqname = __pyx_t_5; + __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_v_seqlen); + __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 = 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 = 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 = 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 = 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; + __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_v_seqlen); + __pyx_v_seqlen = __pyx_t_3; + __pyx_t_3 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1145 + * for x from 0 <= x < dest.n_targets: + * seqname, seqlen = seqs[x] + * dest.target_name[x] = 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 = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + (__pyx_v_dest->target_name[__pyx_v_x]) = ((char *)calloc((__pyx_t_2 + 1), (sizeof(char)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1146 + * seqname, seqlen = seqs[x] + * dest.target_name[x] = 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 = 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)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1147 + * dest.target_name[x] = 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 = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + (__pyx_v_dest->target_len[__pyx_v_x]) = __pyx_t_13; + } + goto __pyx_L11; + } + __pyx_L11:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1149 + * dest.target_len[x] = seqlen + * + * return dest # <<<<<<<<<<<<<< + * + * ############################################################### + */ + __pyx_r = __pyx_v_dest; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_WriteUnraisable("csamtools.Samfile._buildHeader"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_lines); + __Pyx_DECREF(__pyx_v_record); + __Pyx_DECREF(__pyx_v_ttype); + __Pyx_DECREF(__pyx_v_data); + __Pyx_DECREF(__pyx_v_fields); + __Pyx_DECREF(__pyx_v_text); + __Pyx_DECREF(__pyx_v_seqs); + __Pyx_DECREF(__pyx_v_seqname); + __Pyx_DECREF(__pyx_v_seqlen); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1159 + * ## Possible solutions: deprecate or open new file handle + * ############################################################### + * def __iter__(self): # <<<<<<<<<<<<<< + * if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + * return self + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__iter__"); + __Pyx_TraceCall("__iter__", __pyx_f[0], 1159); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 # <<<<<<<<<<<<<< + * + * cdef bam1_t * getCurrent( 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); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.Samfile.__iter__"); + __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":1163 + * return self + * + * cdef bam1_t * getCurrent( self ): # <<<<<<<<<<<<<< + * return self.b + * + */ + +static bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self) { + bam1_t *__pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("getCurrent"); + __Pyx_TraceCall("getCurrent", __pyx_f[0], 1163); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1164 + * + * cdef bam1_t * getCurrent( self ): + * return self.b # <<<<<<<<<<<<<< + * + * cdef int cnext(self): + */ + __pyx_r = __pyx_v_self->b; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1166 + * return self.b + * + * cdef int cnext(self): # <<<<<<<<<<<<<< + * ''' + * cversion of iterator. Used by :class:`pysam.Samfile.IteratorColumn`. + */ + +static int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self) { + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("cnext"); + __Pyx_TraceCall("cnext", __pyx_f[0], 1166); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1171 + * ''' + * cdef int ret + * return samread(self.samfile, self.b) # <<<<<<<<<<<<<< + * + * def __next__(self): + */ + __pyx_r = samread(__pyx_v_self->samfile, __pyx_v_self->b); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1173 + * return samread(self.samfile, self.b) + * + * def __next__(self): # <<<<<<<<<<<<<< + * """ + * python version of next(). + */ + +static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_7Samfile___next__[] = "\n python version of next().\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_7Samfile___next__; +static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) { + int __pyx_v_ret; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1173); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1178 + * """ + * cdef int ret + * ret = samread(self.samfile, self.b) # <<<<<<<<<<<<<< + * if (ret > 0): + * return makeAlignedRead( self.b ) + */ + __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1179 + * cdef int ret + * ret = samread(self.samfile, self.b) + * if (ret > 0): # <<<<<<<<<<<<<< + * return makeAlignedRead( self.b ) + * else: + */ + __pyx_t_1 = (__pyx_v_ret > 0); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1180 + * ret = samread(self.samfile, self.b) + * if (ret > 0): + * return makeAlignedRead( self.b ) # <<<<<<<<<<<<<< + * else: + * 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 = 1180; __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; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1182 + * return makeAlignedRead( self.b ) + * else: + * raise StopIteration # <<<<<<<<<<<<<< + * + * ##------------------------------------------------------------------- + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __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_AddTraceback("csamtools.Samfile.__next__"); + __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":1234 + * cdef int owns_samfile + * + * def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ): # <<<<<<<<<<<<<< + * + * if not samfile._isOpen(): + */ + +static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0; + int __pyx_v_tid; + int __pyx_v_beg; + int __pyx_v_end; + 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__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], 1234); + 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__samfile); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + 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 = 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 = 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 = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen); + 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), "__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 = 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 = 1234; __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 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 = 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 = 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; + } + } + 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 = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.IteratorRowRegion.__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 = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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 = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1244 + * # makes sure that samfile stays alive as long as the + * # iterator is alive + * self.samfile = samfile # <<<<<<<<<<<<<< + * + * if samfile.isbam: mode = "rb" + */ + __Pyx_INCREF(((PyObject *)__pyx_v_samfile)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile)); + __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile); + __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile)); + ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile = __pyx_v_samfile; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1246 + * self.samfile = samfile + * + * if samfile.isbam: mode = "rb" # <<<<<<<<<<<<<< + * else: mode = "r" + * + */ + 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_L8; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1247 + * + * if samfile.isbam: mode = "rb" + * else: mode = "r" # <<<<<<<<<<<<<< + * + * # reopen the file - note that this makes the iterator + */ + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + __Pyx_DECREF(__pyx_v_mode); + __pyx_v_mode = ((PyObject *)__pyx_n_s__r); + } + __pyx_L8:; + + /* "/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: # <<<<<<<<<<<<<< + * store = StderrStore() + * self.fp = samopen( samfile._filename, mode, NULL ) + */ + if (__pyx_v_reopen) { + + /* "/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 = 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 = 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; + + /* "/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 = 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); + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1255 + * 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_IteratorRowRegion *)__pyx_v_self)->fp != NULL))) { + PyErr_SetNone(PyExc_AssertionError); + {__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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1261 + * self.owns_samfile = False + * + * self.retval = 0 # <<<<<<<<<<<<<< + * + * self.iter = bam_iter_query(self.samfile.index, + */ + ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1263 + * self.retval = 0 + * + * self.iter = bam_iter_query(self.samfile.index, # <<<<<<<<<<<<<< + * tid, + * beg, + */ + ((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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1267 + * beg, + * end) + * self.b = bam_init1() # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b = bam_init1(); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IteratorRowRegion.__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":1269 + * self.b = bam_init1() + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__iter__"); + __Pyx_TraceCall("__iter__", __pyx_f[0], 1269); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1270 + * + * def __iter__(self): + * return self # <<<<<<<<<<<<<< + * + * cdef bam1_t * getCurrent( 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":1272 + * return self + * + * cdef bam1_t * getCurrent( self ): # <<<<<<<<<<<<<< + * return self.b + * + */ + +static bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_obj_9csamtools_IteratorRowRegion *__pyx_v_self) { + bam1_t *__pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("getCurrent"); + __Pyx_TraceCall("getCurrent", __pyx_f[0], 1272); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1273 + * + * cdef bam1_t * getCurrent( self ): + * return self.b # <<<<<<<<<<<<<< + * + * cdef int cnext(self): + */ + __pyx_r = __pyx_v_self->b; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1275 + * return self.b + * + * cdef int cnext(self): # <<<<<<<<<<<<<< + * '''cversion of iterator. Used by IteratorColumn''' + * self.retval = bam_iter_read( self.fp.x.bam, + */ + +static int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamtools_IteratorRowRegion *__pyx_v_self) { + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("cnext"); + __Pyx_TraceCall("cnext", __pyx_f[0], 1275); + + /* "/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, # <<<<<<<<<<<<<< + * self.iter, + * self.b) + */ + __pyx_v_self->retval = bam_iter_read(__pyx_v_self->fp->x.bam, __pyx_v_self->iter, __pyx_v_self->b); + + __pyx_r = 0; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1281 + * self.b) + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * """ + */ + +static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_17IteratorRowRegion___next__[] = "python version of next().\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__; +static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1281); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1284 + * """python version of next(). + * """ + * self.cnext() # <<<<<<<<<<<<<< + * if self.retval < 0: raise StopIteration + * return makeAlignedRead( self.b ) + */ + ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1285 + * """ + * self.cnext() + * if self.retval < 0: raise StopIteration # <<<<<<<<<<<<<< + * return makeAlignedRead( self.b ) + * + */ + __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 = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1286 + * self.cnext() + * if self.retval < 0: raise StopIteration + * return makeAlignedRead( self.b ) # <<<<<<<<<<<<<< + * + * 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 = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_2); + __Pyx_AddTraceback("csamtools.IteratorRowRegion.__next__"); + __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":1288 + * return makeAlignedRead( self.b ) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * bam_destroy1(self.b) + * 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], 1288); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1289 + * + * def __dealloc__(self): + * bam_destroy1(self.b) # <<<<<<<<<<<<<< + * if self.owns_samfile: samclose( self.fp ) + * + */ + bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1290 + * def __dealloc__(self): + * bam_destroy1(self.b) + * if self.owns_samfile: samclose( self.fp ) # <<<<<<<<<<<<<< + * + * cdef class IteratorRowAll(IteratorRow): + */ + 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(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1307 + * cdef int owns_samfile + * + * def __cinit__(self, Samfile samfile, int reopen = True ): # <<<<<<<<<<<<<< + * + * if not samfile._isOpen(): + */ + +static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(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; + int __pyx_t_3; + int __pyx_t_4; + char *__pyx_t_5; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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}; + 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__samfile); + 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__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), "__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 = 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 = 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; + } + } + 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 = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.IteratorRowAll.__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 = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1312 + * raise ValueError( "I/O operation on closed file" ) + * + * if samfile.isbam: mode = "rb" # <<<<<<<<<<<<<< + * else: mode = "r" + * + */ + 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_L7; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1313 + * + * if samfile.isbam: mode = "rb" + * else: mode = "r" # <<<<<<<<<<<<<< + * + * # reopen the file to avoid iterator conflict + */ + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + __Pyx_DECREF(__pyx_v_mode); + __pyx_v_mode = ((PyObject *)__pyx_n_s__r); + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1316 + * + * # reopen the file to avoid iterator conflict + * if reopen: # <<<<<<<<<<<<<< + * store = StderrStore() + * self.fp = samopen( samfile._filename, mode, NULL ) + */ + if (__pyx_v_reopen) { + + /* "/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 = 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 = 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; + + /* "/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 = 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); + + /* "/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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1320 + * 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_IteratorRowAll *)__pyx_v_self)->fp != NULL))) { + PyErr_SetNone(PyExc_AssertionError); + {__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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1327 + * + * # allocate memory for alignment + * self.b = calloc(1, sizeof(bam1_t)) # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t)))); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IteratorRowAll.__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":1329 + * self.b = calloc(1, sizeof(bam1_t)) + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__iter__"); + __Pyx_TraceCall("__iter__", __pyx_f[0], 1329); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1330 + * + * def __iter__(self): + * return self # <<<<<<<<<<<<<< + * + * cdef bam1_t * getCurrent( 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":1332 + * return self + * + * cdef bam1_t * getCurrent( self ): # <<<<<<<<<<<<<< + * return self.b + * + */ + +static bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_9csamtools_IteratorRowAll *__pyx_v_self) { + bam1_t *__pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("getCurrent"); + __Pyx_TraceCall("getCurrent", __pyx_f[0], 1332); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1333 + * + * cdef bam1_t * getCurrent( self ): + * return self.b # <<<<<<<<<<<<<< + * + * cdef int cnext(self): + */ + __pyx_r = __pyx_v_self->b; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1335 + * return self.b + * + * cdef int cnext(self): # <<<<<<<<<<<<<< + * '''cversion of iterator. Used by IteratorColumn''' + * cdef int ret + */ + +static int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtools_IteratorRowAll *__pyx_v_self) { + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("cnext"); + __Pyx_TraceCall("cnext", __pyx_f[0], 1335); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1338 + * '''cversion of iterator. Used by IteratorColumn''' + * cdef int ret + * return samread(self.fp, self.b) # <<<<<<<<<<<<<< + * + * def __next__(self): + */ + __pyx_r = samread(__pyx_v_self->fp, __pyx_v_self->b); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1340 + * return samread(self.fp, self.b) + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * + */ + +static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_14IteratorRowAll___next__[] = "python version of next().\n\n pyrex uses this non-standard name instead of next()\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__; +static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self) { + int __pyx_v_ret; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1340); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1346 + * """ + * cdef int ret + * ret = samread(self.fp, self.b) # <<<<<<<<<<<<<< + * if (ret > 0): + * return makeAlignedRead( self.b ) + */ + __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp, ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1347 + * cdef int ret + * ret = samread(self.fp, self.b) + * if (ret > 0): # <<<<<<<<<<<<<< + * return makeAlignedRead( self.b ) + * else: + */ + __pyx_t_1 = (__pyx_v_ret > 0); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1348 + * ret = samread(self.fp, self.b) + * if (ret > 0): + * return makeAlignedRead( self.b ) # <<<<<<<<<<<<<< + * else: + * 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 = 1348; __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; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1350 + * return makeAlignedRead( self.b ) + * else: + * raise StopIteration # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __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_AddTraceback("csamtools.IteratorRowAll.__next__"); + __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":1352 + * raise StopIteration + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * bam_destroy1(self.b) + * 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], 1352); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1353 + * + * def __dealloc__(self): + * bam_destroy1(self.b) # <<<<<<<<<<<<<< + * if self.owns_samfile: samclose( self.fp ) + * + */ + bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1354 + * def __dealloc__(self): + * bam_destroy1(self.b) + * if self.owns_samfile: samclose( self.fp ) # <<<<<<<<<<<<<< + * + * cdef class IteratorRowAllRefs(IteratorRow): + */ + 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(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1363 + * cdef IteratorRowRegion rowiter + * + * def __cinit__(self, Samfile samfile): # <<<<<<<<<<<<<< + * assert samfile._isOpen() + * if not samfile._hasIndex(): raise ValueError("no index available for fetch") + */ + +static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __Pyx_TraceCall("__cinit__", __pyx_f[0], 1363); + 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, 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) { + 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 = 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 = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1364 + * + * def __cinit__(self, Samfile samfile): + * assert samfile._isOpen() # <<<<<<<<<<<<<< + * if not samfile._hasIndex(): raise ValueError("no index available for fetch") + * 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 = 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 = 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 = 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 = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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 = 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 = 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 = 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 = 1365; __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_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 = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 # <<<<<<<<<<<<<< + * self.tid = -1 + * + */ + __Pyx_INCREF(((PyObject *)__pyx_v_samfile)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile)); + __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile); + __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile)); + ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile = __pyx_v_samfile; + + /* "/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 # <<<<<<<<<<<<<< + * + * def nextiter(self): + */ + ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = -1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1369 + * self.tid = -1 + * + * def nextiter(self): # <<<<<<<<<<<<<< + * self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29) + * + */ + +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], 1369); + + /* "/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 = 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 = 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)); + __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_536870912); + 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 = 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); + __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter); + __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter)); + ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__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_AddTraceback("csamtools.IteratorRowAllRefs.nextiter"); + __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":1372 + * self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29) + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__iter__"); + __Pyx_TraceCall("__iter__", __pyx_f[0], 1372); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1373 + * + * def __iter__(self): + * 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_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1375 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * + */ + +static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_18IteratorRowAllRefs___next__[] = "python version of next().\n\n pyrex uses this non-standard name instead of next()\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__; +static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1375); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1381 + * """ + * # Create an initial iterator + * if self.tid==-1: # <<<<<<<<<<<<<< + * if not self.samfile.nreferences: + * raise StopIteration + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid == -1); + if (__pyx_t_1) { + + /* "/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 = 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 = 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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1383 + * if self.tid==-1: + * if not self.samfile.nreferences: + * raise StopIteration # <<<<<<<<<<<<<< + * self.tid = 0 + * self.nextiter() + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1384 + * if not self.samfile.nreferences: + * raise StopIteration + * self.tid = 0 # <<<<<<<<<<<<<< + * self.nextiter() + * + */ + ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = 0; + + /* "/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 = 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 = 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; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1387 + * self.nextiter() + * + * while 1: # <<<<<<<<<<<<<< + * self.rowiter.cnext() + * + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1388 + * + * while 1: + * self.rowiter.cnext() # <<<<<<<<<<<<<< + * + * # If current iterator is not exhausted, return aligned read + */ + ((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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1391 + * + * # If current iterator is not exhausted, return aligned read + * if self.rowiter.retval>0: # <<<<<<<<<<<<<< + * return makeAlignedRead(self.rowiter.b) + * + */ + __pyx_t_3 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->retval > 0); + if (__pyx_t_3) { + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L9; + } + __pyx_L9:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1394 + * return makeAlignedRead(self.rowiter.b) + * + * self.tid += 1 # <<<<<<<<<<<<<< + * + * # Otherwise, proceed to next reference or stop + */ + ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid += 1; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1397 + * + * # Otherwise, proceed to next reference or stop + * if self.tidtid); 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 = 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 = 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 = 1397; __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/csamtools.pyx":1398 + * # Otherwise, proceed to next reference or stop + * if self.tid 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;} + + /* "/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_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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1418 + * + * if not samfile._isOpen(): + * raise ValueError( "I/O operation on closed file" ) # <<<<<<<<<<<<<< + * + * if not samfile._isOpen(): + */ + __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:; + + /* "/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" ) + * + */ + __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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1421 + * + * if not samfile._isOpen(): + * raise ValueError( "I/O operation on closed file" ) # <<<<<<<<<<<<<< + * + * assert samfile.isbam, "can only use this iterator on bam files" + */ + __pyx_t_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:; + + /* "/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" + * + */ + #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 + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1424 + * + * assert samfile.isbam, "can only use this iterator on bam files" + * mode = "rb" # <<<<<<<<<<<<<< + * + * # reopen the file to avoid iterator conflict + */ + __Pyx_INCREF(((PyObject *)__pyx_n_s__rb)); + __Pyx_DECREF(__pyx_v_mode); + __pyx_v_mode = ((PyObject *)__pyx_n_s__rb); + + /* "/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 ) + */ + if (__pyx_v_reopen) { + + /* "/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_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; + + /* "/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_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); + + /* "/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_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; + + /* "/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: + */ + #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;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1432 + * store.release() + * assert self.fp != NULL + * self.owns_samfile = True # <<<<<<<<<<<<<< + * else: + * self.fp = samfile.samfile + */ + ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 1; + goto __pyx_L8; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1434 + * self.owns_samfile = True + * else: + * self.fp = samfile.samfile # <<<<<<<<<<<<<< + * self.owns_samfile = False + * + */ + ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = __pyx_v_samfile->samfile; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1435 + * else: + * self.fp = samfile.samfile + * self.owns_samfile = False # <<<<<<<<<<<<<< + * + * # allocate memory for alignment + */ + ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 0; + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1438 + * + * # allocate memory for alignment + * self.b = calloc(1, sizeof(bam1_t)) # <<<<<<<<<<<<<< + * + * self.positions = positions + */ + ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1440 + * self.b = calloc(1, sizeof(bam1_t)) + * + * self.positions = positions # <<<<<<<<<<<<<< + * self.current_pos = 0 + * + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1441 + * + * self.positions = positions + * self.current_pos = 0 # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->current_pos = 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 + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +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 + * + * def __iter__(self): + * return self # <<<<<<<<<<<<<< + * + * cdef bam1_t * getCurrent( 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":1446 + * return self + * + * cdef bam1_t * getCurrent( self ): # <<<<<<<<<<<<<< + * return self.b + * + */ + +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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1447 + * + * cdef bam1_t * getCurrent( self ): + * return self.b # <<<<<<<<<<<<<< + * + * cdef int cnext(self): + */ + __pyx_r = __pyx_v_self->b; + goto __pyx_L0; + + __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''' + * + */ + +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 + * + * # 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 ) + */ + __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:; + + /* "/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_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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1456 + * + * bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 ) + * self.current_pos += 1 # <<<<<<<<<<<<<< + * return samread(self.fp, self.b) + * + */ + __pyx_v_self->current_pos += 1; + + /* "/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) # <<<<<<<<<<<<<< + * + * def __next__(self): + */ + __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_3); + __Pyx_WriteUnraisable("csamtools.IteratorRowSelection.cnext"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1459 + * return samread(self.fp, self.b) + * + * 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1459); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1465 + * """ + * + * cdef int ret = self.cnext() # <<<<<<<<<<<<<< + * if (ret > 0): + * return makeAlignedRead( self.b ) + */ + __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)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1466 + * + * cdef int ret = self.cnext() + * if (ret > 0): # <<<<<<<<<<<<<< + * return makeAlignedRead( self.b ) + * else: + */ + __pyx_t_1 = (__pyx_v_ret > 0); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1467 + * cdef int ret = self.cnext() + * if (ret > 0): + * return makeAlignedRead( self.b ) # <<<<<<<<<<<<<< + * else: + * raise StopIteration + */ + __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; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1469 + * return makeAlignedRead( self.b ) + * else: + * raise StopIteration # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __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 = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IteratorRowSelection.__next__"); + __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":1471 + * raise StopIteration + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * bam_destroy1(self.b) + * if self.owns_samfile: samclose( self.fp ) + */ + +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("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1471); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1472 + * + * def __dealloc__(self): + * bam_destroy1(self.b) # <<<<<<<<<<<<<< + * if self.owns_samfile: samclose( self.fp ) + * + */ + bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b); + + /* "/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(); +} + +/* "/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___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("__advance_all"); + __Pyx_TraceCall("__advance_all", __pyx_f[0], 1486); + + /* "/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_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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1493 + * return bam_iter_read( d.samfile.x.bam, d.iter, b ) + * + * cdef int __advance_snpcalls( void * data, bam1_t * b ): # <<<<<<<<<<<<<< + * '''advance using same filter and read processing as in + * the samtools pileup. + */ + +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], 1493); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1498 + * ''' + * cdef __iterdata * d + * d = <__iterdata*>data # <<<<<<<<<<<<<< + * + * cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b ) + */ + __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1500 + * d = <__iterdata*>data + * + * 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1501 + * + * 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_v_skip = 0; + + /* "/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_v_is_cns = 1; + + /* "/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 + * + */ + __pyx_v_is_nobaq = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1505 + * cdef int is_cns = 1 + * cdef int is_nobaq = 0 + * cdef int capQ_thres = 0 # <<<<<<<<<<<<<< + * + * # reload sequence + */ + __pyx_v_capQ_thres = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1508 + * + * # 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) { + + /* "/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_t_3 = (__pyx_v_d->seq != NULL); + if (__pyx_t_3) { + free(__pyx_v_d->seq); + goto __pyx_L4; + } + __pyx_L4:; + + /* "/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; + + /* "/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)); + + /* "/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) { + + /* "/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_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)); + + /* "/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)) # <<<<<<<<<<<<<< + * + * + */ + __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 = 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 = 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 = 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 = 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; +} + +/* "/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, # <<<<<<<<<<<<<< + * int tid, + * int start, + */ + +static PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args) { + int __pyx_v_reopen = ((int)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; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("setupIteratorData"); + __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; + } + } + + /* "/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 = 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 = 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 = 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 = 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 = 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)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_1 = 0; + __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 = 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); + __Pyx_GOTREF(__pyx_v_self->iter); + __Pyx_DECREF(((PyObject *)__pyx_v_self->iter)); + __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1663 + * + * self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen ) + * self.iterdata.samfile = self.samfile.samfile # <<<<<<<<<<<<<< + * self.iterdata.iter = self.iter.iter + * self.iterdata.seq = NULL + */ + __pyx_v_self->iterdata.samfile = __pyx_v_self->samfile->samfile; + + /* "/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 # <<<<<<<<<<<<<< + * self.iterdata.seq = NULL + * self.iterdata.tid = -1 + */ + __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1665 + * self.iterdata.samfile = self.samfile.samfile + * self.iterdata.iter = self.iter.iter + * self.iterdata.seq = NULL # <<<<<<<<<<<<<< + * self.iterdata.tid = -1 + * + */ + __pyx_v_self->iterdata.seq = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1666 + * self.iterdata.iter = self.iter.iter + * self.iterdata.seq = NULL + * self.iterdata.tid = -1 # <<<<<<<<<<<<<< + * + * if self.fastafile != None: + */ + __pyx_v_self->iterdata.tid = -1; + + /* "/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 = 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 = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1669 + * + * if self.fastafile != None: + * self.iterdata.fastafile = self.fastafile.fastafile # <<<<<<<<<<<<<< + * else: + * self.iterdata.fastafile = NULL + */ + __pyx_v_self->iterdata.fastafile = __pyx_v_self->fastafile->fastafile; + goto __pyx_L3; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1671 + * self.iterdata.fastafile = self.fastafile.fastafile + * else: + * self.iterdata.fastafile = NULL # <<<<<<<<<<<<<< + * + * if self.stepper == None or self.stepper == "all": + */ + __pyx_v_self->iterdata.fastafile = NULL; + } + __pyx_L3:; + + /* "/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 = 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 = 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 = 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 = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_6; + } + if (__pyx_t_8) { + + /* "/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 ) # <<<<<<<<<<<<<< + * elif self.stepper == "samtools": + * self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata ) + */ + __pyx_v_self->pileup_iter = bam_plp_init((&__pyx_f_9csamtools___advance_all), (&__pyx_v_self->iterdata)); + goto __pyx_L4; + } + + /* "/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 = 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 = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_8) { + + /* "/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 ) # <<<<<<<<<<<<<< + * else: + * raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper) + */ + __pyx_v_self->pileup_iter = bam_plp_init((&__pyx_f_9csamtools___advance_snpcalls), (&__pyx_v_self->iterdata)); + goto __pyx_L4; + } + /*else*/ { + + /* "/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_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 = 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 = 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 = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L4:; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * cdef reset( self, tid, start, end ): + */ + 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_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("csamtools.IteratorColumn.setupIteratorData"); + __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":1682 + * bam_plp_set_mask( self.pileup_iter, self.mask ) + * + * cdef reset( self, tid, start, end ): # <<<<<<<<<<<<<< + * '''reset iterator position. + * + */ + +static PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, PyObject *__pyx_v_tid, PyObject *__pyx_v_start, PyObject *__pyx_v_end) { + 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("reset"); + __Pyx_TraceCall("reset", __pyx_f[0], 1682); + + /* "/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 = 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)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile)); + __Pyx_INCREF(__pyx_v_tid); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tid); + __Pyx_GIVEREF(__pyx_v_tid); + __Pyx_INCREF(__pyx_v_start); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start); + __Pyx_GIVEREF(__pyx_v_start); + __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 = 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 = 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; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->iter); + __Pyx_DECREF(((PyObject *)__pyx_v_self->iter)); + __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1689 + * ''' + * self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 ) + * self.iterdata.iter = self.iter.iter # <<<<<<<<<<<<<< + * + * # invalidate sequence if different tid + */ + __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter; + + /* "/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 = 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 = 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 = 1692; __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/csamtools.pyx":1693 + * # invalidate sequence if different tid + * if self.tid != tid: + * if self.iterdata.seq != NULL: free( self.iterdata.seq ) # <<<<<<<<<<<<<< + * self.iterdata.seq = NULL + * self.iterdata.tid = -1 + */ + __pyx_t_4 = (__pyx_v_self->iterdata.seq != NULL); + if (__pyx_t_4) { + free(__pyx_v_self->iterdata.seq); + goto __pyx_L4; + } + __pyx_L4:; + + /* "/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 # <<<<<<<<<<<<<< + * self.iterdata.tid = -1 + * + */ + __pyx_v_self->iterdata.seq = NULL; + + /* "/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 # <<<<<<<<<<<<<< + * + * # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata ) + */ + __pyx_v_self->iterdata.tid = -1; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1698 + * + * # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata ) + * bam_plp_reset(self.pileup_iter) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + bam_plp_reset(__pyx_v_self->pileup_iter); + + __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.IteratorColumn.reset"); + __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":1700 + * bam_plp_reset(self.pileup_iter) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * # reset in order to avoid memory leak messages for iterators that have + * # not been fully consumed + */ + +static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self) { + int __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1700); + + /* "/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 != NULL: # <<<<<<<<<<<<<< + * bam_plp_reset(self.pileup_iter) + * bam_plp_destroy(self.pileup_iter) + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter != ((bam_plp_t)NULL)); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1704 + * # not been fully consumed + * if self.pileup_iter != NULL: + * bam_plp_reset(self.pileup_iter) # <<<<<<<<<<<<<< + * bam_plp_destroy(self.pileup_iter) + * self.pileup_iter = NULL + */ + bam_plp_reset(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1705 + * if self.pileup_iter != NULL: + * bam_plp_reset(self.pileup_iter) + * bam_plp_destroy(self.pileup_iter) # <<<<<<<<<<<<<< + * self.pileup_iter = NULL + * + */ + bam_plp_destroy(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1706 + * bam_plp_reset(self.pileup_iter) + * bam_plp_destroy(self.pileup_iter) + * self.pileup_iter = NULL # <<<<<<<<<<<<<< + * + * if self.iterdata.seq != NULL: + */ + ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL); + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1708 + * self.pileup_iter = NULL + * + * if self.iterdata.seq != NULL: # <<<<<<<<<<<<<< + * free(self.iterdata.seq) + * self.iterdata.seq = NULL + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1709 + * + * if self.iterdata.seq != NULL: + * free(self.iterdata.seq) # <<<<<<<<<<<<<< + * self.iterdata.seq = NULL + * + */ + free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1710 + * if self.iterdata.seq != NULL: + * free(self.iterdata.seq) + * self.iterdata.seq = NULL # <<<<<<<<<<<<<< + * + * cdef class IteratorColumnRegion(IteratorColumn): + */ + ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL; + goto __pyx_L6; + } + __pyx_L6:; + + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1715 + * '''iterates over a region only. + * ''' + * def __cinit__(self, Samfile samfile, # <<<<<<<<<<<<<< + * int tid = 0, + * int start = 0, + */ + +static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0; + int __pyx_v_tid; + int __pyx_v_start; + int __pyx_v_end; + PyObject *__pyx_v_kwargs = 0; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_2; + 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], 1715); + __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[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__samfile); + 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__tid); + 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--; } + } + } + 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 = 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 = 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 = 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 = 1718; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_end = __pyx_k_58; + } + } else { + __pyx_v_tid = ((int)0); + __pyx_v_start = ((int)0); + __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 = 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; + } + } + 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 = 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 = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1722 + * + * # initialize iterator + * self.setupIteratorData( tid, start, end, 1 ) # <<<<<<<<<<<<<< + * + * def __next__(self): + */ + __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 = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__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":1724 + * self.setupIteratorData( tid, start, end, 1 ) + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * """ + */ + +static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_20IteratorColumnRegion___next__[] = "python version of next().\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__; +static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___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], 1724); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1728 + * """ + * + * while 1: # <<<<<<<<<<<<<< + * self.cnext() + * if self.n_plp < 0: + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1729 + * + * while 1: + * self.cnext() # <<<<<<<<<<<<<< + * if self.n_plp < 0: + * raise ValueError("error during iteration" ) + */ + ((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)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1730 + * while 1: + * self.cnext() + * if self.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp < 0); + if (__pyx_t_1) { + + /* "/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 = 1731; __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 = 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 = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1733 + * raise ValueError("error during iteration" ) + * + * if self.plp == NULL: # <<<<<<<<<<<<<< + * raise StopIteration + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp == NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1734 + * + * if self.plp == NULL: + * raise StopIteration # <<<<<<<<<<<<<< + * + * return makePileupProxy( self.plp, + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1736 + * raise StopIteration + * + * return makePileupProxy( self.plp, # <<<<<<<<<<<<<< + * self.tid, + * self.pos, + */ + __Pyx_XDECREF(__pyx_r); + + /* "/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 = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__next__"); + __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":1745 + * """ + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * Samfile samfile, + * **kwargs ): + */ + +static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___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; + int __pyx_t_2; + int __pyx_t_3; + struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_4; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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)) { + 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 = 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) { + 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 = 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 = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/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 = 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 = 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 = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1753 + * + * # initialize iterator + * self.setupIteratorData( self.tid, 0, max_pos, 1 ) # <<<<<<<<<<<<<< + * + * def __next__(self): + */ + __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 = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__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":1755 + * self.setupIteratorData( self.tid, 0, max_pos, 1 ) + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * """ + */ + +static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__[] = "python version of next().\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__; +static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_5; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 1755); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1759 + * """ + * + * while 1: # <<<<<<<<<<<<<< + * self.cnext() + * + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1760 + * + * while 1: + * self.cnext() # <<<<<<<<<<<<<< + * + * if self.n_plp < 0: + */ + ((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)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1762 + * self.cnext() + * + * if self.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp < 0); + if (__pyx_t_1) { + + /* "/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 = 1763; __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 = 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 = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1766 + * + * # return result, if within same reference + * if self.plp != NULL: # <<<<<<<<<<<<<< + * return makePileupProxy( self.plp, + * self.tid, + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1767 + * # return result, if within same reference + * if self.plp != NULL: + * return makePileupProxy( self.plp, # <<<<<<<<<<<<<< + * self.tid, + * self.pos, + */ + __Pyx_XDECREF(__pyx_r); + + /* "/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 = 1767; __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/csamtools.pyx":1773 + * + * # otherwise, proceed to next reference or stop + * self.tid += 1 # <<<<<<<<<<<<<< + * if self.tid < self.samfile.nreferences: + * self.setupIteratorData( self.tid, 0, max_pos, 0 ) + */ + ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid += 1; + + /* "/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 = 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 = 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 = 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 = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_1) { + + /* "/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 ) # <<<<<<<<<<<<<< + * else: + * raise StopIteration + */ + __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 = 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*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1777 + * self.setupIteratorData( self.tid, 0, max_pos, 0 ) + * else: + * raise StopIteration # <<<<<<<<<<<<<< + * + * ##------------------------------------------------------------------- + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L9:; + } + + __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("csamtools.IteratorColumnAllRefs.__next__"); + __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":1782 + * ##------------------------------------------------------------------- + * ##------------------------------------------------------------------- + * cdef inline int32_t query_start(bam1_t *src) except -1: # <<<<<<<<<<<<<< + * cdef uint32_t * cigar_p, op + * cdef uint32_t k + */ + +static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src) { + uint32_t *__pyx_v_cigar_p; + uint32_t __pyx_v_op; + uint32_t __pyx_v_k; + uint32_t __pyx_v_start_offset; + int32_t __pyx_r; + uint32_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("query_start"); + __Pyx_TraceCall("query_start", __pyx_f[0], 1782); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1785 + * cdef uint32_t * cigar_p, op + * cdef uint32_t k + * cdef uint32_t start_offset = 0 # <<<<<<<<<<<<<< + * + * if src.core.n_cigar: + */ + __pyx_v_start_offset = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1787 + * cdef uint32_t start_offset = 0 + * + * if src.core.n_cigar: # <<<<<<<<<<<<<< + * cigar_p = bam1_cigar(src); + * for k from 0 <= k < src.core.n_cigar: + */ + if (__pyx_v_src->core.n_cigar) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1788 + * + * if src.core.n_cigar: + * 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":1789 + * if src.core.n_cigar: + * cigar_p = bam1_cigar(src); + * for k from 0 <= k < src.core.n_cigar: # <<<<<<<<<<<<<< + * op = cigar_p[k] & BAM_CIGAR_MASK + * if op==BAM_CHARD_CLIP: + */ + __pyx_t_1 = __pyx_v_src->core.n_cigar; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { + + /* "/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 # <<<<<<<<<<<<<< + * if op==BAM_CHARD_CLIP: + * if start_offset!=0 and start_offset!=src.core.l_qseq: + */ + __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15); + + /* "/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: # <<<<<<<<<<<<<< + * if start_offset!=0 and start_offset!=src.core.l_qseq: + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + */ + switch (__pyx_v_op) { + case 5: + + /* "/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: # <<<<<<<<<<<<<< + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + * return -1 + */ + __pyx_t_2 = (__pyx_v_start_offset != 0); + if (__pyx_t_2) { + __pyx_t_3 = (__pyx_v_start_offset != __pyx_v_src->core.l_qseq); + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_2; + } + if (__pyx_t_4) { + + /* "/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_60); + + /* "/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 # <<<<<<<<<<<<<< + * elif op==BAM_CSOFT_CLIP: + * start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT + */ + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; + break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1795 + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + * return -1 + * elif op==BAM_CSOFT_CLIP: # <<<<<<<<<<<<<< + * start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT + * else: + */ + case 4: + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1796 + * return -1 + * elif op==BAM_CSOFT_CLIP: + * start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_v_start_offset += ((__pyx_v_cigar_p[__pyx_v_k]) >> 4); + break; + default: + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1798 + * start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT + * else: + * break # <<<<<<<<<<<<<< + * + * return start_offset + */ + goto __pyx_L5_break; + break; + } + } + __pyx_L5_break:; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1800 + * break + * + * return start_offset # <<<<<<<<<<<<<< + * + * ##------------------------------------------------------------------- + */ + __pyx_r = __pyx_v_start_offset; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1805 + * ##------------------------------------------------------------------- + * ##------------------------------------------------------------------- + * cdef inline int32_t query_end(bam1_t *src) except -1: # <<<<<<<<<<<<<< + * cdef uint32_t * cigar_p, op + * cdef uint32_t k + */ + +static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) { + uint32_t *__pyx_v_cigar_p; + uint32_t __pyx_v_op; + uint32_t __pyx_v_k; + uint32_t __pyx_v_end_offset; + int32_t __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("query_end"); + __Pyx_TraceCall("query_end", __pyx_f[0], 1805); + + /* "/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 # <<<<<<<<<<<<<< + * + * if src.core.n_cigar>1: + */ + __pyx_v_end_offset = __pyx_v_src->core.l_qseq; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1810 + * cdef uint32_t end_offset = src.core.l_qseq + * + * if src.core.n_cigar>1: # <<<<<<<<<<<<<< + * cigar_p = bam1_cigar(src); + * for k from src.core.n_cigar > k >= 1: + */ + __pyx_t_1 = (__pyx_v_src->core.n_cigar > 1); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1811 + * + * if src.core.n_cigar>1: + * cigar_p = bam1_cigar(src); # <<<<<<<<<<<<<< + * for k from src.core.n_cigar > k >= 1: + * op = cigar_p[k] & BAM_CIGAR_MASK + */ + __pyx_v_cigar_p = bam1_cigar(__pyx_v_src); + + /* "/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: # <<<<<<<<<<<<<< + * op = cigar_p[k] & BAM_CIGAR_MASK + * if op==BAM_CHARD_CLIP: + */ + for (__pyx_v_k = __pyx_v_src->core.n_cigar-1; __pyx_v_k >= 1; __pyx_v_k--) { + + /* "/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 # <<<<<<<<<<<<<< + * if op==BAM_CHARD_CLIP: + * if end_offset!=0 and end_offset!=src.core.l_qseq: + */ + __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15); + + /* "/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: # <<<<<<<<<<<<<< + * if end_offset!=0 and end_offset!=src.core.l_qseq: + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + */ + switch (__pyx_v_op) { + case 5: + + /* "/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: # <<<<<<<<<<<<<< + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + * return -1 + */ + __pyx_t_1 = (__pyx_v_end_offset != 0); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_end_offset != __pyx_v_src->core.l_qseq); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { + + /* "/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_60); + + /* "/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 # <<<<<<<<<<<<<< + * elif op==BAM_CSOFT_CLIP: + * end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT + */ + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; + break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1818 + * PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string') + * return -1 + * elif op==BAM_CSOFT_CLIP: # <<<<<<<<<<<<<< + * end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT + * else: + */ + case 4: + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1819 + * return -1 + * elif op==BAM_CSOFT_CLIP: + * end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_v_end_offset -= ((__pyx_v_cigar_p[__pyx_v_k]) >> 4); + break; + default: + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1821 + * end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT + * else: + * break # <<<<<<<<<<<<<< + * + * if end_offset==0: + */ + goto __pyx_L5_break; + break; + } + } + __pyx_L5_break:; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1823 + * break + * + * if end_offset==0: # <<<<<<<<<<<<<< + * end_offset = src.core.l_qseq + * + */ + __pyx_t_3 = (__pyx_v_end_offset == 0); + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1824 + * + * if end_offset==0: + * end_offset = src.core.l_qseq # <<<<<<<<<<<<<< + * + * return end_offset + */ + __pyx_v_end_offset = __pyx_v_src->core.l_qseq; + goto __pyx_L7; + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1826 + * end_offset = src.core.l_qseq + * + * return end_offset # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_end_offset; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1829 + * + * + * cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end): # <<<<<<<<<<<<<< + * cdef uint8_t * p + * cdef uint32_t k + */ + +static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_src, uint32_t __pyx_v_start, uint32_t __pyx_v_end) { + uint8_t *__pyx_v_p; + uint32_t __pyx_v_k; + char *__pyx_v_s; + PyObject *__pyx_v_seq; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + uint32_t __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("get_seq_range"); + __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1829); + __pyx_v_seq = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1834 + * cdef char * s + * + * if not src.core.l_qseq: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_1 = (!__pyx_v_src->core.l_qseq); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1835 + * + * if not src.core.l_qseq: + * return None # <<<<<<<<<<<<<< + * + * seq = PyString_FromStringAndSize(NULL, end-start) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1838 + * + * seq = PyString_FromStringAndSize(NULL, end-start) + * s = PyString_AS_STRING(seq) # <<<<<<<<<<<<<< + * p = bam1_seq(src) + * + */ + __pyx_v_s = PyString_AS_STRING(__pyx_v_seq); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1839 + * seq = PyString_FromStringAndSize(NULL, end-start) + * s = PyString_AS_STRING(seq) + * p = bam1_seq(src) # <<<<<<<<<<<<<< + * + * for k from start <= k < end: + */ + __pyx_v_p = bam1_seq(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1841 + * p = bam1_seq(src) + * + * for k from start <= k < end: # <<<<<<<<<<<<<< + * # 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 + */ + __pyx_t_3 = __pyx_v_end; + for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { + + /* "/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] # <<<<<<<<<<<<<< + * + * return seq + */ + (__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)]); + } + + /* "/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 # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_seq); + __pyx_r = __pyx_v_seq; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.get_seq_range"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_seq); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1849 + * + * + * cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end): # <<<<<<<<<<<<<< + * cdef uint8_t * p + * cdef uint32_t k + */ + +static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v_src, uint32_t __pyx_v_start, uint32_t __pyx_v_end) { + uint8_t *__pyx_v_p; + uint32_t __pyx_v_k; + char *__pyx_v_q; + PyObject *__pyx_v_qual; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + uint32_t __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("get_qual_range"); + __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1849); + __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1854 + * cdef char * q + * + * p = bam1_qual(src) # <<<<<<<<<<<<<< + * if p[0] == 0xff: + * return None + */ + __pyx_v_p = bam1_qual(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1855 + * + * p = bam1_qual(src) + * if p[0] == 0xff: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_1 = ((__pyx_v_p[0]) == 0xff); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1856 + * p = bam1_qual(src) + * if p[0] == 0xff: + * return None # <<<<<<<<<<<<<< + * + * qual = PyString_FromStringAndSize(NULL, end-start) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1859 + * + * qual = PyString_FromStringAndSize(NULL, end-start) + * q = PyString_AS_STRING(qual) # <<<<<<<<<<<<<< + * + * for k from start <= k < end: + */ + __pyx_v_q = PyString_AS_STRING(__pyx_v_qual); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1861 + * q = PyString_AS_STRING(qual) + * + * for k from start <= k < end: # <<<<<<<<<<<<<< + * ## equivalent to t[i] + 33 (see bam.c) + * q[k-start] = p[k] + 33 + */ + __pyx_t_3 = __pyx_v_end; + for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { + + /* "/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 # <<<<<<<<<<<<<< + * + * return qual + */ + (__pyx_v_q[(__pyx_v_k - __pyx_v_start)]) = ((__pyx_v_p[__pyx_v_k]) + 33); + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1865 + * q[k-start] = p[k] + 33 + * + * return qual # <<<<<<<<<<<<<< + * + * cdef class AlignedRead: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_qual); + __pyx_r = __pyx_v_qual; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.get_qual_range"); + __pyx_r = 0; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_qual); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1890 + * + * # Now only called when instances are created from Python + * def __init__(self): # <<<<<<<<<<<<<< + * # see bam_init1 + * self._delegate = calloc( 1, sizeof( bam1_t) ) + */ + +static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__init__"); + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1892 + * def __init__(self): + * # see bam_init1 + * self._delegate = calloc( 1, sizeof( bam1_t) ) # <<<<<<<<<<<<<< + * # allocate some memory + * # If size is 0, calloc does not return a pointer that can be passed to free() + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate = ((bam1_t *)calloc(1, (sizeof(bam1_t)))); + + /* "/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 # <<<<<<<<<<<<<< + * self._delegate.data = calloc( self._delegate.m_data, 1 ) + * self._delegate.data_len = 0 + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data = 40; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1897 + * # so allocate 40 bytes for a new read + * self._delegate.m_data = 40 + * self._delegate.data = calloc( self._delegate.m_data, 1 ) # <<<<<<<<<<<<<< + * self._delegate.data_len = 0 + * + */ + ((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)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1898 + * self._delegate.m_data = 40 + * self._delegate.data = calloc( self._delegate.m_data, 1 ) + * self._delegate.data_len = 0 # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->data_len = 0; + + __pyx_r = 0; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1900 + * self._delegate.data_len = 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * bam_destroy1(self._delegate) + * + */ + +static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self) { + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1900); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1901 + * + * def __dealloc__(self): + * bam_destroy1(self._delegate) # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + bam_destroy1(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); + + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1903 + * bam_destroy1(self._delegate) + * + * def __str__(self): # <<<<<<<<<<<<<< + * """return string representation of alignment. + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self); /*proto*/ +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; + 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("__str__"); + __Pyx_TraceCall("__str__", __pyx_f[0], 1903); + + /* "/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, + */ + __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 = 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 = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1916 + * # requires a valid header. + * return "\t".join(map(str, (self.qname, + * self.flag, # <<<<<<<<<<<<<< + * self.rname, + * self.pos, + */ + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1917 + * return "\t".join(map(str, (self.qname, + * self.flag, + * self.rname, # <<<<<<<<<<<<<< + * self.pos, + * self.mapq, + */ + __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); + + /* "/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__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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1919 + * self.rname, + * self.pos, + * self.mapq, # <<<<<<<<<<<<<< + * self.cigar, + * self.mrnm, + */ + __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); + + /* "/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__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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1921 + * self.mapq, + * self.cigar, + * self.mrnm, # <<<<<<<<<<<<<< + * self.mpos, + * self.rlen, + */ + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1922 + * self.cigar, + * self.mrnm, + * self.mpos, # <<<<<<<<<<<<<< + * self.rlen, + * self.seq, + */ + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1923 + * self.mrnm, + * self.mpos, + * self.rlen, # <<<<<<<<<<<<<< + * self.seq, + * self.qual, + */ + __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); + + /* "/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); + + /* "/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_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 = 1915; __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 = 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_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_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.AlignedRead.__str__"); + __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":1928 + * self.tags ))) + * + * def compare(self, AlignedRead other): # <<<<<<<<<<<<<< + * '''return -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); /*proto*/ +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; + bam1_t *__pyx_v_o; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("compare"); + __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;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1934 + * cdef bam1_t *t, *o + * + * t = self._delegate # <<<<<<<<<<<<<< + * o = other._delegate + * + */ + __pyx_v_t = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1935 + * + * t = self._delegate + * o = other._delegate # <<<<<<<<<<<<<< + * + * # uncomment for debugging purposes + */ + __pyx_v_o = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_other)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1947 + * + * # Fast-path test for object identity + * if t==o: # <<<<<<<<<<<<<< + * return 0 + * + */ + __pyx_t_1 = (__pyx_v_t == __pyx_v_o); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1948 + * # Fast-path test for object identity + * if t==o: + * return 0 # <<<<<<<<<<<<<< + * + * retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t)) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_int_0); + __pyx_r = __pyx_int_0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1950 + * return 0 + * + * retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t)) # <<<<<<<<<<<<<< + * + * if retval: return retval + */ + __pyx_v_retval = memcmp((&__pyx_v_t->core), (&__pyx_v_o->core), (sizeof(bam1_core_t))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1952 + * retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t)) + * + * if retval: return retval # <<<<<<<<<<<<<< + * retval = cmp(t.data_len, o.data_len) + * if retval: return retval + */ + 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 = 1952; __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_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __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 = 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 = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_retval = __pyx_t_5; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1954 + * 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) + * + */ + 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 = 1954; __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_L7; + } + __pyx_L7:; + + /* "/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) # <<<<<<<<<<<<<< + * + * # 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 = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("csamtools.AlignedRead.compare"); + __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":1958 + * + * # Disabled so long as __cmp__ is a special method + * def __hash__(self): # <<<<<<<<<<<<<< + * return _Py_HashPointer(self) + * + */ + +static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self); /*proto*/ +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], 1958); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1959 + * # Disabled so long as __cmp__ is a special method + * def __hash__(self): + * return _Py_HashPointer(self) # <<<<<<<<<<<<<< + * + * property qname: + */ + __pyx_r = _Py_HashPointer(((void *)__pyx_v_self)); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1963 + * property qname: + * """the query name (None if not present)""" + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * src = self._delegate + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 1963); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1965 + * def __get__(self): + * cdef bam1_t * src + * src = self._delegate # <<<<<<<<<<<<<< + * if src.core.l_qname == 0: return None + * return bam1_qname( src ) + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1966 + * cdef bam1_t * src + * src = self._delegate + * if src.core.l_qname == 0: return None # <<<<<<<<<<<<<< + * return bam1_qname( src ) + * + */ + __pyx_t_1 = (__pyx_v_src->core.l_qname == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1967 + * src = self._delegate + * if src.core.l_qname == 0: return None + * return bam1_qname( src ) # <<<<<<<<<<<<<< + * + * 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 = 1967; __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("csamtools.AlignedRead.qname.__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":1969 + * return bam1_qname( src ) + * + * def __set__(self, qname ): # <<<<<<<<<<<<<< + * if qname == None or len(qname) == 0: return + * cdef bam1_t * src + */ + +static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) { + bam1_t *__pyx_v_src; + int __pyx_v_l; + char *__pyx_v_p; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + char *__pyx_t_6; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __Pyx_TraceCall("__set__", __pyx_f[0], 1969); + + /* "/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 = 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 = 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 = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_3 == 0); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1975 + * cdef char * p + * + * src = self._delegate # <<<<<<<<<<<<<< + * p = bam1_qname( src ) + * + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1976 + * + * src = self._delegate + * p = bam1_qname( src ) # <<<<<<<<<<<<<< + * + * # the qname is \0 terminated + */ + __pyx_v_p = bam1_qname(__pyx_v_src); + + /* "/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 = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_l = (__pyx_t_3 + 1); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1983 + * src.core.l_qname, + * l, + * p ) # <<<<<<<<<<<<<< + * + * src.core.l_qname = l + */ + pysam_bam_update(__pyx_v_src, __pyx_v_src->core.l_qname, __pyx_v_l, ((uint8_t *)__pyx_v_p)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1985 + * p ) + * + * src.core.l_qname = l # <<<<<<<<<<<<<< + * + * # re-acquire pointer to location in memory + */ + __pyx_v_src->core.l_qname = __pyx_v_l; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1989 + * # re-acquire pointer to location in memory + * # as it might have moved + * p = bam1_qname(src) # <<<<<<<<<<<<<< + * + * strncpy( p, qname, l ) + */ + __pyx_v_p = bam1_qname(__pyx_v_src); + + /* "/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 = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + strncpy(__pyx_v_p, __pyx_t_6, __pyx_v_l); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.AlignedRead.qname.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1996 + * """the :term:`cigar` alignment (None if not present). + * """ + * def __get__(self): # <<<<<<<<<<<<<< + * cdef uint32_t * cigar_p + * cdef bam1_t * src + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__pyx_v_self) { + uint32_t *__pyx_v_cigar_p; + bam1_t *__pyx_v_src; + PyObject *__pyx_v_op; + PyObject *__pyx_v_l; + PyObject *__pyx_v_cigar; + int __pyx_v_k; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + uint32_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2002 + * cdef int k + * + * src = self._delegate # <<<<<<<<<<<<<< + * if src.core.n_cigar == 0: return None + * + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2003 + * + * src = self._delegate + * if src.core.n_cigar == 0: return None # <<<<<<<<<<<<<< + * + * cigar = [] + */ + __pyx_t_1 = (__pyx_v_src->core.n_cigar == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2006 + * + * cigar = [] + * 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":2007 + * cigar = [] + * 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++) { + + /* "/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 = 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; + + /* "/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 = 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; + + /* "/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 = 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); + __Pyx_GIVEREF(__pyx_v_op); + __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 = 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; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2011 + * l = cigar_p[k] >> BAM_CIGAR_SHIFT + * cigar.append((op, l)) + * return cigar # <<<<<<<<<<<<<< + * + * def __set__(self, values ): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_cigar); + __pyx_r = __pyx_v_cigar; + 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_4); + __Pyx_AddTraceback("csamtools.AlignedRead.cigar.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_op); + __Pyx_DECREF(__pyx_v_l); + __Pyx_DECREF(__pyx_v_cigar); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2013 + * return cigar + * + * def __set__(self, values ): # <<<<<<<<<<<<<< + * if values == None or len(values) == 0: return + * cdef uint32_t * p + */ + +static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values) { + uint32_t *__pyx_v_p; + bam1_t *__pyx_v_src; + PyObject *__pyx_v_op; + PyObject *__pyx_v_l; + int __pyx_v_k; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __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; + uint32_t __pyx_t_10; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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); + + /* "/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 = 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 = 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 = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_3 == 0); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2020 + * cdef int k + * + * k = 0 # <<<<<<<<<<<<<< + * + * src = self._delegate + */ + __pyx_v_k = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2022 + * k = 0 + * + * src = self._delegate # <<<<<<<<<<<<<< + * + * # get location of cigar string + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2025 + * + * # get location of cigar string + * p = bam1_cigar(src) # <<<<<<<<<<<<<< + * + * # create space for cigar data within src.data + */ + __pyx_v_p = bam1_cigar(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2030 + * pysam_bam_update( src, + * src.core.n_cigar * 4, + * len(values) * 4, # <<<<<<<<<<<<<< + * p ) + * + */ + __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;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2031 + * src.core.n_cigar * 4, + * len(values) * 4, + * p ) # <<<<<<<<<<<<<< + * + * # length is number of cigar operations, not bytes + */ + pysam_bam_update(__pyx_v_src, (__pyx_v_src->core.n_cigar * 4), (__pyx_t_3 * 4), ((uint8_t *)__pyx_v_p)); + + /* "/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 = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_src->core.n_cigar = __pyx_t_3; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2038 + * # re-acquire pointer to location in memory + * # as it might have moved + * p = bam1_cigar(src) # <<<<<<<<<<<<<< + * + * # insert cigar operations + */ + __pyx_v_p = bam1_cigar(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2041 + * + * # insert cigar operations + * for op, l in values: # <<<<<<<<<<<<<< + * p[k] = l << BAM_CIGAR_SHIFT | op + * k += 1 + */ + 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 = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; + } else if (likely(PyTuple_CheckExact(__pyx_t_1))) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; + } else { + __pyx_t_6 = PyIter_Next(__pyx_t_1); + if (!__pyx_t_6) { + 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); + } + if (PyTuple_CheckExact(__pyx_t_6) && likely(PyTuple_GET_SIZE(__pyx_t_6) == 2)) { + PyObject* tuple = __pyx_t_6; + __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7); + __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_v_op); + __pyx_v_op = __pyx_t_7; + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_v_l); + __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 = 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 = 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 = 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 = 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; + __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_v_l); + __pyx_v_l = __pyx_t_8; + __pyx_t_8 = 0; + } + + /* "/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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2043 + * for op, l in values: + * p[k] = l << BAM_CIGAR_SHIFT | op + * k += 1 # <<<<<<<<<<<<<< + * + * ## setting the cigar string also updates the "bin" attribute + */ + __pyx_v_k += 1; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/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)) # <<<<<<<<<<<<<< + * + * property seq: + */ + __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, bam_calend((&__pyx_v_src->core), __pyx_v_p)); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("csamtools.AlignedRead.cigar.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_op); + __Pyx_DECREF(__pyx_v_l); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * cdef char * s + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2050); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2053 + * cdef bam1_t * src + * cdef char * s + * src = self._delegate # <<<<<<<<<<<<<< + * + * if src.core.l_qseq == 0: return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2055 + * src = self._delegate + * + * if src.core.l_qseq == 0: return None # <<<<<<<<<<<<<< + * + * return get_seq_range(src, 0, src.core.l_qseq) + */ + __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_2); + __Pyx_AddTraceback("csamtools.AlignedRead.seq.__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":2059 + * return get_seq_range(src, 0, src.core.l_qseq) + * + * def __set__(self,seq): # <<<<<<<<<<<<<< + * # samtools manages sequence and quality length memory together + * # if no quality information is present, the first byte says 0xff. + */ + +static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) { + bam1_t *__pyx_v_src; + uint8_t *__pyx_v_p; + char *__pyx_v_s; + int __pyx_v_l; + int __pyx_v_k; + int __pyx_v_nbytes_new; + int __pyx_v_nbytes_old; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + char *__pyx_t_7; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __Pyx_TraceCall("__set__", __pyx_f[0], 2059); + + /* "/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 = 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 = 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 = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_3 == 0); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2069 + * cdef int l, k, nbytes_new, nbytes_old + * + * src = self._delegate # <<<<<<<<<<<<<< + * + * l = len(seq) + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/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 = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_l = __pyx_t_3; + + /* "/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 # <<<<<<<<<<<<<< + * nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq + * # acquire pointer to location in memory + */ + __pyx_v_nbytes_new = (__Pyx_div_long((__pyx_v_l + 1), 2) + __pyx_v_l); + + /* "/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 # <<<<<<<<<<<<<< + * # acquire pointer to location in memory + * p = bam1_seq( src ) + */ + __pyx_v_nbytes_old = (__Pyx_div_long((__pyx_v_src->core.l_qseq + 1), 2) + __pyx_v_src->core.l_qseq); + + /* "/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 ) # <<<<<<<<<<<<<< + * src.core.l_qseq = l + * + */ + __pyx_v_p = bam1_seq(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2079 + * # acquire pointer to location in memory + * p = bam1_seq( src ) + * src.core.l_qseq = l # <<<<<<<<<<<<<< + * + * pysam_bam_update( src, + */ + __pyx_v_src->core.l_qseq = __pyx_v_l; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2084 + * nbytes_old, + * nbytes_new, + * p) # <<<<<<<<<<<<<< + * # re-acquire pointer to location in memory + * # as it might have moved + */ + pysam_bam_update(__pyx_v_src, __pyx_v_nbytes_old, __pyx_v_nbytes_new, __pyx_v_p); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2087 + * # re-acquire pointer to location in memory + * # as it might have moved + * p = bam1_seq( src ) # <<<<<<<<<<<<<< + * for k from 0 <= k < nbytes_new: p[k] = 0 + * # convert to C string + */ + __pyx_v_p = bam1_seq(__pyx_v_src); + + /* "/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 # <<<<<<<<<<<<<< + * # convert to C string + * s = seq + */ + __pyx_t_6 = __pyx_v_nbytes_new; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { + (__pyx_v_p[__pyx_v_k]) = 0; + } + + /* "/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 = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_s = __pyx_t_7; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2091 + * # convert to C string + * s = seq + * for k from 0 <= k < l: # <<<<<<<<<<<<<< + * p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2) + * + */ + __pyx_t_6 = __pyx_v_l; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { + + /* "/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) # <<<<<<<<<<<<<< + * + * # erase qualities + */ + (__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)))); + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2095 + * + * # erase qualities + * p = bam1_qual( src ) # <<<<<<<<<<<<<< + * p[0] = 0xff + * + */ + __pyx_v_p = bam1_qual(__pyx_v_src); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2096 + * # erase qualities + * p = bam1_qual( src ) + * p[0] = 0xff # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_p[0]) = 0xff; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("csamtools.AlignedRead.seq.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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): # <<<<<<<<<<<<<< + * + * cdef bam1_t * src + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2101); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2106 + * cdef char * q + * + * src = self._delegate # <<<<<<<<<<<<<< + * + * if src.core.l_qseq == 0: return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2108 + * src = self._delegate + * + * if src.core.l_qseq == 0: return None # <<<<<<<<<<<<<< + * + * return get_qual_range(src, 0, src.core.l_qseq) + */ + __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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_2); + __Pyx_AddTraceback("csamtools.AlignedRead.qual.__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":2112 + * return get_qual_range(src, 0, src.core.l_qseq) + * + * def __set__(self,qual): # <<<<<<<<<<<<<< + * # note that space is already allocated via the sequences + * cdef bam1_t * src + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) { + bam1_t *__pyx_v_src; + uint8_t *__pyx_v_p; + char *__pyx_v_q; + int __pyx_v_k; + int __pyx_v_l; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + char *__pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __Pyx_TraceCall("__set__", __pyx_f[0], 2112); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2119 + * cdef int k + * + * src = self._delegate # <<<<<<<<<<<<<< + * p = bam1_qual( src ) + * if qual == None or len(qual) == 0: + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2120 + * + * src = self._delegate + * p = bam1_qual( src ) # <<<<<<<<<<<<<< + * if qual == None or len(qual) == 0: + * # if absent - set to 0xff + */ + __pyx_v_p = bam1_qual(__pyx_v_src); + + /* "/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 = 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 = 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 = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_3 == 0); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2123 + * if qual == None or len(qual) == 0: + * # if absent - set to 0xff + * p[0] = 0xff # <<<<<<<<<<<<<< + * return + * cdef int l + */ + (__pyx_v_p[0]) = 0xff; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2124 + * # if absent - set to 0xff + * p[0] = 0xff + * return # <<<<<<<<<<<<<< + * cdef int l + * # convert to C string + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_q = __pyx_t_6; + + /* "/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 = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_l = __pyx_t_3; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2129 + * q = qual + * 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 + */ + __pyx_t_5 = (__pyx_v_src->core.l_qseq != __pyx_v_l); + if (__pyx_t_5) { + + /* "/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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __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 = 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 = 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 = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 # <<<<<<<<<<<<<< + * for k from 0 <= k < l: + * p[k] = q[k] - 33 + */ + #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 = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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: # <<<<<<<<<<<<<< + * p[k] = q[k] - 33 + * + */ + __pyx_t_9 = __pyx_v_l; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2133 + * assert src.core.l_qseq == l + * for k from 0 <= k < l: + * p[k] = q[k] - 33 # <<<<<<<<<<<<<< + * + * property query: + */ + (__pyx_v_p[__pyx_v_k]) = (((uint8_t)(__pyx_v_q[__pyx_v_k])) - 33); + } + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("csamtools.AlignedRead.qual.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2145 + * were not considered for alignment may have been retained.""" + * + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * cdef uint32_t start, end + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + uint32_t __pyx_v_start; + uint32_t __pyx_v_end; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int32_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2145); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2150 + * cdef char * s + * + * src = self._delegate # <<<<<<<<<<<<<< + * + * if src.core.l_qseq == 0: return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2152 + * src = self._delegate + * + * if src.core.l_qseq == 0: return None # <<<<<<<<<<<<<< + * + * start = query_start(src) + */ + __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_start = __pyx_t_2; + + /* "/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 = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_end = __pyx_t_2; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2157 + * end = query_end(src) + * + * return get_seq_range(src, start, end) # <<<<<<<<<<<<<< + * + * 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 = 2157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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_3); + __Pyx_AddTraceback("csamtools.AlignedRead.query.__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":2161 + * property qqual: + * """aligned query sequence quality values (None if not present)""" + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * cdef uint32_t start, end + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + uint32_t __pyx_v_start; + uint32_t __pyx_v_end; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int32_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2161); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2166 + * cdef char * q + * + * src = self._delegate # <<<<<<<<<<<<<< + * + * if src.core.l_qseq == 0: return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2168 + * src = self._delegate + * + * if src.core.l_qseq == 0: return None # <<<<<<<<<<<<<< + * + * start = query_start(src) + */ + __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_start = __pyx_t_2; + + /* "/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 = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_end = __pyx_t_2; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2173 + * end = query_end(src) + * + * return get_qual_range(src, start, end) # <<<<<<<<<<<<<< + * + * 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 = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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_3); + __Pyx_AddTraceback("csamtools.AlignedRead.qqual.__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":2177 + * property qstart: + * """start index of the aligned query portion of the sequence (0-based, inclusive)""" + * def __get__(self): # <<<<<<<<<<<<<< + * return query_start(self._delegate) + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + int32_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2177); + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 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; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.AlignedRead.qstart.__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":2182 + * property qend: + * """end index of the aligned query portion of the sequence (0-based, exclusive)""" + * def __get__(self): # <<<<<<<<<<<<<< + * return query_end(self._delegate) + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + int32_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2182); + + /* "/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) # <<<<<<<<<<<<<< + * + * 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 = 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; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.AlignedRead.qend.__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":2187 + * property qlen: + * """Length of the aligned query sequence""" + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * src = self._delegate + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + PyObject *__pyx_r = NULL; + int32_t __pyx_t_1; + int32_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2187); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2189 + * def __get__(self): + * cdef bam1_t * src + * src = self._delegate # <<<<<<<<<<<<<< + * return query_end(src)-query_start(src) + * + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2190 + * cdef bam1_t * src + * src = self._delegate + * return query_end(src)-query_start(src) # <<<<<<<<<<<<<< + * + * 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 = 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; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.AlignedRead.qlen.__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":2204 + * + * """ + * def __get__(self): # <<<<<<<<<<<<<< + * cdef char * ctag + * cdef bam1_t * src + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + uint8_t *__pyx_v_s; + char __pyx_v_auxtag[3]; + char __pyx_v_auxtype; + PyObject *__pyx_v_result; + PyObject *__pyx_v_value; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + char __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + int __pyx_t_8; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2211 + * cdef char auxtype + * + * src = self._delegate # <<<<<<<<<<<<<< + * if src.l_aux == 0: return None + * + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2212 + * + * src = self._delegate + * if src.l_aux == 0: return None # <<<<<<<<<<<<<< + * + * s = bam1_aux( src ) + */ + __pyx_t_1 = (__pyx_v_src->l_aux == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2214 + * if src.l_aux == 0: return None + * + * s = bam1_aux( src ) # <<<<<<<<<<<<<< + * result = [] + * auxtag[2] = 0 + */ + __pyx_v_s = bam1_aux(__pyx_v_src); + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2216 + * s = bam1_aux( src ) + * result = [] + * auxtag[2] = 0 # <<<<<<<<<<<<<< + * while s < (src.data + src.data_len): + * # get tag + */ + (__pyx_v_auxtag[2]) = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2217 + * result = [] + * auxtag[2] = 0 + * while s < (src.data + src.data_len): # <<<<<<<<<<<<<< + * # get tag + * auxtag[0] = s[0] + */ + while (1) { + __pyx_t_1 = (__pyx_v_s < (__pyx_v_src->data + __pyx_v_src->data_len)); + if (!__pyx_t_1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2219 + * while s < (src.data + src.data_len): + * # get tag + * auxtag[0] = s[0] # <<<<<<<<<<<<<< + * auxtag[1] = s[1] + * s += 2 + */ + (__pyx_v_auxtag[0]) = (__pyx_v_s[0]); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2220 + * # get tag + * auxtag[0] = s[0] + * auxtag[1] = s[1] # <<<<<<<<<<<<<< + * s += 2 + * auxtype = s[0] + */ + (__pyx_v_auxtag[1]) = (__pyx_v_s[1]); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2221 + * auxtag[0] = s[0] + * auxtag[1] = s[1] + * s += 2 # <<<<<<<<<<<<<< + * auxtype = s[0] + * + */ + __pyx_v_s += 2; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2222 + * auxtag[1] = s[1] + * s += 2 + * auxtype = s[0] # <<<<<<<<<<<<<< + * + * if auxtype in ('c', 'C'): + */ + __pyx_v_auxtype = (__pyx_v_s[0]); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2224 + * auxtype = s[0] + * + * if auxtype in ('c', 'C'): # <<<<<<<<<<<<<< + * value = bam_aux2i(s) + * s += 1 + */ + __pyx_t_3 = __pyx_v_auxtype; + __pyx_t_1 = (__pyx_t_3 == 'c'); + if (!__pyx_t_1) { + __pyx_t_4 = (__pyx_t_3 == 'C'); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_5; + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2225 + * + * if auxtype in ('c', 'C'): + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2226 + * if auxtype in ('c', 'C'): + * value = bam_aux2i(s) + * s += 1 # <<<<<<<<<<<<<< + * elif auxtype in ('s', 'S'): + * value = bam_aux2i(s) + */ + __pyx_v_s += 1; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2227 + * value = bam_aux2i(s) + * s += 1 + * elif auxtype in ('s', 'S'): # <<<<<<<<<<<<<< + * value = bam_aux2i(s) + * s += 2 + */ + __pyx_t_3 = __pyx_v_auxtype; + __pyx_t_1 = (__pyx_t_3 == 's'); + if (!__pyx_t_1) { + __pyx_t_5 = (__pyx_t_3 == 'S'); + __pyx_t_4 = __pyx_t_5; + } else { + __pyx_t_4 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_4; + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2228 + * s += 1 + * elif auxtype in ('s', 'S'): + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2229 + * elif auxtype in ('s', 'S'): + * value = bam_aux2i(s) + * s += 2 # <<<<<<<<<<<<<< + * elif auxtype in ('i', 'I'): + * value = bam_aux2i(s) + */ + __pyx_v_s += 2; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2230 + * value = bam_aux2i(s) + * s += 2 + * elif auxtype in ('i', 'I'): # <<<<<<<<<<<<<< + * value = bam_aux2i(s) + * s += 4 + */ + __pyx_t_3 = __pyx_v_auxtype; + __pyx_t_1 = (__pyx_t_3 == 'i'); + if (!__pyx_t_1) { + __pyx_t_4 = (__pyx_t_3 == 'I'); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_5; + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2231 + * s += 2 + * elif auxtype in ('i', 'I'): + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2232 + * elif auxtype in ('i', 'I'): + * value = bam_aux2i(s) + * s += 4 # <<<<<<<<<<<<<< + * elif auxtype == 'f': + * value = bam_aux2f(s) + */ + __pyx_v_s += 4; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2233 + * value = bam_aux2i(s) + * s += 4 + * elif auxtype == 'f': # <<<<<<<<<<<<<< + * value = bam_aux2f(s) + * s += 4 + */ + __pyx_t_1 = (__pyx_v_auxtype == 'f'); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2234 + * s += 4 + * elif auxtype == 'f': + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2235 + * elif auxtype == 'f': + * value = bam_aux2f(s) + * s += 4 # <<<<<<<<<<<<<< + * elif auxtype == 'd': + * value = bam_aux2d(s) + */ + __pyx_v_s += 4; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2236 + * value = bam_aux2f(s) + * s += 4 + * elif auxtype == 'd': # <<<<<<<<<<<<<< + * value = bam_aux2d(s) + * s += 8 + */ + __pyx_t_1 = (__pyx_v_auxtype == 'd'); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2237 + * s += 4 + * elif auxtype == 'd': + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2238 + * elif auxtype == 'd': + * value = bam_aux2d(s) + * s += 8 # <<<<<<<<<<<<<< + * elif auxtype == 'A': + * value = "%c" % bam_aux2A(s) + */ + __pyx_v_s += 8; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2239 + * value = bam_aux2d(s) + * s += 8 + * elif auxtype == 'A': # <<<<<<<<<<<<<< + * value = "%c" % bam_aux2A(s) + * s += 1 + */ + __pyx_t_1 = (__pyx_v_auxtype == 'A'); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2240 + * s += 8 + * elif auxtype == 'A': + * value = "%c" % 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 = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2241 + * elif auxtype == 'A': + * value = "%c" % bam_aux2A(s) + * s += 1 # <<<<<<<<<<<<<< + * elif auxtype in ('Z', 'H'): + * value = bam_aux2Z(s) + */ + __pyx_v_s += 1; + goto __pyx_L8; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2242 + * value = "%c" % bam_aux2A(s) + * s += 1 + * elif auxtype in ('Z', 'H'): # <<<<<<<<<<<<<< + * value = bam_aux2Z(s) + * # +1 for NULL terminated string + */ + __pyx_t_3 = __pyx_v_auxtype; + __pyx_t_1 = (__pyx_t_3 == 'Z'); + if (!__pyx_t_1) { + __pyx_t_5 = (__pyx_t_3 == 'H'); + __pyx_t_4 = __pyx_t_5; + } else { + __pyx_t_4 = __pyx_t_1; + } + __pyx_t_1 = __pyx_t_4; + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2243 + * s += 1 + * elif auxtype in ('Z', 'H'): + * value = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2245 + * value = 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 = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_s += (__pyx_t_7 + 1); + goto __pyx_L8; + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2247 + * s += len(value) + 1 + * # + * s += 1 # <<<<<<<<<<<<<< + * + * result.append( (auxtag, value) ) + */ + __pyx_v_s += 1; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2249 + * s += 1 + * + * result.append( (auxtag, value) ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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)); + __Pyx_INCREF(__pyx_v_value); + 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 = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2251 + * result.append( (auxtag, value) ) + * + * return result # <<<<<<<<<<<<<< + * + * def __set__(self, tags): + */ + __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_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("csamtools.AlignedRead.tags.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_result); + __Pyx_DECREF(__pyx_v_value); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2253 + * return result + * + * def __set__(self, tags): # <<<<<<<<<<<<<< + * cdef char * ctag + * cdef bam1_t * src + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags) { + bam1_t *__pyx_v_src; + uint8_t *__pyx_v_s; + char *__pyx_v_temp; + int __pyx_v_max_size; + int __pyx_v_size; + int __pyx_v_offset; + PyObject *__pyx_v_buffer; + PyObject *__pyx_v_pytag; + PyObject *__pyx_v_value; + PyObject *__pyx_v_t; + PyObject *__pyx_v_fmt; + PyObject *__pyx_v_pytype; + int __pyx_r; + 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; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + char *__pyx_t_11; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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); + __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + __pyx_v_fmt = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_pytype = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2262 + * cdef int max_size, size, offset + * + * src = self._delegate # <<<<<<<<<<<<<< + * max_size = 4000 + * offset = 0 + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2263 + * + * src = self._delegate + * max_size = 4000 # <<<<<<<<<<<<<< + * offset = 0 + * + */ + __pyx_v_max_size = 4000; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2264 + * src = self._delegate + * max_size = 4000 + * offset = 0 # <<<<<<<<<<<<<< + * + * if tags != None: + */ + __pyx_v_offset = 0; + + /* "/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 = 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 = 2266; __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/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 = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_v_buffer); + __pyx_v_buffer = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2271 + * buffer = ctypes.create_string_buffer(max_size) + * + * for pytag, value in tags: # <<<<<<<<<<<<<< + * t = type(value) + * if t == types.FloatType: + */ + 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 = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + } + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; + } else if (likely(PyTuple_CheckExact(__pyx_t_1))) { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; + } else { + __pyx_t_4 = PyIter_Next(__pyx_t_1); + if (!__pyx_t_4) { + 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); + } + 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_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_v_pytag); + __pyx_v_pytag = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_v_value); + __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 = 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 = 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 = 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 = 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; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_v_value); + __pyx_v_value = __pyx_t_6; + __pyx_t_6 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2272 + * + * for pytag, value in tags: + * t = type(value) # <<<<<<<<<<<<<< + * if t == types.FloatType: + * fmt, pytype = "= -127: fmt, pytype = "= -127: fmt, pytype = "= -32767: fmt, pytype = "= -127: fmt, pytype = "= -32767: fmt, pytype = "= -127: fmt, pytype = "= -32767: fmt, pytype = "= -127: fmt, pytype = "= -32767: fmt, pytype = "= -32767: fmt, pytype = " 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 = 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 = 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_69); + __Pyx_INCREF(__pyx_t_4); + __pyx_t_6 = ((PyObject *)__pyx_n_s__C); + __Pyx_INCREF(__pyx_t_6); + __Pyx_DECREF(__pyx_v_fmt); + __pyx_v_fmt = __pyx_t_4; + __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_v_pytype); + __pyx_v_pytype = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L11; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2283 + * else: + * if value <= 255: fmt, pytype = " 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value ) + * else: fmt, pytype = " 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value ) # <<<<<<<<<<<<<< + * else: fmt, pytype = " 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value ) + * else: fmt, pytype = " 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 = 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 = 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 = 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 = 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 = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_size = __pyx_t_9; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2294 + * + * size = struct.calcsize(fmt) + * if offset + size > max_size: # <<<<<<<<<<<<<< + * raise NotImplementedError("tags field too large") + * + */ + __pyx_t_2 = ((__pyx_v_offset + __pyx_v_size) > __pyx_v_max_size); + if (__pyx_t_2) { + + /* "/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 = 2295; __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_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 = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L13; + } + __pyx_L13:; + + /* "/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 = 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 = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "/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 = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + + /* "/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 = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + + /* "/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 = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + + /* "/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 = 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); + __Pyx_GIVEREF(__pyx_v_fmt); + __Pyx_INCREF(__pyx_v_buffer); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_buffer); + __Pyx_GIVEREF(__pyx_v_buffer); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __Pyx_INCREF(__pyx_v_pytype); + PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_v_pytype); + __Pyx_GIVEREF(__pyx_v_pytype); + __Pyx_INCREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2304 + * pytype, + * value ) + * offset += size # <<<<<<<<<<<<<< + * + * # delete the old data and allocate new + */ + __pyx_v_offset += __pyx_v_size; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2312 + * src.l_aux, + * offset, + * bam1_aux( src ) ) # <<<<<<<<<<<<<< + * + * src.l_aux = offset + */ + pysam_bam_update(__pyx_v_src, __pyx_v_src->l_aux, __pyx_v_offset, bam1_aux(__pyx_v_src)); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2314 + * bam1_aux( src ) ) + * + * src.l_aux = offset # <<<<<<<<<<<<<< + * + * # copy data only if there is any + */ + __pyx_v_src->l_aux = __pyx_v_offset; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2317 + * + * # copy data only if there is any + * if offset != 0: # <<<<<<<<<<<<<< + * + * # get location of new data + */ + __pyx_t_2 = (__pyx_v_offset != 0); + if (__pyx_t_2) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2320 + * + * # get location of new data + * s = bam1_aux( src ) # <<<<<<<<<<<<<< + * + * # check if there is direct path from buffer.raw to tmp + */ + __pyx_v_s = bam1_aux(__pyx_v_src); + + /* "/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 = 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 = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_temp = __pyx_t_11; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * property flag: + */ + memcpy(__pyx_v_s, __pyx_v_temp, __pyx_v_offset); + goto __pyx_L14; + } + __pyx_L14:; + + __pyx_r = 0; + 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_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("csamtools.AlignedRead.tags.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_buffer); + __Pyx_DECREF(__pyx_v_pytag); + __Pyx_DECREF(__pyx_v_value); + __Pyx_DECREF(__pyx_v_t); + __Pyx_DECREF(__pyx_v_fmt); + __Pyx_DECREF(__pyx_v_pytype); + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2328 + * property flag: + * """properties flag""" + * def __get__(self): return self._delegate.core.flag # <<<<<<<<<<<<<< + * def __set__(self, flag): self._delegate.core.flag = flag + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___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], 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 = 2328; __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.AlignedRead.flag.__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":2329 + * """properties flag""" + * def __get__(self): return self._delegate.core.flag + * def __set__(self, flag): self._delegate.core.flag = flag # <<<<<<<<<<<<<< + * + * property rname: + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag) { + int __pyx_r; + uint32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.flag.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2347 + * + * """ + * def __get__(self): return self._delegate.core.tid # <<<<<<<<<<<<<< + * def __set__(self, tid): self._delegate.core.tid = tid + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___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], 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 = 2347; __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.AlignedRead.rname.__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":2348 + * """ + * def __get__(self): return self._delegate.core.tid + * def __set__(self, tid): self._delegate.core.tid = tid # <<<<<<<<<<<<<< + * + * property tid: + */ + +static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) { + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.rname.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2361 + * + * """ + * def __get__(self): return self._delegate.core.tid # <<<<<<<<<<<<<< + * def __set__(self, tid): self._delegate.core.tid = tid + * + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___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], 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 = 2361; __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.AlignedRead.tid.__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":2362 + * """ + * def __get__(self): return self._delegate.core.tid + * def __set__(self, tid): self._delegate.core.tid = tid # <<<<<<<<<<<<<< + * + * property pos: + */ + +static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) { + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.tid.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2366 + * property pos: + * """0-based leftmost coordinate""" + * def __get__(self): return self._delegate.core.pos # <<<<<<<<<<<<<< + * def __set__(self, pos): + * ## setting the cigar string also updates the "bin" attribute + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___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], 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 = 2366; __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.AlignedRead.pos.__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":2367 + * """0-based leftmost coordinate""" + * def __get__(self): return self._delegate.core.pos + * def __set__(self, pos): # <<<<<<<<<<<<<< + * ## setting the cigar string also updates the "bin" attribute + * cdef bam1_t * src + */ + +static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) { + bam1_t *__pyx_v_src; + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __Pyx_TraceCall("__set__", __pyx_f[0], 2367); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2370 + * ## setting the cigar string also updates the "bin" attribute + * cdef bam1_t * src + * src = self._delegate # <<<<<<<<<<<<<< + * if src.core.n_cigar: + * src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) ) + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2371 + * cdef bam1_t * src + * src = self._delegate + * if src.core.n_cigar: # <<<<<<<<<<<<<< + * src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) ) + * else: + */ + if (__pyx_v_src->core.n_cigar) { + + /* "/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)) ) # <<<<<<<<<<<<<< + * else: + * src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1) + */ + __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); + goto __pyx_L5; + } + /*else*/ { + + /* "/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) # <<<<<<<<<<<<<< + * self._delegate.core.pos = pos + * property bin: + */ + __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, (__pyx_v_src->core.pos + 1)); + } + __pyx_L5:; + + /* "/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 = 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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.pos.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2378 + * property bin: + * """properties bin""" + * def __get__(self): return self._delegate.core.bin # <<<<<<<<<<<<<< + * def __set__(self, bin): self._delegate.core.bin = bin + * property rlen: + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___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], 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 = 2378; __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.AlignedRead.bin.__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":2379 + * """properties bin""" + * def __get__(self): return self._delegate.core.bin + * def __set__(self, bin): self._delegate.core.bin = bin # <<<<<<<<<<<<<< + * property rlen: + * '''length of the read (read only). Returns 0 if not given.''' + */ + +static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin) { + int __pyx_r; + uint32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.bin.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * property aend: + * '''aligned end position of the read (read only). Returns + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___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], 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 = 2382; __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.AlignedRead.rlen.__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":2386 + * '''aligned end position of the read (read only). Returns + * None if not available.''' + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * src = self._delegate + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2386); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2388 + * def __get__(self): + * cdef bam1_t * src + * src = self._delegate # <<<<<<<<<<<<<< + * if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0: + * return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/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 = 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 = 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 = 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); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_3; + } + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2390 + * src = self._delegate + * if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0: + * return None # <<<<<<<<<<<<<< + * return bam_calend(&src.core, bam1_cigar(src)) + * property alen: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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)) # <<<<<<<<<<<<<< + * property alen: + * '''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 = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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("csamtools.AlignedRead.aend.__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":2395 + * '''aligned length of the read (read only). Returns None if + * not available.''' + * def __get__(self): # <<<<<<<<<<<<<< + * cdef bam1_t * src + * src = self._delegate + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx_v_self) { + bam1_t *__pyx_v_src; + 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2395); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2397 + * def __get__(self): + * cdef bam1_t * src + * src = self._delegate # <<<<<<<<<<<<<< + * if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0: + * return None + */ + __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate; + + /* "/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 = 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 = 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 = 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); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_3; + } + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2399 + * 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_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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, # <<<<<<<<<<<<<< + * bam1_cigar(src)) - \ + * self._delegate.core.pos + */ + __Pyx_XDECREF(__pyx_r); + + /* "/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 = 2401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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("csamtools.AlignedRead.alen.__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":2406 + * property mapq: + * """mapping quality""" + * def __get__(self): return self._delegate.core.qual # <<<<<<<<<<<<<< + * def __set__(self, qual): self._delegate.core.qual = qual + * property mrnm: + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___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], 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 = 2406; __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.AlignedRead.mapq.__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":2407 + * """mapping quality""" + * def __get__(self): return self._delegate.core.qual + * def __set__(self, qual): self._delegate.core.qual = qual # <<<<<<<<<<<<<< + * property mrnm: + * """the :term:`reference` id of the mate """ + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) { + int __pyx_r; + uint32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.mapq.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self, mtid): self._delegate.core.mtid = mtid + * property mpos: + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___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], 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 = 2410; __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.AlignedRead.mrnm.__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":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 # <<<<<<<<<<<<<< + * property mpos: + * """the position of the mate""" + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid) { + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.mrnm.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2414 + * property mpos: + * """the position of the mate""" + * def __get__(self): return self._delegate.core.mpos # <<<<<<<<<<<<<< + * def __set__(self, mpos): self._delegate.core.mpos = mpos + * property isize: + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___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], 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 = 2414; __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.AlignedRead.mpos.__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":2415 + * """the position of the mate""" + * def __get__(self): return self._delegate.core.mpos + * def __set__(self, mpos): self._delegate.core.mpos = mpos # <<<<<<<<<<<<<< + * property isize: + * """the insert size""" + */ + +static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos) { + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.mpos.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2418 + * property isize: + * """the insert size""" + * def __get__(self): return self._delegate.core.isize # <<<<<<<<<<<<<< + * def __set__(self, isize): self._delegate.core.isize = isize + * property is_paired: + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___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], 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 = 2418; __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.AlignedRead.isize.__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":2419 + * """the insert size""" + * def __get__(self): return self._delegate.core.isize + * def __set__(self, isize): self._delegate.core.isize = isize # <<<<<<<<<<<<<< + * property is_paired: + * """true if read is paired in sequencing""" + */ + +static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize) { + int __pyx_r; + int32_t __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.isize.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self,val): + * if val: self._delegate.core.flag |= BAM_FPAIRED + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___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], 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 = 2422; __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.AlignedRead.is_paired.__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":2423 + * """true if read is paired in sequencing""" + * 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 + */ + +static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___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], 2423); + + /* "/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 = 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*/ { + + /* "/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 # <<<<<<<<<<<<<< + * property is_proper_pair: + * """true if read is mapped in a proper pair""" + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1); + } + __pyx_L5:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.is_paired.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self,val): + * if val: self._delegate.core.flag |= BAM_FPROPER_PAIR + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___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], 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 = 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 = 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 = 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; + __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_proper_pair.__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":2429 + * """true if read is mapped in a proper pair""" + * 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 + */ + +static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___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], 2429); + + /* "/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 = 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*/ { + + /* "/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 # <<<<<<<<<<<<<< + * property is_unmapped: + * """true if read itself is unmapped""" + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~2); + } + __pyx_L5:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.is_proper_pair.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self,val): + * if val: self._delegate.core.flag |= BAM_FUNMAP + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___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], 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 = 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 = 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 = 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; + __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_unmapped.__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":2435 + * """true if read itself is unmapped""" + * 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 + */ + +static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___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], 2435); + + /* "/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 = 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*/ { + + /* "/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 # <<<<<<<<<<<<<< + * property mate_is_unmapped: + * """true if the mate is unmapped""" + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~4); + } + __pyx_L5:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.is_unmapped.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self,val): + * if val: self._delegate.core.flag |= BAM_FMUNMAP + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___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], 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 = 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 = 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 = 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; + __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_unmapped.__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":2441 + * """true if the mate is unmapped""" + * 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 + */ + +static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/ +static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___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], 2441); + + /* "/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 = 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*/ { + + /* "/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 # <<<<<<<<<<<<<< + * property is_reverse: + * """true if read is mapped to reverse strand""" + */ + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~8); + } + __pyx_L5:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_unmapped.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 # <<<<<<<<<<<<<< + * def __set__(self,val): + * 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) { + 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], 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 = 2464; __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 = 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 = 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; + __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_read2.__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":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_FREAD2 + * else: self._delegate.core.flag &= ~BAM_FREAD2 + */ + +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], 2465); + + /* "/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_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 = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 128; + goto __pyx_L5; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2467 + * 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""" + */ + ((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_read2.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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_FSECONDARY + */ + +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], 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 = 2470; __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 = 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 = 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; + __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":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_FSECONDARY + * else: self._delegate.core.flag &= ~BAM_FSECONDARY + */ + +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], 2471); + + /* "/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_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 = 2472; __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*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2473 + * 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""" + */ + ((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.is_secondary.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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_FQCFAIL + */ + +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], 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 = 2476; __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 = 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 = 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; + __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_qcfail.__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":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_FQCFAIL + * else: self._delegate.core.flag &= ~BAM_FQCFAIL + */ + +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], 2477); + + /* "/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_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 = 2478; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { + ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 512; + goto __pyx_L5; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2479 + * 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""" + */ + ((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_qcfail.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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_FDUP + */ + +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], 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 = 2482; __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 = 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 = 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; + __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_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":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_FDUP + * else: self._delegate.core.flag &= ~BAM_FDUP + */ + +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], 2483); + + /* "/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_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 = 2484; __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; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2485 + * 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.""" + */ + ((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_duplicate.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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_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; + 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], 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; + + /* "/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); + + /* "/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++) { + + /* "/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); + + /* "/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 = 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; + + /* "/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 ) + */ + __pyx_t_2 = (__pyx_v_op == 0); + if (__pyx_t_2) { + + /* "/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++) { + + /* "/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: + + /* "/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_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_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; +} + +/* "/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 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("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); + + /* "/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_v_src->core.n_cigar == 0); + if (__pyx_t_1) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_int_0); + __pyx_r = __pyx_int_0; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 + * + */ + __pyx_v_pos = __pyx_v_src->core.pos; + + /* "/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; + + /* "/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++) { + + /* "/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; + + /* "/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) { + + /* "/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; + + /* "/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:; + + /* "/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 + * + */ + 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; + } + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2539 + * pos += l + * + * return overlap # <<<<<<<<<<<<<< + * + * def opt(self, tag): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_overlap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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 = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __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_DECREF(__pyx_v_l); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2541 + * 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 + */ + +static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/ +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; + 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; + int __pyx_t_7; + int __pyx_t_8; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("opt"); + __Pyx_TraceCall("opt", __pyx_f[0], 2541); + __pyx_v_type = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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); + + /* "/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 ) # <<<<<<<<<<<<<< + * type = chr(v[0]) + * if type == 'c' or type == 'C' or type == 's' or type == 'S': + */ + __pyx_t_2 = (__pyx_v_v == NULL); + if (__pyx_t_2) { + __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 = 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 = 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 = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/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 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 = 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 = 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 = 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; + + /* "/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 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_6; + } + __pyx_t_6 = __pyx_t_8; + } else { + __pyx_t_6 = __pyx_t_5; + } + __pyx_t_5 = __pyx_t_6; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + + /* "/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 bam_aux2i(v) # <<<<<<<<<<<<<< + * elif type == 'i' or type == 'I': + * return 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 = 2549; __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_L6; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2550 + * if type == 'c' or type == 'C' or type == 's' or type == 'S': + * return bam_aux2i(v) + * elif type == 'i' or type == 'I': # <<<<<<<<<<<<<< + * return 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 = 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 = 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 = 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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __pyx_t_2; + } else { + __pyx_t_6 = __pyx_t_5; + } + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2551 + * return bam_aux2i(v) + * elif type == 'i' or type == 'I': + * return bam_aux2i(v) # <<<<<<<<<<<<<< + * elif type == 'f' or type == 'F': + * return 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 = 2551; __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_L6; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2552 + * elif type == 'i' or type == 'I': + * return bam_aux2i(v) + * elif type == 'f' or type == 'F': # <<<<<<<<<<<<<< + * return 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 = 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 = 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 = 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 = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = __pyx_t_5; + } else { + __pyx_t_2 = __pyx_t_6; + } + if (__pyx_t_2) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2553 + * return bam_aux2i(v) + * elif type == 'f' or type == 'F': + * return bam_aux2f(v) # <<<<<<<<<<<<<< + * elif type == 'd' or type == 'D': + * return 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 = 2553; __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_L6; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2554 + * elif type == 'f' or type == 'F': + * return bam_aux2f(v) + * elif type == 'd' or type == 'D': # <<<<<<<<<<<<<< + * return 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 = 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 = 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 = 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 = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __pyx_t_6; + } else { + __pyx_t_5 = __pyx_t_2; + } + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2555 + * return bam_aux2f(v) + * elif type == 'd' or type == 'D': + * return bam_aux2d(v) # <<<<<<<<<<<<<< + * elif type == 'A': + * # 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 = 2555; __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_L6; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2556 + * elif type == 'd' or type == 'D': + * return 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 = 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 = 2556; __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":2559 + * # there might a more efficient way + * # to convert a char into a string + * return '%c' % bam_aux2A(v) # <<<<<<<<<<<<<< + * elif type == 'Z': + * return 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 = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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); + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L6; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2560 + * # to convert a char into a string + * return '%c' % bam_aux2A(v) + * elif type == 'Z': # <<<<<<<<<<<<<< + * return 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 = 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 = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2561 + * return '%c' % bam_aux2A(v) + * elif type == 'Z': + * return bam_aux2Z(v) # <<<<<<<<<<<<<< + * + * 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 = 2561; __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_L6; + } + __pyx_L6:; + + __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("csamtools.AlignedRead.opt"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_type); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2563 + * return bam_aux2Z(v) + * + * def fancy_str (self): # <<<<<<<<<<<<<< + * """returns list of fieldnames/values in pretty format for debugging + * """ + */ + +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[] = "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; + PyObject *__pyx_v_fields_names_in_order; + PyObject *__pyx_v_f; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __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; + int __pyx_t_10; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("fancy_str"); + __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); + + /* "/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 = 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; + + /* "/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 = 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_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; + + /* "/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 = 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)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tid)); + __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__mtid)); + PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__mtid)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mtid)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__mpos)); + PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__mpos)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mpos)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__isize)); + PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__isize)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__isize)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__flag)); + PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__flag)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__flag)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__n_cigar)); + PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__n_cigar)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_cigar)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__cigar)); + PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__cigar)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cigar)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__qual)); + PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__qual)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qual)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__bin)); + PyList_SET_ITEM(__pyx_t_1, 9, ((PyObject *)__pyx_n_s__bin)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bin)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__l_qname)); + PyList_SET_ITEM(__pyx_t_1, 10, ((PyObject *)__pyx_n_s__l_qname)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_qname)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__qname)); + PyList_SET_ITEM(__pyx_t_1, 11, ((PyObject *)__pyx_n_s__qname)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qname)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__l_qseq)); + PyList_SET_ITEM(__pyx_t_1, 12, ((PyObject *)__pyx_n_s__l_qseq)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_qseq)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__qseq)); + PyList_SET_ITEM(__pyx_t_1, 13, ((PyObject *)__pyx_n_s__qseq)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qseq)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__bqual)); + PyList_SET_ITEM(__pyx_t_1, 14, ((PyObject *)__pyx_n_s__bqual)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bqual)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__l_aux)); + PyList_SET_ITEM(__pyx_t_1, 15, ((PyObject *)__pyx_n_s__l_aux)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_aux)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__m_data)); + PyList_SET_ITEM(__pyx_t_1, 16, ((PyObject *)__pyx_n_s__m_data)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__m_data)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__data_len)); + PyList_SET_ITEM(__pyx_t_1, 17, ((PyObject *)__pyx_n_s__data_len)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__data_len)); + __Pyx_DECREF(((PyObject *)__pyx_v_fields_names_in_order)); + __pyx_v_fields_names_in_order = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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: # <<<<<<<<<<<<<< + * if not f in self.__dict__: + * continue + */ + 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 = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + for (;;) { + 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++; + __Pyx_DECREF(__pyx_v_f); + __pyx_v_f = __pyx_t_3; + __pyx_t_3 = 0; + + /* "/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 = 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 = 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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2593 + * 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))) + * + */ + goto __pyx_L5_continue; + goto __pyx_L7; + } + __pyx_L7:; + + /* "/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))) # <<<<<<<<<<<<<< + * + * 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 = 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 = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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_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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_3 = 0; + __pyx_t_7 = 0; + __pyx_t_9 = 0; + __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 = 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; + + /* "/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 = 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 = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(PyList_CheckExact(__pyx_t_9))) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_9)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + } else if (likely(PyTuple_CheckExact(__pyx_t_9))) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_9)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + } else { + __pyx_t_1 = PyIter_Next(__pyx_t_9); + if (!__pyx_t_1) { + 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); + } + __Pyx_DECREF(__pyx_v_f); + __pyx_v_f = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2597 + * + * for f in self.__dict__: + * if not f in field_names: # <<<<<<<<<<<<<< + * ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f))) + * return ret_string + */ + if (unlikely(((PyObject *)__pyx_v_field_names) == Py_None)) { + __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 = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = (!__pyx_t_5); + if (__pyx_t_4) { + + /* "/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))) # <<<<<<<<<<<<<< + * return ret_string + * + */ + 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 = 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 = 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 = 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 = 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 = 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_INCREF(((PyObject *)__pyx_kp_s_8)); + PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8)); + 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_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 = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + goto __pyx_L10; + } + __pyx_L10:; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "/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 # <<<<<<<<<<<<<< + * + * cdef class PileupProxy: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_ret_string)); + __pyx_r = ((PyObject *)__pyx_v_ret_string); + 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_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("csamtools.AlignedRead.fancy_str"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_ret_string); + __Pyx_DECREF(__pyx_v_field_names); + __Pyx_DECREF(__pyx_v_fields_names_in_order); + __Pyx_DECREF(__pyx_v_f); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2623 + * cdef int n_pu + * + * def __init__(self): # <<<<<<<<<<<<<< + * raise TypeError("This class cannot be instantiated from Python") + * + */ + +static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__init__"); + __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; + + /* "/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 = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.PileupProxy.__init__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2626 + * raise TypeError("This class cannot be instantiated from Python") + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "\t".join( map(str, (self.tid, self.pos, self.n))) +\ + * "\n" +\ + */ + +static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11PileupProxy___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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__str__"); + __Pyx_TraceCall("__str__", __pyx_f[0], 2626); + + /* "/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_XDECREF(__pyx_r); + + /* "/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 = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "/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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __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 = 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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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 = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "/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 = 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 = 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 = 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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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 = 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; + __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_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("csamtools.PileupProxy.__str__"); + __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":2633 + * property tid: + * '''the chromosome ID as is defined in the header''' + * def __get__(self): return self.tid # <<<<<<<<<<<<<< + * + * property n: + */ + +static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___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], 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 = 2633; __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.PileupProxy.tid.__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":2637 + * property n: + * '''number of reads mapping to this column.''' + * def __get__(self): return self.n_pu # <<<<<<<<<<<<<< + * def __set__(self, n): self.n_pu = n + * + */ + +static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___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], 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 = 2637; __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.PileupProxy.n.__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":2638 + * '''number of reads mapping to this column.''' + * def __get__(self): return self.n_pu + * def __set__(self, n): self.n_pu = n # <<<<<<<<<<<<<< + * + * property pos: + */ + +static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n); /*proto*/ +static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n) { + int __pyx_r; + int __pyx_t_1; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__set__"); + __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; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.PileupProxy.n.__set__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2641 + * + * property pos: + * def __get__(self): return self.pos # <<<<<<<<<<<<<< + * + * property pileups: + */ + +static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___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], 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 = 2641; __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.PileupProxy.pos.__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":2645 + * property pileups: + * '''list of reads (:class:`pysam.PileupRead`) aligned to this column''' + * def __get__(self): # <<<<<<<<<<<<<< + * cdef int x + * pileups = [] + */ + +static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__pyx_v_self) { + int __pyx_v_x; + PyObject *__pyx_v_pileups; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2645); + __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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 = 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; + + /* "/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: # <<<<<<<<<<<<<< + * pileups.append( makePileupRead( &(self.plp[x])) ) + * return pileups + */ + __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++) { + + /* "/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])) ) # <<<<<<<<<<<<<< + * return pileups + * + */ + if (unlikely(__pyx_v_pileups == Py_None)) { + 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 = 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 = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2652 + * for x from 0 <= x < self.n_pu: + * pileups.append( makePileupRead( &(self.plp[x])) ) + * return pileups # <<<<<<<<<<<<<< + * + * cdef class PileupRead: + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_pileups)); + __pyx_r = ((PyObject *)__pyx_v_pileups); + 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.PileupProxy.pileups.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_pileups); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2667 + * uint32_t _is_tail + * + * def __init__(self): # <<<<<<<<<<<<<< + * raise TypeError("This class cannot be instantiated from Python") + * + */ + +static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__init__"); + __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; + + /* "/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 = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.PileupRead.__init__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2670 + * raise TypeError("This class cannot be instantiated from Python") + * + * 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 ) ) ) + * + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead___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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__str__"); + __Pyx_TraceCall("__str__", __pyx_f[0], 2670); + + /* "/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 ) ) ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __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_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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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; + __pyx_r = __pyx_t_9; + __pyx_t_9 = 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_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("csamtools.PileupRead.__str__"); + __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":2675 + * property alignment: + * """a :class:`pysam.AlignedRead` object of the aligned read""" + * def __get__(self): # <<<<<<<<<<<<<< + * return self._alignment + * property qpos: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 2675); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2676 + * """a :class:`pysam.AlignedRead` object of the aligned read""" + * def __get__(self): + * return self._alignment # <<<<<<<<<<<<<< + * property qpos: + * """position of the read base at the pileup site, 0-based""" + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_alignment)); + __pyx_r = ((PyObject *)((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_alignment); + 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":2679 + * property qpos: + * """position of the read base at the pileup site, 0-based""" + * def __get__(self): # <<<<<<<<<<<<<< + * return self._qpos + * property indel: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___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], 2679); + + /* "/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 # <<<<<<<<<<<<<< + * property indel: + * """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 = 2680; __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.PileupRead.qpos.__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":2683 + * property indel: + * """indel length; 0 for no indel, positive for ins and negative for del""" + * def __get__(self): # <<<<<<<<<<<<<< + * return self._indel + * property is_del: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___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], 2683); + + /* "/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 # <<<<<<<<<<<<<< + * property is_del: + * """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 = 2684; __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.PileupRead.indel.__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":2687 + * property is_del: + * """1 iff the base on the padded read is a deletion""" + * def __get__(self): # <<<<<<<<<<<<<< + * return self._is_del + * property is_head: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___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], 2687); + + /* "/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 # <<<<<<<<<<<<<< + * property is_head: + * 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 = 2688; __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.PileupRead.is_del.__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":2690 + * return self._is_del + * property is_head: + * def __get__(self): # <<<<<<<<<<<<<< + * return self._is_head + * property is_tail: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___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], 2690); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2691 + * property is_head: + * def __get__(self): + * return self._is_head # <<<<<<<<<<<<<< + * property is_tail: + * 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 = 2691; __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.PileupRead.is_head.__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":2693 + * return self._is_head + * property is_tail: + * def __get__(self): # <<<<<<<<<<<<<< + * return self._is_tail + * property level: + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___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], 2693); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2694 + * property is_tail: + * def __get__(self): + * return self._is_tail # <<<<<<<<<<<<<< + * property level: + * 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 = 2694; __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.PileupRead.is_tail.__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":2696 + * return self._is_tail + * property level: + * def __get__(self): # <<<<<<<<<<<<<< + * return self._level + * + */ + +static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___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], 2696); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2697 + * property level: + * def __get__(self): + * return self._level # <<<<<<<<<<<<<< + * + * 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 = 2697; __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.PileupRead.level.__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":2701 + * class Outs: + * '''http://mail.python.org/pipermail/python-list/2000-June/038406.html''' + * def __init__(self, id = 1): # <<<<<<<<<<<<<< + * self.streams = [] + * self.id = id + */ + +static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +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; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__id,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__init__"); + __Pyx_TraceCall("__init__", __pyx_f[0], 2701); + __pyx_self = __pyx_self; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[2] = {0,0}; + values[1] = ((PyObject *)__pyx_int_1); + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__id); + 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), "__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]; + } else { + __pyx_v_id = ((PyObject *)__pyx_int_1); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: __pyx_v_id = 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, 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:; + + /* "/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 = 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 = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + + /* "/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 = 2703; __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_AddTraceback("csamtools.Outs.__init__"); + __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":2705 + * self.id = id + * + * def setdevice(self, filename): # <<<<<<<<<<<<<< + * '''open an existing file, like "/dev/null"''' + * fd = os.open(filename, os.O_WRONLY) + */ + +static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +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; + PyObject *__pyx_v_filename = 0; + PyObject *__pyx_v_fd; + 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_TraceDeclarations + __Pyx_RefNannySetupContext("setdevice"); + __Pyx_TraceCall("setdevice", __pyx_f[0], 2705); + __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("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 = 2705; __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("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(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_filename); + 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 = 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; + __Pyx_DECREF(__pyx_v_fd); + __pyx_v_fd = __pyx_t_3; + __pyx_t_3 = 0; + + /* "/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 = 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 = 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 = 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; + __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("csamtools.Outs.setdevice"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_fd); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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); + */ + +static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +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; + PyObject *__pyx_v_filename = 0; + PyObject *__pyx_v_fd; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + 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__filename,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("setfile"); + __Pyx_TraceCall("setfile", __pyx_f[0], 2710); + __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("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 = 2710; __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("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(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_filename); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_0660); + 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 = 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; + __Pyx_DECREF(__pyx_v_fd); + __pyx_v_fd = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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 = 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 = 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 = 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; + __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_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("csamtools.Outs.setfile"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_fd); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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) + */ + +static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +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; + PyObject *__pyx_v_ofd; + 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__fd,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("setfd"); + __Pyx_TraceCall("setfd", __pyx_f[0], 2715); + __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__fd); + if (likely(values[1])) kw_args--; + else { + __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 = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_self = values[0]; + __pyx_v_fd = 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_fd = PyTuple_GET_ITEM(__pyx_args, 1); + } + 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 = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.Outs.setfd"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_ofd = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_v_ofd); + __pyx_v_ofd = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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. + * 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 = 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 = 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; + + /* "/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. + */ + __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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2719 + * self.streams.append(ofd) + * sys.stdout.flush() # Buffered data goes to old stream. + * sys.stderr.flush() # Buffered data goes to old stream. # <<<<<<<<<<<<<< + * os.dup2(fd, self.id) # Open unit 1 on new stream. + * os.close(fd) # Close other unit (look out, caller.) + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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_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_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_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_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; + + /* "/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_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_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_3, 0, __pyx_v_fd); + __Pyx_GIVEREF(__pyx_v_fd); + __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_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; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.Outs.setfd"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_ofd); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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: + */ + +static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +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; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("restore"); + __Pyx_TraceCall("restore", __pyx_f[0], 2723); + __pyx_self = __pyx_self; + + /* "/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 = 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 = 2725; __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/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 = 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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __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 = 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; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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; + + /* "/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 = 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 = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + 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_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("csamtools.Outs.restore"); + __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":2734 + * del self.streams[-1] + * + * def _samtools_dispatch( method, # <<<<<<<<<<<<<< + * args = (), + * catch_stdout = True, + */ + +static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +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; + PyObject *__pyx_v_catch_stdout = 0; + PyObject *__pyx_v_catch_stderr = 0; + PyObject *__pyx_v_stderr_h; + PyObject *__pyx_v_stderr_f; + PyObject *__pyx_v_stderr_save; + PyObject *__pyx_v_stdout_h; + PyObject *__pyx_v_stdout_f; + PyObject *__pyx_v_stdout_save; + char **__pyx_v_cargs; + int __pyx_v_i; + int __pyx_v_n; + int __pyx_v_retval; + PyObject *__pyx_v_out_stdout; + PyObject *__pyx_v_out_stderr; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + char *__pyx_t_8; + int __pyx_t_9; + 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], 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}; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2735 + * + * def _samtools_dispatch( method, + * args = (), # <<<<<<<<<<<<<< + * catch_stdout = True, + * catch_stderr = False, + */ + values[1] = ((PyObject *)__pyx_empty_tuple); + 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); + 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__method); + 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__args); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__catch_stdout); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__catch_stderr); + 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), "_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]; + __pyx_v_catch_stdout = values[2]; + __pyx_v_catch_stderr = values[3]; + } else { + __pyx_v_args = ((PyObject *)__pyx_empty_tuple); + __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); + case 2: __pyx_v_args = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_method = 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("_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(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_args); + __pyx_v_stderr_h = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_stderr_f = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_stderr_save = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_stdout_h = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_stdout_f = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_stdout_save = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_out_stdout = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_out_stderr = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 2762; __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/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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) { + + /* "/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 = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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 = 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 = 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 = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { + + /* "/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 = 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 = 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 = 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)) { + 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_stderr_h); + __pyx_v_stderr_h = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_v_stderr_f); + __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 = 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 = 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 = 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 = 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; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_v_stderr_f); + __pyx_v_stderr_f = __pyx_t_1; + __pyx_t_1 = 0; + } + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_v_stderr_save); + __pyx_v_stderr_save = __pyx_t_3; + __pyx_t_3 = 0; + + /* "/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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 2772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { + + /* "/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 = 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 = 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 = 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)) { + 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_stdout_h); + __pyx_v_stdout_h = __pyx_t_1; + __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_stdout_f); + __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 = 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 = 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 = 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 = 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; + __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_stdout_f); + __pyx_v_stdout_f = __pyx_t_3; + __pyx_t_3 = 0; + } + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_v_stdout_save); + __pyx_v_stdout_save = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/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 = 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 = 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 = 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; + + /* "/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 = 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 = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { + + /* "/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_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 = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __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 = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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 = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __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 = 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); + __pyx_v_args = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L10; + } + __pyx_L10:; + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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 = 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 = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_n = __pyx_t_7; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2791 + * n = len(args) + * # allocate two more for first (dummy) argument (contains command) + * cargs = calloc( n+2, sizeof( char *) ) # <<<<<<<<<<<<<< + * cargs[0] = "samtools" + * cargs[1] = method + */ + __pyx_v_cargs = ((char **)calloc((__pyx_v_n + 2), (sizeof(char *)))); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2792 + * # allocate two more for first (dummy) argument (contains command) + * cargs = calloc( n+2, sizeof( char *) ) + * cargs[0] = "samtools" # <<<<<<<<<<<<<< + * cargs[1] = method + * for i from 0 <= i < n: cargs[i+2] = args[i] + */ + (__pyx_v_cargs[0]) = __pyx_k__samtools; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2793 + * cargs = 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 = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + (__pyx_v_cargs[1]) = __pyx_t_8; + + /* "/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] # <<<<<<<<<<<<<< + * retval = pysam_dispatch(n+2, cargs) + * free( cargs ) + */ + __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 = 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 = 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; + } + + /* "/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) # <<<<<<<<<<<<<< + * free( cargs ) + * + */ + __pyx_v_retval = pysam_dispatch((__pyx_v_n + 2), __pyx_v_cargs); + + /* "/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 ) # <<<<<<<<<<<<<< + * + * # restore stdout/stderr. This will also flush, so + */ + free(__pyx_v_cargs); + + /* "/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 = 2800; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { + + /* "/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 = 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 = 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; + + /* "/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 = 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); + __Pyx_GIVEREF(__pyx_v_stdout_f); + __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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L14; + } + /*else*/ { + + /* "/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 = 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); + __pyx_t_1 = 0; + } + __pyx_L14:; + + /* "/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 = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { + + /* "/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 = 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 = 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; + + /* "/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 = 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); + __Pyx_GIVEREF(__pyx_v_stderr_f); + __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 = 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L15; + } + /*else*/ { + + /* "/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 = 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); + __pyx_t_3 = 0; + } + __pyx_L15:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2814 + * out_stderr = [] + * + * return retval, out_stderr, out_stdout # <<<<<<<<<<<<<< + * + * 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 = 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 = 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); + __Pyx_INCREF(__pyx_v_out_stderr); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_stderr); + __Pyx_GIVEREF(__pyx_v_out_stderr); + __Pyx_INCREF(__pyx_v_out_stdout); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_out_stdout); + __Pyx_GIVEREF(__pyx_v_out_stdout); + __pyx_t_3 = 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_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("csamtools._samtools_dispatch"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_stderr_h); + __Pyx_DECREF(__pyx_v_stderr_f); + __Pyx_DECREF(__pyx_v_stderr_save); + __Pyx_DECREF(__pyx_v_stdout_h); + __Pyx_DECREF(__pyx_v_stdout_f); + __Pyx_DECREF(__pyx_v_stdout_save); + __Pyx_DECREF(__pyx_v_out_stdout); + __Pyx_DECREF(__pyx_v_out_stderr); + __Pyx_DECREF(__pyx_v_args); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2829 + * property tid: + * '''the chromosome ID as is defined in the header''' + * def __get__(self): # <<<<<<<<<<<<<< + * return self._tid + * + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___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], 2829); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2830 + * '''the chromosome ID as is defined in the header''' + * def __get__(self): + * return self._tid # <<<<<<<<<<<<<< + * + * 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 = 2830; __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.SNPCall.tid.__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":2834 + * property pos: + * '''nucleotide position of SNP.''' + * def __get__(self): return self._pos # <<<<<<<<<<<<<< + * + * property reference_base: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___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], 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 = 2834; __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.SNPCall.pos.__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":2838 + * property reference_base: + * '''reference base at pos. ``N`` if no reference sequence supplied.''' + * def __get__(self): return PyString_FromStringAndSize( &self._reference_base, 1 ) # <<<<<<<<<<<<<< + * + * property genotype: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___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], 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 = 2838; __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.SNPCall.reference_base.__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":2842 + * property genotype: + * '''the genotype called.''' + * def __get__(self): return PyString_FromStringAndSize( &self._genotype, 1 ) # <<<<<<<<<<<<<< + * + * property consensus_quality: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___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], 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 = 2842; __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.SNPCall.genotype.__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":2846 + * property consensus_quality: + * '''the genotype quality (Phred-scaled).''' + * def __get__(self): return self._consensus_quality # <<<<<<<<<<<<<< + * + * property snp_quality: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_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], 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 = 2846; __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.SNPCall.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":2850 + * property snp_quality: + * '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.''' + * def __get__(self): return self._snp_quality # <<<<<<<<<<<<<< + * + * property mapping_quality: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_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], 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 = 2850; __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.SNPCall.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":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 # <<<<<<<<<<<<<< + * + * property coverage: + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_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], 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 = 2854; __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.SNPCall.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":2858 + * property coverage: + * '''coverage or read depth - the number of reads involved in the call.''' + * def __get__(self): return self._coverage # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall_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], 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 = 2858; __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.SNPCall.coverage.__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":2860 + * def __get__(self): return self._coverage + * + * def __str__(self): # <<<<<<<<<<<<<< + * + * return "\t".join( map(str, ( + */ + +static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_7SNPCall___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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__str__"); + __Pyx_TraceCall("__str__", __pyx_f[0], 2860); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2862 + * def __str__(self): + * + * 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 = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "/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 = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + + /* "/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 = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + + /* "/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 = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + + /* "/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 = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + + /* "/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 = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + + /* "/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 = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + + /* "/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 = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + + /* "/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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_10, 7, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __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_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))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type))); + 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 = 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 = 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 = 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; + __pyx_r = __pyx_t_10; + __pyx_t_10 = 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_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_AddTraceback("csamtools.SNPCall.__str__"); + __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":2891 + * cdef IteratorColumn iter + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * IteratorColumn iterator_column, + * **kwargs ): + */ + +static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_13SNPCallerBase___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], 2891); + __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 = 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) { + 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 = 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 = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2895 + * **kwargs ): + * + * self.iter = iterator_column # <<<<<<<<<<<<<< + * self.c = bam_maqcns_init() + * + */ + __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column)); + __Pyx_GOTREF(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter); + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2896 + * + * self.iter = iterator_column + * self.c = bam_maqcns_init() # <<<<<<<<<<<<<< + * + * # set the default parameterization according to + */ + ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c = bam_maqcns_init(); + + /* "/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 ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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 = 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; + + /* "/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 ) # <<<<<<<<<<<<<< + * # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 ) + * 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 = 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 = 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 = 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; + + /* "/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 ) # <<<<<<<<<<<<<< + * self.c.het_rate = kwargs.get( "het_rate", 0.001 ) + * 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 = 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 = 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 = 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; + + /* "/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 ) # <<<<<<<<<<<<<< + * 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 = 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 = 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 = 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 = 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; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2910 + * self.c.theta = kwargs.get( "theta", 0.83 ) + * + * if self.c.errmod != BAM_ERRMOD_MAQ2: # <<<<<<<<<<<<<< + * self.c.theta += 0.02 + * + */ + __pyx_t_5 = (((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod != BAM_ERRMOD_MAQ2); + if (__pyx_t_5) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2911 + * + * if self.c.errmod != BAM_ERRMOD_MAQ2: + * self.c.theta += 0.02 # <<<<<<<<<<<<<< + * + * # call prepare AFTER setting parameters + */ + ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta += 0.02; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2914 + * + * # call prepare AFTER setting parameters + * bam_maqcns_prepare( self.c ) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + bam_maqcns_prepare(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.SNPCallerBase.__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":2916 + * bam_maqcns_prepare( self.c ) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * bam_maqcns_destroy( self.c ) + * + */ + +static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self) { + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dealloc__"); + __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2916); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2917 + * + * def __dealloc__(self): + * bam_maqcns_destroy( self.c ) # <<<<<<<<<<<<<< + * + * cdef __dump( self, glf1_t * g, uint32_t cns, int rb ): + */ + bam_maqcns_destroy(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c); + + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2919 + * bam_maqcns_destroy( self.c ) + * + * cdef __dump( self, glf1_t * g, uint32_t cns, int rb ): # <<<<<<<<<<<<<< + * '''debugging output.''' + * + */ + +static PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9csamtools_SNPCallerBase *__pyx_v_self, glf1_t *__pyx_v_g, uint32_t __pyx_v_cns, int __pyx_v_rb) { + int __pyx_v_x; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__dump"); + __Pyx_TraceCall("__dump", __pyx_f[0], 2919); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2922 + * '''debugging output.''' + * + * pysam_dump_glf( g, self.c ); # <<<<<<<<<<<<<< + * print "" + * for x in range(self.iter.n_plp): + */ + pysam_dump_glf(__pyx_v_g, __pyx_v_self->c); + + /* "/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 = 2923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2924 + * pysam_dump_glf( g, self.c ); + * print "" + * for x in range(self.iter.n_plp): # <<<<<<<<<<<<<< + * print "--> read %i %s %i" % (x, + * bam1_qname(self.iter.plp[x].b), + */ + __pyx_t_1 = __pyx_v_self->iter->n_plp; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_x = __pyx_t_2; + + /* "/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 = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + + /* "/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 = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + + /* "/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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __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 = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + } + + /* "/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 = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + + /* "/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 = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + + /* "/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 = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + + /* "/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 = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + + /* "/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 = 2935; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + + /* "/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 = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + + /* "/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 = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + + /* "/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 = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + + /* "/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 = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + + /* "/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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_13, 5, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 6, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 7, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 8, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 9, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_4 = 0; + __pyx_t_3 = 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_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 = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2943 + * ) + * + * printf("-------------------------------------\n"); # <<<<<<<<<<<<<< + * sys.stdout.flush() + * + */ + printf(__pyx_k_106); + + /* "/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 = 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 = 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 = 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 = 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; + + __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_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_AddTraceback("csamtools.SNPCallerBase.__dump"); + __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":2960 + * """ + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * IteratorColumn iterator_column, + * **kwargs ): + */ + +static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_16IteratorSNPCalls___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; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0}; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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)) { + 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 = 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) { + 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 = 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 = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2964 + * **kwargs ): + * + * assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence" # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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_107)); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__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":2966 + * assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence" + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__iter__"); + __Pyx_TraceCall("__iter__", __pyx_f[0], 2966); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2967 + * + * def __iter__(self): + * 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_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2969 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * """ + */ + +static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_9csamtools_16IteratorSNPCalls___next__[] = "python version of next().\n "; +struct wrapperbase __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__; +static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self) { + char *__pyx_v_seq; + int __pyx_v_seq_len; + int __pyx_v_rb; + uint32_t __pyx_v_cns; + glf1_t *__pyx_v_g; + struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__next__"); + __Pyx_TraceCall("__next__", __pyx_f[0], 2969); + __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2974 + * + * # 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_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2976 + * self.iter.cnext() + * + * if self.iter.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0); + if (__pyx_t_1) { + + /* "/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 = 2977; __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 = 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 = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2979 + * raise ValueError("error during iteration" ) + * + * if self.iter.plp == NULL: # <<<<<<<<<<<<<< + * raise StopIteration + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2980 + * + * if self.iter.plp == NULL: + * raise StopIteration # <<<<<<<<<<<<<< + * + * cdef char * seq = self.iter.getSequence() + */ + __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2982 + * raise StopIteration + * + * cdef char * seq = self.iter.getSequence() # <<<<<<<<<<<<<< + * cdef int seq_len = self.iter.seq_len + * + */ + __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); + + /* "/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 = 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 = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_seq_len = __pyx_t_4; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2985 + * cdef int seq_len = self.iter.seq_len + * + * assert seq != NULL # <<<<<<<<<<<<<< + * + * # reference base + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + if (unlikely(!(__pyx_v_seq != NULL))) { + PyErr_SetNone(PyExc_AssertionError); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2988 + * + * # 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_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len); + if (__pyx_t_1) { + + /* "/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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_3 = 0; + __pyx_t_2 = 0; + __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 = 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 = 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 = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/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] # <<<<<<<<<<<<<< + * cdef uint32_t cns + * cdef glf1_t * g + */ + __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos]); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2998 + * self.iter.plp, + * bam_nt16_table[rb], + * self.c ) # <<<<<<<<<<<<<< + * + * if pysam_glf_depth( g ) == 0: + */ + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3000 + * self.c ) + * + * if pysam_glf_depth( g ) == 0: # <<<<<<<<<<<<<< + * cns = 0xfu << 28 | 0xf << 24 + * else: + */ + __pyx_t_1 = (pysam_glf_depth(__pyx_v_g) == 0); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3001 + * + * if pysam_glf_depth( g ) == 0: + * cns = 0xfu << 28 | 0xf << 24 # <<<<<<<<<<<<<< + * else: + * cns = glf2cns(g, (self.c.q_r + .499)) + */ + __pyx_v_cns = 4278190080U; + goto __pyx_L8; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3003 + * cns = 0xfu << 28 | 0xf << 24 + * else: + * cns = glf2cns(g, (self.c.q_r + .499)) # <<<<<<<<<<<<<< + * + * free(g) + */ + __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.c->q_r + .499))); + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3005 + * cns = glf2cns(g, (self.c.q_r + .499)) + * + * free(g) # <<<<<<<<<<<<<< + * + * cdef SNPCall call + */ + free(__pyx_v_g); + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3010 + * + * call = SNPCall() + * call._tid = self.iter.tid # <<<<<<<<<<<<<< + * call._pos = self.iter.pos + * call._reference_base = rb + */ + __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->tid; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3011 + * call = SNPCall() + * call._tid = self.iter.tid + * call._pos = self.iter.pos # <<<<<<<<<<<<<< + * call._reference_base = rb + * call._genotype = bam_nt16_rev_table[cns>>28] + */ + __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3012 + * call._tid = self.iter.tid + * call._pos = self.iter.pos + * call._reference_base = rb # <<<<<<<<<<<<<< + * call._genotype = bam_nt16_rev_table[cns>>28] + * call._consensus_quality = cns >> 8 & 0xff + */ + __pyx_v_call->_reference_base = __pyx_v_rb; + + /* "/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] # <<<<<<<<<<<<<< + * call._consensus_quality = cns >> 8 & 0xff + * call._snp_quality = cns & 0xff + */ + __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]); + + /* "/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 # <<<<<<<<<<<<<< + * call._snp_quality = cns & 0xff + * call._rms_mapping_quality = cns >> 16&0xff + */ + __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * call._rms_mapping_quality = cns >> 16&0xff + * call._coverage = self.iter.n_plp + */ + __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * call._coverage = self.iter.n_plp + * + */ + __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * + * return call + */ + __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3019 + * call._coverage = self.iter.n_plp + * + * return call # <<<<<<<<<<<<<< + * + * cdef class SNPCaller( SNPCallerBase ): + */ + __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_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3035 + * + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * IteratorColumn iterator_column, + * **kwargs ): + */ + +static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_9SNPCaller___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], 3035); + __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 = 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) { + 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 = 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 = 3036; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("csamtools.SNPCaller.__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":3041 + * pass + * + * def call(self, reference, int pos ): # <<<<<<<<<<<<<< + * """call a snp on chromosome *reference* + * and position *pos*. + */ + +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[] = "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; + int __pyx_v_tid; + char *__pyx_v_seq; + int __pyx_v_seq_len; + int __pyx_v_rb; + uint32_t __pyx_v_cns; + glf1_t *__pyx_v_g; + struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call; + 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], 3041); + 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 = 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 = 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 = 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 = 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 = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("csamtools.SNPCaller.call"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tid = __pyx_t_4; + + /* "/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 = 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 = 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 = 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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3052 + * self.iter.reset( tid, pos, pos + 1 ) + * + * while 1: # <<<<<<<<<<<<<< + * self.iter.cnext() + * + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3053 + * + * while 1: + * self.iter.cnext() # <<<<<<<<<<<<<< + * + * if self.iter.n_plp < 0: + */ + ((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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3055 + * self.iter.cnext() + * + * if self.iter.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0); + if (__pyx_t_6) { + + /* "/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 = 3056; __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 = 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 = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3058 + * raise ValueError("error during iteration" ) + * + * if self.iter.plp == NULL: # <<<<<<<<<<<<<< + * raise ValueError( "no reads in region - no call" ) + * + */ + __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL); + if (__pyx_t_6) { + + /* "/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 = 3059; __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 = 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 = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L9; + } + __pyx_L9:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3061 + * raise ValueError( "no reads in region - no call" ) + * + * if self.iter.pos == pos: break # <<<<<<<<<<<<<< + * + * cdef char * seq = self.iter.getSequence() + */ + __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos); + if (__pyx_t_6) { + goto __pyx_L7_break; + goto __pyx_L10; + } + __pyx_L10:; + } + __pyx_L7_break:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3063 + * if self.iter.pos == pos: break + * + * cdef char * seq = self.iter.getSequence() # <<<<<<<<<<<<<< + * cdef int seq_len = self.iter.seq_len + * + */ + __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); + + /* "/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 = 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 = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_seq_len = __pyx_t_4; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3066 + * cdef int seq_len = self.iter.seq_len + * + * assert seq != NULL # <<<<<<<<<<<<<< + * + * # reference base + */ + #ifndef PYREX_WITHOUT_ASSERTIONS + if (unlikely(!(__pyx_v_seq != NULL))) { + PyErr_SetNone(PyExc_AssertionError); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3066; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3069 + * + * # 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_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len); + if (__pyx_t_6) { + + /* "/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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __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 = 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 = 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 = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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] # <<<<<<<<<<<<<< + * cdef uint32_t cns + * cdef glf1_t * g + */ + __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos]); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3079 + * self.iter.plp, + * bam_nt16_table[rb], + * self.c ) # <<<<<<<<<<<<<< + * + * + */ + __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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3082 + * + * + * if pysam_glf_depth( g ) == 0: # <<<<<<<<<<<<<< + * cns = 0xfu << 28 | 0xf << 24 + * else: + */ + __pyx_t_6 = (pysam_glf_depth(__pyx_v_g) == 0); + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3083 + * + * if pysam_glf_depth( g ) == 0: + * cns = 0xfu << 28 | 0xf << 24 # <<<<<<<<<<<<<< + * else: + * cns = glf2cns(g, (self.c.q_r + .499)) + */ + __pyx_v_cns = 4278190080U; + goto __pyx_L12; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3085 + * cns = 0xfu << 28 | 0xf << 24 + * else: + * cns = glf2cns(g, (self.c.q_r + .499)) # <<<<<<<<<<<<<< + * + * free(g) + */ + __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.c->q_r + .499))); + } + __pyx_L12:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3087 + * cns = glf2cns(g, (self.c.q_r + .499)) + * + * free(g) # <<<<<<<<<<<<<< + * + * cdef SNPCall call + */ + free(__pyx_v_g); + + /* "/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 = 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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3092 + * + * call = SNPCall() + * call._tid = self.iter.tid # <<<<<<<<<<<<<< + * call._pos = self.iter.pos + * call._reference_base = rb + */ + __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->tid; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3093 + * call = SNPCall() + * call._tid = self.iter.tid + * call._pos = self.iter.pos # <<<<<<<<<<<<<< + * call._reference_base = rb + * call._genotype = bam_nt16_rev_table[cns>>28] + */ + __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3094 + * call._tid = self.iter.tid + * call._pos = self.iter.pos + * call._reference_base = rb # <<<<<<<<<<<<<< + * call._genotype = bam_nt16_rev_table[cns>>28] + * call._consensus_quality = cns >> 8 & 0xff + */ + __pyx_v_call->_reference_base = __pyx_v_rb; + + /* "/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] # <<<<<<<<<<<<<< + * call._consensus_quality = cns >> 8 & 0xff + * call._snp_quality = cns & 0xff + */ + __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]); + + /* "/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 # <<<<<<<<<<<<<< + * call._snp_quality = cns & 0xff + * call._rms_mapping_quality = cns >> 16&0xff + */ + __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * call._rms_mapping_quality = cns >> 16&0xff + * call._coverage = self.iter.n_plp + */ + __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * call._coverage = self.iter.n_plp + * + */ + __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff); + + /* "/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 # <<<<<<<<<<<<<< + * + * return call + */ + __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3101 + * call._coverage = self.iter.n_plp + * + * return call # <<<<<<<<<<<<<< + * + * cdef class IndelCall: + */ + __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_5); + __Pyx_AddTraceback("csamtools.SNPCaller.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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3111 + * cdef bam_maqindel_ret_t * _r + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * #assert r != NULL + * #self._r = r + */ + +static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__cinit__"); + __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; + + __pyx_r = 0; + __Pyx_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3118 + * property tid: + * '''the chromosome ID as is defined in the header''' + * def __get__(self): # <<<<<<<<<<<<<< + * return self._tid + * + */ + +static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___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], 3118); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3119 + * '''the chromosome ID as is defined in the header''' + * def __get__(self): + * return self._tid # <<<<<<<<<<<<<< + * + * 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 = 3119; __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.tid.__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":3123 + * property pos: + * '''nucleotide position of SNP.''' + * def __get__(self): return self._pos # <<<<<<<<<<<<<< + * + * property genotype: + */ + +static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___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], 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 = 3123; __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.pos.__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":3127 + * property genotype: + * '''the genotype called.''' + * def __get__(self): # <<<<<<<<<<<<<< + * if self._r.gt == 0: + * s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1) + */ + +static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_s; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 3127); + __pyx_v_s = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3128 + * '''the genotype called.''' + * def __get__(self): + * if self._r.gt == 0: # <<<<<<<<<<<<<< + * s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1) + * return "%s/%s" % (s,s) + */ + switch (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->gt) { + case 0: + + /* "/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 = 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; + + /* "/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) # <<<<<<<<<<<<<< + * elif self._r.gt == 1: + * 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 = 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); + __Pyx_GIVEREF(__pyx_v_s); + __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_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); + __pyx_t_2 = 0; + goto __pyx_L0; + break; + + /* "/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: # <<<<<<<<<<<<<< + * s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1) + * return "%s/%s" % (s,s) + */ + case 1: + + /* "/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 = 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; + + /* "/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) # <<<<<<<<<<<<<< + * else: + * 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 = 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); + __Pyx_GIVEREF(__pyx_v_s); + __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_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); + __pyx_t_1 = 0; + goto __pyx_L0; + break; + default: + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3135 + * return "%s/%s" % (s,s) + * else: + * return "%s/%s" % (self.first_allele, self.second_allele ) # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_3, 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_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); + __pyx_t_2 = 0; + goto __pyx_L0; + break; + } + + __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.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_XGIVEREF(__pyx_r); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 second_allele: + */ + +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], 3155); + __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 = 3155; __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.first_allele.__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":3159 + * property second_allele: + * '''sequence of second allele.''' + * def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1) # <<<<<<<<<<<<<< + * + * property reads_first: + */ + +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], 3159); + __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 = 3159; __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.second_allele.__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":3163 + * property reads_first: + * '''reads supporting first allele.''' + * def __get__(self): return self._r.cnt1 # <<<<<<<<<<<<<< + * + * 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 3163); + __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 = 3163; __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.reads_first.__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":3167 + * property reads_second: + * '''reads supporting first allele.''' + * def __get__(self): return self._r.cnt2 # <<<<<<<<<<<<<< + * + * property reads_diff: + */ + +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], 3167); + __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 = 3167; __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.reads_second.__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":3171 + * property reads_diff: + * '''reads supporting first allele.''' + * def __get__(self): return self._r.cnt_anti # <<<<<<<<<<<<<< + * + * 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; + __Pyx_TraceDeclarations + __Pyx_RefNannySetupContext("__get__"); + __Pyx_TraceCall("__get__", __pyx_f[0], 3171); + __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 = 3171; __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.reads_diff.__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":3173 + * def __get__(self): return self._r.cnt_anti + * + * def __str__(self): # <<<<<<<<<<<<<< + * + * return "\t".join( map(str, ( + */ + +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("__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 = 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); + + /* "/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_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); + __Pyx_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3189 + * 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], 3189); + + /* "/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(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3212 + * cdef int max_depth + * + * 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) { + 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], 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_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 + + /* "/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_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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3231 + * self.max_depth = kwargs.get( "max_depth", 1024 ) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * free( self.options ) + * + */ + +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], 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_TraceReturn(Py_None); + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3234 + * free( self.options ) + * + * def _call( self ): # <<<<<<<<<<<<<< + * + * cdef char * seq = self.iter.getSequence() + */ + +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; + 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], 3234); + __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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 + * + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3239 + * cdef int seq_len = self.iter.seq_len + * + * assert seq != NULL # <<<<<<<<<<<<<< + * + * # reference base + */ + #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 + + /* "/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 = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos >= __pyx_v_seq_len); + if (__pyx_t_3) { + + /* "/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_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; + + /* "/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_v_call->_r = __pyx_v_r; + + /* "/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_v_call->_tid = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->tid; + + /* "/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_v_call->_pos = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos; + + /* "/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_v_p = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp + __pyx_v_i); + + /* "/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_3 = (__pyx_v_p->b->core.qual < ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ); + if (__pyx_t_3) { + + /* "/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_v_tmp = __pyx_v_p->b->core.qual; + goto __pyx_L9; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3280 + * tmp = p.b.core.qual + * else: + * tmp = self.cap_mapQ # <<<<<<<<<<<<<< + * rms_aux += tmp * tmp + * + */ + __pyx_v_tmp = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ; + } + __pyx_L9:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3281 + * else: + * tmp = self.cap_mapQ + * rms_aux += tmp * tmp # <<<<<<<<<<<<<< + * + * call._rms_mapping_quality = (sqrt(rms_aux / self.iter.n_plp) + .499) + */ + __pyx_v_rms_aux += (__pyx_v_tmp * __pyx_v_tmp); + } + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3283 + * rms_aux += tmp * tmp + * + * call._rms_mapping_quality = (sqrt(rms_aux / self.iter.n_plp) + .499) # <<<<<<<<<<<<<< + * + * return 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 = 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 = (sqrt(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_4); + __Pyx_XDECREF(__pyx_t_5); + __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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3300 + * ''' + * + * 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], 3300); + __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 = 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) { + 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 = 3300; __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 = 3301; __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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3306 + * pass + * + * 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[] = "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 + * """ + * + * 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_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 = 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_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 = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tid = __pyx_t_4; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3315 + * 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 = 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 = 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_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3317 + * self.iter.reset( tid, pos, pos + 1 ) + * + * while 1: # <<<<<<<<<<<<<< + * self.iter.cnext() + * + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3318 + * + * 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3320 + * self.iter.cnext() + * + * if self.iter.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0); + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3321 + * + * 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 = 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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3323 + * raise ValueError("error during iteration" ) + * + * if self.iter.plp == NULL: # <<<<<<<<<<<<<< + * raise ValueError( "no reads in region - no call" ) + * + */ + __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL); + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3324 + * + * 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 = 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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3326 + * raise ValueError( "no reads in region - no call" ) + * + * if self.iter.pos == pos: break # <<<<<<<<<<<<<< + * + * return self._call() + */ + __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:; + } + __pyx_L7_break:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3328 + * if self.iter.pos == pos: break + * + * return self._call() # <<<<<<<<<<<<<< + * + * cdef class IteratorIndelCalls( IndelCallerBase ): + */ + __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; + + __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; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3344 + * """ + * + * 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}; + __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_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 = 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;} + + __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":3350 + * + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3351 + * + * def __iter__(self): + * 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_TraceReturn(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3353 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * """ + */ + +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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3358 + * + * # 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); + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3360 + * self.iter.cnext() + * + * if self.iter.n_plp < 0: # <<<<<<<<<<<<<< + * raise ValueError("error during iteration" ) + * + */ + __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0); + if (__pyx_t_1) { + + /* "/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_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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3363 + * 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) { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3364 + * + * if self.iter.plp == NULL: + * raise StopIteration # <<<<<<<<<<<<<< + * + * return self._call() + */ + __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_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3366 + * raise StopIteration + * + * return self._call() # <<<<<<<<<<<<<< + * + * + */ + __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 = 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_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__next__"); + __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":3386 + * cdef int owns_samfile + * + * def __init__(self, Samfile samfile, int reopen = True ): # <<<<<<<<<<<<<< + * self.samfile = samfile + * + */ + +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; + char *__pyx_t_3; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0}; + __Pyx_TraceDeclarations + __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}; + 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__samfile); + 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__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), "__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); + } + } 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 = 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("__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.IndexedReads.__init__"); + __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 = 3386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3387 + * + * def __init__(self, Samfile samfile, int reopen = True ): + * self.samfile = samfile # <<<<<<<<<<<<<< + * + * if samfile.isbam: mode = "rb" + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3389 + * self.samfile = samfile + * + * if samfile.isbam: mode = "rb" # <<<<<<<<<<<<<< + * else: mode = "r" + * + */ + 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*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3390 + * + * if samfile.isbam: mode = "rb" + * else: mode = "r" # <<<<<<<<<<<<<< + * + * # reopen the file - note that this makes the iterator + */ + __Pyx_INCREF(((PyObject *)__pyx_n_s__r)); + __Pyx_DECREF(__pyx_v_mode); + __pyx_v_mode = ((PyObject *)__pyx_n_s__r); + } + __pyx_L6:; + + /* "/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 ) + */ + if (__pyx_v_reopen) { + + /* "/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_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; + + /* "/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_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;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3399 + * store.release() + * assert self.fp != NULL + * self.owns_samfile = True # <<<<<<<<<<<<<< + * else: + * self.fp = samfile.samfile + */ + ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 1; + goto __pyx_L7; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3401 + * self.owns_samfile = True + * else: + * self.fp = samfile.samfile # <<<<<<<<<<<<<< + * self.owns_samfile = False + * + */ + ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = __pyx_v_samfile->samfile; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3402 + * else: + * self.fp = samfile.samfile + * self.owns_samfile = False # <<<<<<<<<<<<<< + * + * assert samfile.isbam, "can only IndexReads on bam files" + */ + ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 0; + } + __pyx_L7:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3404 + * self.owns_samfile = False + * + * assert samfile.isbam, "can only IndexReads on bam files" # <<<<<<<<<<<<<< + * + * def build( self ): + */ + #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 = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("csamtools.IndexedReads.__init__"); + __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":3406 + * assert samfile.isbam, "can only IndexReads on bam files" + * + * def build( self ): # <<<<<<<<<<<<<< + * '''build index.''' + * + */ + +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("build"); + __Pyx_TraceCall("build", __pyx_f[0], 3406); + + /* "/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; + + /* "/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 = 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 = calloc(1, sizeof( bam1_t) ) # <<<<<<<<<<<<<< + * + * 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); + + /* "/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) { + + /* "/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 ) + * + */ + __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 ) # <<<<<<<<<<<<<< + * + * bam_destroy1( b ) + */ + __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); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3427 + * bam_destroy1( b ) + * + * def find( self, qname ): # <<<<<<<<<<<<<< + * if qname in self.index: + * return IteratorRowSelection( self.samfile, self.index[qname], reopen = False ) + */ + +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("find"); + __Pyx_TraceCall("find", __pyx_f[0], 3427); + + /* "/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 = ((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) { + + /* "/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_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_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_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_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L5; + } + /*else*/ { + + /* "/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 ) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __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_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("csamtools.IndexedReads.find"); + __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":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; + return o; +} + +static void __pyx_tp_dealloc_9csamtools_AlignedRead(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_11AlignedRead___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_11AlignedRead_qname(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5qname___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_qname(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_5qname___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_cigar(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5cigar___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_cigar(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_seq(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_3seq___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_seq(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_3seq___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qual(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4qual___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_qual(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4qual___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_query(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5query___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qqual(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5qqual___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qstart(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_6qstart___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qend(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4qend___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qlen(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4qlen___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tags(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4tags___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_tags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4tags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_flag(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4flag___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_flag(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4flag___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rname(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5rname___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_rname(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_5rname___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tid(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_3tid___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_tid(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_3tid___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_pos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_3pos___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_pos(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_3pos___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_bin(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_3bin___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_bin(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_3bin___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rlen(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4rlen___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_aend(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4aend___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_alen(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4alen___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mapq(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4mapq___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_mapq(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mrnm(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_mrnm(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mpos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_4mpos___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_mpos(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_isize(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_5isize___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_isize(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_5isize___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_paired(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_paired(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read1(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_read1(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read2(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_read2(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(o); +} + +static int __pyx_setprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +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_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} +}; + +static PyNumberMethods __pyx_tp_as_number_AlignedRead = { + 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_AlignedRead = { + 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_AlignedRead = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_AlignedRead = { + #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_AlignedRead = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.AlignedRead"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_AlignedRead), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_AlignedRead, /*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_AlignedRead, /*tp_as_number*/ + &__pyx_tp_as_sequence_AlignedRead, /*tp_as_sequence*/ + &__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*/ + 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_Samfile, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __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*/ + __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_Samfile, /*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_Samfile, /*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_PileupProxy(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + return o; +} + +static void __pyx_tp_dealloc_9csamtools_PileupProxy(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} + +static PyObject *__pyx_getprop_9csamtools_11PileupProxy_tid(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11PileupProxy_3tid___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11PileupProxy_n(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11PileupProxy_1n___get__(o); +} + +static int __pyx_setprop_9csamtools_11PileupProxy_n(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_pf_9csamtools_11PileupProxy_1n___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11PileupProxy_3pos___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pileups(PyObject *o, void *x) { + return __pyx_pf_9csamtools_11PileupProxy_7pileups___get__(o); +} + +static PyMethodDef __pyx_methods_9csamtools_PileupProxy[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_9csamtools_PileupProxy[] = { + {(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_156), 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_PileupProxy = { + 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_PileupProxy = { + 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_PileupProxy = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_PileupProxy = { + #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_PileupProxy = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.PileupProxy"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_PileupProxy), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_PileupProxy, /*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_PileupProxy, /*tp_as_number*/ + &__pyx_tp_as_sequence_PileupProxy, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_PileupProxy, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pf_9csamtools_11PileupProxy___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 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("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*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_PileupProxy, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_9csamtools_PileupProxy, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pf_9csamtools_11PileupProxy___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_PileupProxy, /*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_PileupRead(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_PileupRead *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_PileupRead *)o); + p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_9csamtools_PileupRead(PyObject *o) { + struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o; + Py_XDECREF(((PyObject *)p->_alignment)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_9csamtools_PileupRead(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o; + if (p->_alignment) { + e = (*v)(((PyObject*)p->_alignment), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_9csamtools_PileupRead(PyObject *o) { + struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o; + PyObject* tmp; + tmp = ((PyObject*)p->_alignment); + p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_alignment(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_9alignment___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_qpos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_4qpos___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_indel(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_5indel___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_del(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_6is_del___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_head(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_7is_head___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_tail(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_7is_tail___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_10PileupRead_level(PyObject *o, void *x) { + return __pyx_pf_9csamtools_10PileupRead_5level___get__(o); +} + +static PyMethodDef __pyx_methods_9csamtools_PileupRead[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_9csamtools_PileupRead[] = { + {(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}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_PileupRead = { + 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_PileupRead = { + 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_PileupRead = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_PileupRead = { + #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_PileupRead = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.PileupRead"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_PileupRead), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_PileupRead, /*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_PileupRead, /*tp_as_number*/ + &__pyx_tp_as_sequence_PileupRead, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_PileupRead, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pf_9csamtools_10PileupRead___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 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("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*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_PileupRead, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_9csamtools_PileupRead, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pf_9csamtools_10PileupRead___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_PileupRead, /*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_Fastafile __pyx_vtable_9csamtools_Fastafile; + +static PyObject *__pyx_tp_new_9csamtools_Fastafile(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_Fastafile *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_Fastafile *)o); + p->__pyx_vtab = __pyx_vtabptr_9csamtools_Fastafile; + if (__pyx_pf_9csamtools_9Fastafile___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_Fastafile(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_9Fastafile___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_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(__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_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_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 PyObject *__pyx_tp_new_9csamtools_IteratorRow(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IteratorRow(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorRow[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorRow = { + 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_IteratorRow = { + 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_IteratorRow = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorRow = { + #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_IteratorRow = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorRow"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorRow), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorRow, /*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_IteratorRow, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorRow, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorRow, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IteratorRow, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __Pyx_DOCSTR("abstract base class for iterators over mapped reads.\n\n Various iterators implement different behaviours for wrapping around\n contig boundaries. Examples include:\n\n :class:`pysam.IteratorRowRegion`\n iterate within a single contig and a defined region.\n\n :class:`pysam.IteratorRowAll`\n iterate until EOF. This iterator will also include unmapped reads.\n\n :class:`pysam.IteratorRowAllRefs`\n iterate over all reads in all reference sequences.\n \n The method :meth:`Samfile.fetch` returns an IteratorRow.\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorRow, /*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_IteratorRow, /*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_IteratorRowRegion __pyx_vtable_9csamtools_IteratorRowRegion; + +static PyObject *__pyx_tp_new_9csamtools_IteratorRowRegion(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorRowRegion *p; + PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)o); + p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowRegion; + p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None); + if (__pyx_pf_9csamtools_17IteratorRowRegion___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IteratorRowRegion(PyObject *o) { + struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->samfile)); + __pyx_tp_dealloc_9csamtools_IteratorRow(o); +} + +static int __pyx_tp_traverse_9csamtools_IteratorRowRegion(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)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; + } + return 0; +} + +static int __pyx_tp_clear_9csamtools_IteratorRowRegion(PyObject *o) { + struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)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); + return 0; +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorRowRegion[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_17IteratorRowRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_17IteratorRowRegion___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorRowRegion = { + 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_IteratorRowRegion = { + 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_IteratorRowRegion = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorRowRegion = { + #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_IteratorRowRegion = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorRowRegion"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorRowRegion), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorRowRegion, /*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_IteratorRowRegion, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorRowRegion, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorRowRegion, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 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 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*/ + 0, /*tp_weaklistoffset*/ + __pyx_pf_9csamtools_17IteratorRowRegion___iter__, /*tp_iter*/ + __pyx_pf_9csamtools_17IteratorRowRegion___next__, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorRowRegion, /*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_IteratorRowRegion, /*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_IteratorRowAll __pyx_vtable_9csamtools_IteratorRowAll; + +static PyObject *__pyx_tp_new_9csamtools_IteratorRowAll(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorRowAll *p; + PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorRowAll *)o); + p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowAll; + if (__pyx_pf_9csamtools_14IteratorRowAll___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IteratorRowAll(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + __pyx_tp_dealloc_9csamtools_IteratorRow(o); +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorRowAll[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_14IteratorRowAll___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorRowAll___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorRowAll = { + 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_IteratorRowAll = { + 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_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_IteratorRowAllRefs = { + #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_IteratorRowAllRefs = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*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_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_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_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*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*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_IteratorRowSelection __pyx_vtable_9csamtools_IteratorRowSelection; + +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_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_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_IteratorRowSelection(PyObject *o, visitproc v, void *a) { + int e; + 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->positions) { + e = (*v)(p->positions, a); if (e) return e; + } + return 0; +} + +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->positions); + p->positions = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +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_IteratorRowSelection = { + 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_IteratorRowSelection = { + 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_IteratorRowSelection = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = { + #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_IteratorRowSelection = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorRowSelection"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorRowSelection), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorRowSelection, /*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_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_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("*(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_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*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_IteratorRowSelection, /*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_IteratorColumn __pyx_vtable_9csamtools_IteratorColumn; + +static PyObject *__pyx_tp_new_9csamtools_IteratorColumn(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorColumn *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorColumn *)o); + p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorColumn; + p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None); + p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None); + p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None); + p->stepper = Py_None; Py_INCREF(Py_None); + if (__pyx_pf_9csamtools_14IteratorColumn___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IteratorColumn(PyObject *o) { + struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_14IteratorColumn___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->iter)); + Py_XDECREF(((PyObject *)p->samfile)); + Py_XDECREF(((PyObject *)p->fastafile)); + Py_XDECREF(p->stepper); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_9csamtools_IteratorColumn(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o; + if (p->iter) { + e = (*v)(((PyObject*)p->iter), a); if (e) return e; + } + if (p->samfile) { + e = (*v)(((PyObject*)p->samfile), a); if (e) return e; + } + if (p->fastafile) { + e = (*v)(((PyObject*)p->fastafile), a); if (e) return e; + } + if (p->stepper) { + e = (*v)(p->stepper, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_9csamtools_IteratorColumn(PyObject *o) { + struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o; + PyObject* tmp; + tmp = ((PyObject*)p->iter); + p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->samfile); + p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->fastafile); + p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->stepper); + p->stepper = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_9csamtools_14IteratorColumn_seq_len(PyObject *o, void *x) { + return __pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(o); +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorColumn[] = { + {__Pyx_NAMESTR("addReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_addReference, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_addReference)}, + {__Pyx_NAMESTR("hasReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_hasReference, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_hasReference)}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_9csamtools_IteratorColumn[] = { + {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_161), 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorColumn = { + 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_IteratorColumn = { + 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_IteratorColumn = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorColumn = { + #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_IteratorColumn = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorColumn"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorColumn), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorColumn, /*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_IteratorColumn, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorColumn, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorColumn, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IteratorColumn, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("abstract base class for iterators over columns.\n\n IteratorColumn objects wrap the pileup functionality of samtools.\n \n For reasons of efficiency, the iterator points to the current \n pileup buffer. The pileup buffer is updated at every iteration.\n This might cause some unexpected behavious. For example,\n consider the conversion to a list::\n \n f = Samfile(\"file.bam\", \"rb\")\n result = list( f.pileup() )\n\n Here, ``result`` will contain ``n`` objects of type :class:`PileupProxy` for ``n`` columns, \n but each object in ``result`` will contain the same information.\n \n The desired behaviour can be achieved by list comprehension::\n\n result = [ x.pileups() for x in f.pileup() ]\n\n ``result`` will be a list of ``n`` lists of objects of type :class:`PileupRead`.\n\n If the iterator is associated with a :class:`Fastafile` using the :meth:`addReference`\n method, then the iterator will export the current sequence via the methods :meth:`getSequence`\n and :meth:`seq_len`.\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 fastafile\n A :class:`FastaFile` object\n mask\n Skip all reads with bits set in mask.\n \n \n "), /*tp_doc*/ + __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pf_9csamtools_14IteratorColumn___iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorColumn, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_9csamtools_IteratorColumn, /*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_IteratorColumn, /*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_IteratorColumnRegion __pyx_vtable_9csamtools_IteratorColumnRegion; + +static PyObject *__pyx_tp_new_9csamtools_IteratorColumnRegion(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorColumnRegion *p; + PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnRegion; + if (__pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorColumnRegion[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorColumnRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorColumnRegion___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorColumnRegion = { + 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_IteratorColumnRegion = { + 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_IteratorColumnRegion = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnRegion = { + #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_IteratorColumnRegion = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorColumnRegion"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorColumnRegion), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorColumn, /*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_IteratorColumnRegion, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorColumnRegion, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorColumnRegion, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IteratorColumnRegion, /*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 a region only.\n "), /*tp_doc*/ + __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + __pyx_pf_9csamtools_20IteratorColumnRegion___next__, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorColumnRegion, /*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_IteratorColumnRegion, /*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_IteratorColumnAllRefs __pyx_vtable_9csamtools_IteratorColumnAllRefs; + +static PyObject *__pyx_tp_new_9csamtools_IteratorColumnAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorColumnAllRefs *p; + PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnAllRefs; + if (__pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorColumnAllRefs[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_21IteratorColumnAllRefs___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorColumnAllRefs = { + 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_IteratorColumnAllRefs = { + 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_IteratorColumnAllRefs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnAllRefs = { + #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_IteratorColumnAllRefs = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorColumnAllRefs"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorColumnAllRefs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IteratorColumn, /*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_IteratorColumnAllRefs, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorColumnAllRefs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorColumnAllRefs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IteratorColumnAllRefs, /*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 columns by chaining iterators over each reference\n "), /*tp_doc*/ + __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + __pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorColumnAllRefs, /*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_IteratorColumnAllRefs, /*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_SNPCall(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + return o; +} + +static void __pyx_tp_dealloc_9csamtools_SNPCall(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_tid(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_3tid___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_pos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_3pos___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_reference_base(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_14reference_base___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_genotype(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_8genotype___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_consensus_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_snp_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_mapping_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_7SNPCall_coverage(PyObject *o, void *x) { + return __pyx_pf_9csamtools_7SNPCall_8coverage___get__(o); +} + +static PyMethodDef __pyx_methods_9csamtools_SNPCall[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_9csamtools_SNPCall[] = { + {(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} +}; + +static PyNumberMethods __pyx_tp_as_number_SNPCall = { + 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_SNPCall = { + 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_SNPCall = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_SNPCall = { + #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_SNPCall = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.SNPCall"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_SNPCall), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_SNPCall, /*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_SNPCall, /*tp_as_number*/ + &__pyx_tp_as_sequence_SNPCall, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SNPCall, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pf_9csamtools_7SNPCall___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_SNPCall, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __Pyx_DOCSTR("the results of a SNP call."), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_SNPCall, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_9csamtools_SNPCall, /*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_SNPCall, /*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_SNPCallerBase __pyx_vtable_9csamtools_SNPCallerBase; + +static PyObject *__pyx_tp_new_9csamtools_SNPCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_SNPCallerBase *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_SNPCallerBase *)o); + p->__pyx_vtab = __pyx_vtabptr_9csamtools_SNPCallerBase; + p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None); + if (__pyx_pf_9csamtools_13SNPCallerBase___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_SNPCallerBase(PyObject *o) { + struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->iter)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_9csamtools_SNPCallerBase(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o; + if (p->iter) { + e = (*v)(((PyObject*)p->iter), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_9csamtools_SNPCallerBase(PyObject *o) { + struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o; + PyObject* tmp; + tmp = ((PyObject*)p->iter); + p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_9csamtools_SNPCallerBase[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_SNPCallerBase = { + 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_SNPCallerBase = { + 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_SNPCallerBase = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_SNPCallerBase = { + #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_SNPCallerBase = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.SNPCallerBase"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_SNPCallerBase), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*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_SNPCallerBase, /*tp_as_number*/ + &__pyx_tp_as_sequence_SNPCallerBase, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SNPCallerBase, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_SNPCallerBase, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("Base class for SNP callers.\n\n *min_baseQ*\n minimum base quality (possibly capped by BAQ)\n *capQ_threshold*\n coefficient for adjusting mapQ of poor mappings\n *theta*\n theta in maq consensus calling model\n *n_haplotypes*\n number of haplotypes in the sample\n *het_rate*\n prior of a difference between two haplotypes\n "), /*tp_doc*/ + __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_SNPCallerBase, /*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_SNPCallerBase, /*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_IteratorSNPCalls __pyx_vtable_9csamtools_IteratorSNPCalls; + +static PyObject *__pyx_tp_new_9csamtools_IteratorSNPCalls(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IteratorSNPCalls *p; + PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_IteratorSNPCalls; + if (__pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static PyMethodDef __pyx_methods_9csamtools_IteratorSNPCalls[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_16IteratorSNPCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_16IteratorSNPCalls___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IteratorSNPCalls = { + 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_IteratorSNPCalls = { + 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_IteratorSNPCalls = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IteratorSNPCalls = { + #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_IteratorSNPCalls = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IteratorSNPCalls"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IteratorSNPCalls), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*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_IteratorSNPCalls, /*tp_as_number*/ + &__pyx_tp_as_sequence_IteratorSNPCalls, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IteratorSNPCalls, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IteratorSNPCalls, /*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 SNPs 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_SNPCallerBase, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pf_9csamtools_16IteratorSNPCalls___iter__, /*tp_iter*/ + __pyx_pf_9csamtools_16IteratorSNPCalls___next__, /*tp_iternext*/ + __pyx_methods_9csamtools_IteratorSNPCalls, /*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_IteratorSNPCalls, /*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_SNPCaller __pyx_vtable_9csamtools_SNPCaller; + +static PyObject *__pyx_tp_new_9csamtools_SNPCaller(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_SNPCaller *p; + PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_SNPCaller *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_SNPCaller; + if (__pyx_pf_9csamtools_9SNPCaller___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static PyMethodDef __pyx_methods_9csamtools_SNPCaller[] = { + {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_9SNPCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9SNPCaller_call)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_SNPCaller = { + 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_SNPCaller = { + 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_SNPCaller = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_SNPCaller = { + #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_SNPCaller = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.SNPCaller"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_SNPCaller), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*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_SNPCaller, /*tp_as_number*/ + &__pyx_tp_as_sequence_SNPCaller, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SNPCaller, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_SNPCaller, /*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_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/ + __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_SNPCaller, /*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_SNPCaller, /*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_IndelCall(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + if (__pyx_pf_9csamtools_9IndelCall___cinit__(o, __pyx_empty_tuple, NULL) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IndelCall(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_9IndelCall___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_9IndelCall_tid(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_3tid___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_pos(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_3pos___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_genotype(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_8genotype___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_consensus_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_snp_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_mapping_quality(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_coverage(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_8coverage___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_first_allele(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_12first_allele___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_second_allele(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_13second_allele___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_first(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_11reads_first___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_second(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_12reads_second___get__(o); +} + +static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_diff(PyObject *o, void *x) { + return __pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(o); +} + +static PyMethodDef __pyx_methods_9csamtools_IndelCall[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_9csamtools_IndelCall[] = { + {(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} +}; + +static PyNumberMethods __pyx_tp_as_number_IndelCall = { + 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_IndelCall = { + 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_IndelCall = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IndelCall = { + #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_IndelCall = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IndelCall"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IndelCall), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IndelCall, /*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_IndelCall, /*tp_as_number*/ + &__pyx_tp_as_sequence_IndelCall, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IndelCall, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pf_9csamtools_9IndelCall___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IndelCall, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __Pyx_DOCSTR("the results of an indel call."), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_IndelCall, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_9csamtools_IndelCall, /*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_IndelCall, /*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_IndelCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IndelCallerBase *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_9csamtools_IndelCallerBase *)o); + p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None); + if (__pyx_pf_9csamtools_15IndelCallerBase___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_9csamtools_IndelCallerBase(PyObject *o) { + struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->iter)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_9csamtools_IndelCallerBase(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o; + if (p->iter) { + e = (*v)(((PyObject*)p->iter), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_9csamtools_IndelCallerBase(PyObject *o) { + struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o; + PyObject* tmp; + tmp = ((PyObject*)p->iter); + p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_9csamtools_IndelCallerBase[] = { + {__Pyx_NAMESTR("_call"), (PyCFunction)__pyx_pf_9csamtools_15IndelCallerBase__call, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_15IndelCallerBase__call)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IndelCallerBase = { + 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_IndelCallerBase = { + 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_IndelCallerBase = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IndelCallerBase = { + #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_IndelCallerBase = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IndelCallerBase"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IndelCallerBase), /*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_IndelCallerBase, /*tp_as_number*/ + &__pyx_tp_as_sequence_IndelCallerBase, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IndelCallerBase, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IndelCallerBase, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("Base class for SNP callers.\n\n *min_baseQ*\n minimum base quality (possibly capped by BAQ)\n *capQ_threshold*\n coefficient for adjusting mapQ of poor mappings\n *theta*\n theta in maq consensus calling model\n *n_haplotypes*\n number of haplotypes in the sample\n *het_rate*\n prior of a difference between two haplotypes\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_IndelCallerBase, /*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_IndelCallerBase, /*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_IndelCaller(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k); + if (!o) return 0; + if (__pyx_pf_9csamtools_11IndelCaller___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static PyMethodDef __pyx_methods_9csamtools_IndelCaller[] = { + {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_11IndelCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11IndelCaller_call)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IndelCaller = { + 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_IndelCaller = { + 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_IndelCaller = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IndelCaller = { + #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_IndelCaller = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IndelCaller"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IndelCaller), /*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_IndelCaller, /*tp_as_number*/ + &__pyx_tp_as_sequence_IndelCaller, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IndelCaller, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 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_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*/ + __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*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_IteratorIndelCalls, /*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_IndexedReads(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_9csamtools_IndexedReads *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 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 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_IndexedReads = { + 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_IndexedReads = { + 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_IndexedReads = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IndexedReads = { + #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_IndexedReads = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("csamtools.IndexedReads"), /*tp_name*/ + sizeof(struct __pyx_obj_9csamtools_IndexedReads), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_9csamtools_IndexedReads, /*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_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_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("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*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_9csamtools_IndexedReads, /*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_9csamtools_12IndexedReads___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_9csamtools_IndexedReads, /*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("_samtools_dispatch"), (PyCFunction)__pyx_pf_9csamtools__samtools_dispatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools__samtools_dispatch)}, + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + __Pyx_NAMESTR("csamtools"), + 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_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_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_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}, + {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, + {&__pyx_kp_u_180, __pyx_k_180, sizeof(__pyx_k_180), 0, 1, 0, 0}, + {&__pyx_kp_u_181, __pyx_k_181, sizeof(__pyx_k_181), 0, 1, 0, 0}, + {&__pyx_kp_u_182, __pyx_k_182, sizeof(__pyx_k_182), 0, 1, 0, 0}, + {&__pyx_kp_u_183, __pyx_k_183, sizeof(__pyx_k_183), 0, 1, 0, 0}, + {&__pyx_kp_u_184, __pyx_k_184, sizeof(__pyx_k_184), 0, 1, 0, 0}, + {&__pyx_kp_u_185, __pyx_k_185, sizeof(__pyx_k_185), 0, 1, 0, 0}, + {&__pyx_kp_u_186, __pyx_k_186, sizeof(__pyx_k_186), 0, 1, 0, 0}, + {&__pyx_kp_u_187, __pyx_k_187, sizeof(__pyx_k_187), 0, 1, 0, 0}, + {&__pyx_kp_u_188, __pyx_k_188, sizeof(__pyx_k_188), 0, 1, 0, 0}, + {&__pyx_kp_u_189, __pyx_k_189, sizeof(__pyx_k_189), 0, 1, 0, 0}, + {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, + {&__pyx_kp_u_190, __pyx_k_190, sizeof(__pyx_k_190), 0, 1, 0, 0}, + {&__pyx_kp_u_191, __pyx_k_191, sizeof(__pyx_k_191), 0, 1, 0, 0}, + {&__pyx_kp_u_192, __pyx_k_192, sizeof(__pyx_k_192), 0, 1, 0, 0}, + {&__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_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_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_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_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_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_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_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0}, + {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0}, + {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0}, + {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0}, + {&__pyx_kp_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_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_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0}, + {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0}, + {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0}, + {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0}, + {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0}, + {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0}, + {&__pyx_kp_s_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_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_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_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}, + {&__pyx_kp_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 0}, + {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0}, + {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0}, + {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, + {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0}, + {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0}, + {&__pyx_kp_s_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_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, + {&__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_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}, + {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1}, + {&__pyx_n_s__CL, __pyx_k__CL, sizeof(__pyx_k__CL), 0, 0, 1, 1}, + {&__pyx_n_s__CN, __pyx_k__CN, sizeof(__pyx_k__CN), 0, 0, 1, 1}, + {&__pyx_n_s__CO, __pyx_k__CO, sizeof(__pyx_k__CO), 0, 0, 1, 1}, + {&__pyx_n_s__D, __pyx_k__D, sizeof(__pyx_k__D), 0, 0, 1, 1}, + {&__pyx_n_s__DS, __pyx_k__DS, sizeof(__pyx_k__DS), 0, 0, 1, 1}, + {&__pyx_n_s__DT, __pyx_k__DT, sizeof(__pyx_k__DT), 0, 0, 1, 1}, + {&__pyx_n_s__DictType, __pyx_k__DictType, sizeof(__pyx_k__DictType), 0, 0, 1, 1}, + {&__pyx_n_s__F, __pyx_k__F, sizeof(__pyx_k__F), 0, 0, 1, 1}, + {&__pyx_n_s__Fastafile, __pyx_k__Fastafile, sizeof(__pyx_k__Fastafile), 0, 0, 1, 1}, + {&__pyx_n_s__FloatType, __pyx_k__FloatType, sizeof(__pyx_k__FloatType), 0, 0, 1, 1}, + {&__pyx_n_s__GO, __pyx_k__GO, sizeof(__pyx_k__GO), 0, 0, 1, 1}, + {&__pyx_n_s__HD, __pyx_k__HD, sizeof(__pyx_k__HD), 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__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}, + {&__pyx_n_s__IteratorRow, __pyx_k__IteratorRow, sizeof(__pyx_k__IteratorRow), 0, 0, 1, 1}, + {&__pyx_n_s__IteratorRowAll, __pyx_k__IteratorRowAll, sizeof(__pyx_k__IteratorRowAll), 0, 0, 1, 1}, + {&__pyx_n_s__IteratorRowAllRefs, __pyx_k__IteratorRowAllRefs, sizeof(__pyx_k__IteratorRowAllRefs), 0, 0, 1, 1}, + {&__pyx_n_s__IteratorRowRegion, __pyx_k__IteratorRowRegion, sizeof(__pyx_k__IteratorRowRegion), 0, 0, 1, 1}, + {&__pyx_n_s__IteratorSNPCalls, __pyx_k__IteratorSNPCalls, sizeof(__pyx_k__IteratorSNPCalls), 0, 0, 1, 1}, + {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1}, + {&__pyx_n_s__LB, __pyx_k__LB, sizeof(__pyx_k__LB), 0, 0, 1, 1}, + {&__pyx_n_s__LN, __pyx_k__LN, sizeof(__pyx_k__LN), 0, 0, 1, 1}, + {&__pyx_n_s__M5, __pyx_k__M5, sizeof(__pyx_k__M5), 0, 0, 1, 1}, + {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__PN, __pyx_k__PN, sizeof(__pyx_k__PN), 0, 0, 1, 1}, + {&__pyx_n_s__PU, __pyx_k__PU, sizeof(__pyx_k__PU), 0, 0, 1, 1}, + {&__pyx_n_s__PileupColumn, __pyx_k__PileupColumn, sizeof(__pyx_k__PileupColumn), 0, 0, 1, 1}, + {&__pyx_n_s__PileupProxy, __pyx_k__PileupProxy, sizeof(__pyx_k__PileupProxy), 0, 0, 1, 1}, + {&__pyx_n_s__PileupRead, __pyx_k__PileupRead, sizeof(__pyx_k__PileupRead), 0, 0, 1, 1}, + {&__pyx_n_s__RG, __pyx_k__RG, sizeof(__pyx_k__RG), 0, 0, 1, 1}, + {&__pyx_n_s__S, __pyx_k__S, sizeof(__pyx_k__S), 0, 0, 1, 1}, + {&__pyx_n_s__SM, __pyx_k__SM, sizeof(__pyx_k__SM), 0, 0, 1, 1}, + {&__pyx_n_s__SN, __pyx_k__SN, sizeof(__pyx_k__SN), 0, 0, 1, 1}, + {&__pyx_n_s__SNPCaller, __pyx_k__SNPCaller, sizeof(__pyx_k__SNPCaller), 0, 0, 1, 1}, + {&__pyx_n_s__SO, __pyx_k__SO, sizeof(__pyx_k__SO), 0, 0, 1, 1}, + {&__pyx_n_s__SP, __pyx_k__SP, sizeof(__pyx_k__SP), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__VALID_HEADERS, __pyx_k__VALID_HEADERS, sizeof(__pyx_k__VALID_HEADERS), 0, 0, 1, 1}, + {&__pyx_n_s__VALID_HEADER_FIELDS, __pyx_k__VALID_HEADER_FIELDS, sizeof(__pyx_k__VALID_HEADER_FIELDS), 0, 0, 1, 1}, + {&__pyx_n_s__VALID_HEADER_ORDER, __pyx_k__VALID_HEADER_ORDER, sizeof(__pyx_k__VALID_HEADER_ORDER), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s____dict__, __pyx_k____dict__, sizeof(__pyx_k____dict__), 0, 0, 1, 1}, + {&__pyx_n_s____getattribute__, __pyx_k____getattribute__, sizeof(__pyx_k____getattribute__), 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____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 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___alignment, __pyx_k___alignment, sizeof(__pyx_k___alignment), 0, 0, 1, 1}, + {&__pyx_n_s___buildHeader, __pyx_k___buildHeader, sizeof(__pyx_k___buildHeader), 0, 0, 1, 1}, + {&__pyx_n_s___buildLine, __pyx_k___buildLine, sizeof(__pyx_k___buildLine), 0, 0, 1, 1}, + {&__pyx_n_s___call, __pyx_k___call, sizeof(__pyx_k___call), 0, 0, 1, 1}, + {&__pyx_n_s___consensus_quality, __pyx_k___consensus_quality, sizeof(__pyx_k___consensus_quality), 0, 0, 1, 1}, + {&__pyx_n_s___coverage, __pyx_k___coverage, sizeof(__pyx_k___coverage), 0, 0, 1, 1}, + {&__pyx_n_s___delegate, __pyx_k___delegate, sizeof(__pyx_k___delegate), 0, 0, 1, 1}, + {&__pyx_n_s___filename, __pyx_k___filename, sizeof(__pyx_k___filename), 0, 0, 1, 1}, + {&__pyx_n_s___genotype, __pyx_k___genotype, sizeof(__pyx_k___genotype), 0, 0, 1, 1}, + {&__pyx_n_s___hasIndex, __pyx_k___hasIndex, sizeof(__pyx_k___hasIndex), 0, 0, 1, 1}, + {&__pyx_n_s___indel, __pyx_k___indel, sizeof(__pyx_k___indel), 0, 0, 1, 1}, + {&__pyx_n_s___isOpen, __pyx_k___isOpen, sizeof(__pyx_k___isOpen), 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_tail, __pyx_k___is_tail, sizeof(__pyx_k___is_tail), 0, 0, 1, 1}, + {&__pyx_n_s___level, __pyx_k___level, sizeof(__pyx_k___level), 0, 0, 1, 1}, + {&__pyx_n_s___logfile, __pyx_k___logfile, sizeof(__pyx_k___logfile), 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___pos, __pyx_k___pos, sizeof(__pyx_k___pos), 0, 0, 1, 1}, + {&__pyx_n_s___qpos, __pyx_k___qpos, sizeof(__pyx_k___qpos), 0, 0, 1, 1}, + {&__pyx_n_s___r, __pyx_k___r, sizeof(__pyx_k___r), 0, 0, 1, 1}, + {&__pyx_n_s___reference_base, __pyx_k___reference_base, sizeof(__pyx_k___reference_base), 0, 0, 1, 1}, + {&__pyx_n_s___samtools_dispatch, __pyx_k___samtools_dispatch, sizeof(__pyx_k___samtools_dispatch), 0, 0, 1, 1}, + {&__pyx_n_s___snp_quality, __pyx_k___snp_quality, sizeof(__pyx_k___snp_quality), 0, 0, 1, 1}, + {&__pyx_n_s___tid, __pyx_k___tid, sizeof(__pyx_k___tid), 0, 0, 1, 1}, + {&__pyx_n_s__addReference, __pyx_k__addReference, sizeof(__pyx_k__addReference), 0, 0, 1, 1}, + {&__pyx_n_s__alignment, __pyx_k__alignment, sizeof(__pyx_k__alignment), 0, 0, 1, 1}, + {&__pyx_n_s__all, __pyx_k__all, sizeof(__pyx_k__all), 0, 0, 1, 1}, + {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1}, + {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1}, + {&__pyx_n_s__bam, __pyx_k__bam, sizeof(__pyx_k__bam), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1}, + {&__pyx_n_s__cap_mapQ, __pyx_k__cap_mapQ, sizeof(__pyx_k__cap_mapQ), 0, 0, 1, 1}, + {&__pyx_n_s__catch_stderr, __pyx_k__catch_stderr, sizeof(__pyx_k__catch_stderr), 0, 0, 1, 1}, + {&__pyx_n_s__catch_stdout, __pyx_k__catch_stdout, sizeof(__pyx_k__catch_stdout), 0, 0, 1, 1}, + {&__pyx_n_s__chr, __pyx_k__chr, sizeof(__pyx_k__chr), 0, 0, 1, 1}, + {&__pyx_n_s__cigar, __pyx_k__cigar, sizeof(__pyx_k__cigar), 0, 0, 1, 1}, + {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1}, + {&__pyx_n_s__cmp, __pyx_k__cmp, sizeof(__pyx_k__cmp), 0, 0, 1, 1}, + {&__pyx_n_s__cnext, __pyx_k__cnext, sizeof(__pyx_k__cnext), 0, 0, 1, 1}, + {&__pyx_n_s__cnt1, __pyx_k__cnt1, sizeof(__pyx_k__cnt1), 0, 0, 1, 1}, + {&__pyx_n_s__cnt2, __pyx_k__cnt2, sizeof(__pyx_k__cnt2), 0, 0, 1, 1}, + {&__pyx_n_s__cnt_anti, __pyx_k__cnt_anti, sizeof(__pyx_k__cnt_anti), 0, 0, 1, 1}, + {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1}, + {&__pyx_n_s__compare, __pyx_k__compare, sizeof(__pyx_k__compare), 0, 0, 1, 1}, + {&__pyx_n_s__consensus_quality, __pyx_k__consensus_quality, sizeof(__pyx_k__consensus_quality), 0, 0, 1, 1}, + {&__pyx_n_s__core, __pyx_k__core, sizeof(__pyx_k__core), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__errmod, __pyx_k__errmod, sizeof(__pyx_k__errmod), 0, 0, 1, 1}, + {&__pyx_n_s__exc_type, __pyx_k__exc_type, sizeof(__pyx_k__exc_type), 0, 0, 1, 1}, + {&__pyx_n_s__exc_value, __pyx_k__exc_value, sizeof(__pyx_k__exc_value), 0, 0, 1, 1}, + {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1}, + {&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1}, + {&__pyx_n_s__fancy_str, __pyx_k__fancy_str, sizeof(__pyx_k__fancy_str), 0, 0, 1, 1}, + {&__pyx_n_s__fastafile, __pyx_k__fastafile, sizeof(__pyx_k__fastafile), 0, 0, 1, 1}, + {&__pyx_n_s__fd, __pyx_k__fd, sizeof(__pyx_k__fd), 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__fileno, __pyx_k__fileno, sizeof(__pyx_k__fileno), 0, 0, 1, 1}, + {&__pyx_n_s__first_allele, __pyx_k__first_allele, sizeof(__pyx_k__first_allele), 0, 0, 1, 1}, + {&__pyx_n_s__flag, __pyx_k__flag, sizeof(__pyx_k__flag), 0, 0, 1, 1}, + {&__pyx_n_s__flush, __pyx_k__flush, sizeof(__pyx_k__flush), 0, 0, 1, 1}, + {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1}, + {&__pyx_n_s__genotype, __pyx_k__genotype, sizeof(__pyx_k__genotype), 0, 0, 1, 1}, + {&__pyx_n_s__getSequence, __pyx_k__getSequence, sizeof(__pyx_k__getSequence), 0, 0, 1, 1}, + {&__pyx_n_s__getrname, __pyx_k__getrname, sizeof(__pyx_k__getrname), 0, 0, 1, 1}, + {&__pyx_n_s__gettid, __pyx_k__gettid, sizeof(__pyx_k__gettid), 0, 0, 1, 1}, + {&__pyx_n_s__hasReference, __pyx_k__hasReference, sizeof(__pyx_k__hasReference), 0, 0, 1, 1}, + {&__pyx_n_s__hash, __pyx_k__hash, sizeof(__pyx_k__hash), 0, 0, 1, 1}, + {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1}, + {&__pyx_n_s__het_rate, __pyx_k__het_rate, sizeof(__pyx_k__het_rate), 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__indel, __pyx_k__indel, sizeof(__pyx_k__indel), 0, 0, 1, 1}, + {&__pyx_n_s__indel1, __pyx_k__indel1, sizeof(__pyx_k__indel1), 0, 0, 1, 1}, + {&__pyx_n_s__indel2, __pyx_k__indel2, sizeof(__pyx_k__indel2), 0, 0, 1, 1}, + {&__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_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}, + {&__pyx_n_s__l_qseq, __pyx_k__l_qseq, sizeof(__pyx_k__l_qseq), 0, 0, 1, 1}, + {&__pyx_n_s__l_text, __pyx_k__l_text, sizeof(__pyx_k__l_text), 0, 0, 1, 1}, + {&__pyx_n_s__level, __pyx_k__level, sizeof(__pyx_k__level), 0, 0, 1, 1}, + {&__pyx_n_s__m_data, __pyx_k__m_data, sizeof(__pyx_k__m_data), 0, 0, 1, 1}, + {&__pyx_n_s__map, __pyx_k__map, sizeof(__pyx_k__map), 0, 0, 1, 1}, + {&__pyx_n_s__mapping_quality, __pyx_k__mapping_quality, sizeof(__pyx_k__mapping_quality), 0, 0, 1, 1}, + {&__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__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}, + {&__pyx_n_s__n_hap, __pyx_k__n_hap, sizeof(__pyx_k__n_hap), 0, 0, 1, 1}, + {&__pyx_n_s__n_haplotypes, __pyx_k__n_haplotypes, sizeof(__pyx_k__n_haplotypes), 0, 0, 1, 1}, + {&__pyx_n_s__n_plp, __pyx_k__n_plp, sizeof(__pyx_k__n_plp), 0, 0, 1, 1}, + {&__pyx_n_s__n_pu, __pyx_k__n_pu, sizeof(__pyx_k__n_pu), 0, 0, 1, 1}, + {&__pyx_n_s__n_targets, __pyx_k__n_targets, sizeof(__pyx_k__n_targets), 0, 0, 1, 1}, + {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1}, + {&__pyx_n_s__nextiter, __pyx_k__nextiter, sizeof(__pyx_k__nextiter), 0, 0, 1, 1}, + {&__pyx_n_s__nreferences, __pyx_k__nreferences, sizeof(__pyx_k__nreferences), 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__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__q_ref, __pyx_k__q_ref, sizeof(__pyx_k__q_ref), 0, 0, 1, 1}, + {&__pyx_n_s__qname, __pyx_k__qname, sizeof(__pyx_k__qname), 0, 0, 1, 1}, + {&__pyx_n_s__qpos, __pyx_k__qpos, sizeof(__pyx_k__qpos), 0, 0, 1, 1}, + {&__pyx_n_s__qseq, __pyx_k__qseq, sizeof(__pyx_k__qseq), 0, 0, 1, 1}, + {&__pyx_n_s__qual, __pyx_k__qual, sizeof(__pyx_k__qual), 0, 0, 1, 1}, + {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1}, + {&__pyx_n_s__r_indel, __pyx_k__r_indel, sizeof(__pyx_k__r_indel), 0, 0, 1, 1}, + {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, + {&__pyx_n_s__raw, __pyx_k__raw, sizeof(__pyx_k__raw), 0, 0, 1, 1}, + {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1}, + {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1}, + {&__pyx_n_s__readAndRelease, __pyx_k__readAndRelease, sizeof(__pyx_k__readAndRelease), 0, 0, 1, 1}, + {&__pyx_n_s__readlines, __pyx_k__readlines, sizeof(__pyx_k__readlines), 0, 0, 1, 1}, + {&__pyx_n_s__reads_diff, __pyx_k__reads_diff, sizeof(__pyx_k__reads_diff), 0, 0, 1, 1}, + {&__pyx_n_s__reads_first, __pyx_k__reads_first, sizeof(__pyx_k__reads_first), 0, 0, 1, 1}, + {&__pyx_n_s__reads_second, __pyx_k__reads_second, sizeof(__pyx_k__reads_second), 0, 0, 1, 1}, + {&__pyx_n_s__record, __pyx_k__record, sizeof(__pyx_k__record), 0, 0, 1, 1}, + {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1}, + {&__pyx_n_s__reference_base, __pyx_k__reference_base, sizeof(__pyx_k__reference_base), 0, 0, 1, 1}, + {&__pyx_n_s__referencelengths, __pyx_k__referencelengths, sizeof(__pyx_k__referencelengths), 0, 0, 1, 1}, + {&__pyx_n_s__referencenames, __pyx_k__referencenames, sizeof(__pyx_k__referencenames), 0, 0, 1, 1}, + {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1}, + {&__pyx_n_s__release, __pyx_k__release, sizeof(__pyx_k__release), 0, 0, 1, 1}, + {&__pyx_n_s__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1}, + {&__pyx_n_s__reopen, __pyx_k__reopen, sizeof(__pyx_k__reopen), 0, 0, 1, 1}, + {&__pyx_n_s__reset, __pyx_k__reset, sizeof(__pyx_k__reset), 0, 0, 1, 1}, + {&__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}, + {&__pyx_n_s__samfile, __pyx_k__samfile, sizeof(__pyx_k__samfile), 0, 0, 1, 1}, + {&__pyx_n_s__samtools, __pyx_k__samtools, sizeof(__pyx_k__samtools), 0, 0, 1, 1}, + {&__pyx_n_s__second_allele, __pyx_k__second_allele, sizeof(__pyx_k__second_allele), 0, 0, 1, 1}, + {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1}, + {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1}, + {&__pyx_n_s__seq, __pyx_k__seq, sizeof(__pyx_k__seq), 0, 0, 1, 1}, + {&__pyx_n_s__seq_len, __pyx_k__seq_len, sizeof(__pyx_k__seq_len), 0, 0, 1, 1}, + {&__pyx_n_s__setdevice, __pyx_k__setdevice, sizeof(__pyx_k__setdevice), 0, 0, 1, 1}, + {&__pyx_n_s__setfd, __pyx_k__setfd, sizeof(__pyx_k__setfd), 0, 0, 1, 1}, + {&__pyx_n_s__setfile, __pyx_k__setfile, sizeof(__pyx_k__setfile), 0, 0, 1, 1}, + {&__pyx_n_s__setupIteratorData, __pyx_k__setupIteratorData, sizeof(__pyx_k__setupIteratorData), 0, 0, 1, 1}, + {&__pyx_n_s__snp_quality, __pyx_k__snp_quality, sizeof(__pyx_k__snp_quality), 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__stderr_f, __pyx_k__stderr_f, sizeof(__pyx_k__stderr_f), 0, 0, 1, 1}, + {&__pyx_n_s__stderr_h, __pyx_k__stderr_h, sizeof(__pyx_k__stderr_h), 0, 0, 1, 1}, + {&__pyx_n_s__stderr_save, __pyx_k__stderr_save, sizeof(__pyx_k__stderr_save), 0, 0, 1, 1}, + {&__pyx_n_s__stdout, __pyx_k__stdout, sizeof(__pyx_k__stdout), 0, 0, 1, 1}, + {&__pyx_n_s__stepper, __pyx_k__stepper, sizeof(__pyx_k__stepper), 0, 0, 1, 1}, + {&__pyx_n_s__streams, __pyx_k__streams, sizeof(__pyx_k__streams), 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__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}, + {&__pyx_n_s__tell, __pyx_k__tell, sizeof(__pyx_k__tell), 0, 0, 1, 1}, + {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1}, + {&__pyx_n_s__template, __pyx_k__template, sizeof(__pyx_k__template), 0, 0, 1, 1}, + {&__pyx_n_s__text, __pyx_k__text, sizeof(__pyx_k__text), 0, 0, 1, 1}, + {&__pyx_n_s__theta, __pyx_k__theta, sizeof(__pyx_k__theta), 0, 0, 1, 1}, + {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1}, + {&__pyx_n_s__traceback, __pyx_k__traceback, sizeof(__pyx_k__traceback), 0, 0, 1, 1}, + {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1}, + {&__pyx_n_s__until_eof, __pyx_k__until_eof, sizeof(__pyx_k__until_eof), 0, 0, 1, 1}, + {&__pyx_n_s__view, __pyx_k__view, sizeof(__pyx_k__view), 0, 0, 1, 1}, + {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1}, + {&__pyx_n_s__wb, __pyx_k__wb, sizeof(__pyx_k__wb), 0, 0, 1, 1}, + {&__pyx_n_s__wbu, __pyx_k__wbu, sizeof(__pyx_k__wbu), 0, 0, 1, 1}, + {&__pyx_n_s__wh, __pyx_k__wh, sizeof(__pyx_k__wh), 0, 0, 1, 1}, + {&__pyx_n_s__where, __pyx_k__where, sizeof(__pyx_k__where), 0, 0, 1, 1}, + {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1}, + {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1}, + {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 = 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 = 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; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initcsamtools(void); /*proto*/ +PyMODINIT_FUNC initcsamtools(void) +#else +PyMODINIT_FUNC PyInit_csamtools(void); /*proto*/ +PyMODINIT_FUNC PyInit_csamtools(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + 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"); + 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_csamtools(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("csamtools"), __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_csamtools) { + 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_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 = 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 = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_9csamtools_AlignedRead = &__pyx_type_9csamtools_AlignedRead; + __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 = 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 = 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 = 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_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 + __pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent; + __pyx_vtable_9csamtools_IteratorRowRegion.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_cnext; + #else + *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent; + *(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 = 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 = 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 = 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 + __pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_getCurrent; + __pyx_vtable_9csamtools_IteratorRowAll.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_cnext; + #else + *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_getCurrent; + *(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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_vtable_9csamtools_IteratorColumn.getSequence = (char *(*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_getSequence; + __pyx_vtable_9csamtools_IteratorColumn.setMask = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_setMask; + __pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData; + __pyx_vtable_9csamtools_IteratorColumn.reset = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_reset; + #else + *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_cnext; + *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.getSequence = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_getSequence; + *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setMask = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setMask; + *(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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 + __pyx_vtable_9csamtools_SNPCallerBase.__dump = (PyObject *(*)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int))__pyx_f_9csamtools_13SNPCallerBase___dump; + #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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 ---*/ + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":4 + * # cython: profile=True + * # adds doc-strings for sphinx + * 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; + + /* "/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__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; + + /* "/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__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; + + /* "/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__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; + + /* "/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__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; + + /* "/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__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; + + /* "/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__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; + + /* "/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__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; + + /* "/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_172; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":64 + * # hard-coded constants + * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN" + * cdef int max_pos = 2 << 29 # <<<<<<<<<<<<<< + * + * # redirect stderr to 0 + */ + __pyx_v_9csamtools_max_pos = 1073741824; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":67 + * + * # redirect stderr to 0 + * _logfile = open(os.path.devnull, "w") # <<<<<<<<<<<<<< + * pysam_set_stderr( PyFile_AsFile( _logfile ) ) + * + */ + __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_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; + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":68 + * # redirect stderr to 0 + * _logfile = open(os.path.devnull, "w") + * pysam_set_stderr( PyFile_AsFile( _logfile ) ) # <<<<<<<<<<<<<< + * + * ##################################################################### + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":117 + * (f)(a) + * + * class PileupColumn(object): # <<<<<<<<<<<<<< + * '''A pileup column. A pileup column contains + * all the reads that map to a certain target base. + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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_2, 0, __pyx_builtin_object); + __Pyx_GIVEREF(__pyx_builtin_object); + 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_2); __pyx_t_2 = 0; + + /* "/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_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_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 = 117; __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":174 + * return 0 + * + * class StderrStore(): # <<<<<<<<<<<<<< + * ''' + * stderr is captured. + */ + __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); + + /* "/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 = 178; __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 = 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_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; + + /* "/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_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_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; + + /* "/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 = 193; __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 = 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_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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199 + * os.remove( self.stderr_f ) + * + * def __del__(self): # <<<<<<<<<<<<<< + * self.release() + * + */ + __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_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 = 174; __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":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:; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":217 + * ###################################################################### + * # valid types for sam headers + * VALID_HEADER_TYPES = { "HD" : dict, # <<<<<<<<<<<<<< + * "SQ" : list, + * "RG" : list, + */ + __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;} + + /* "/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_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;} + + /* "/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_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;} + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":220 + * "SQ" : list, + * "RG" : list, + * "PG" : list, # <<<<<<<<<<<<<< + * "CO" : list } + * + */ + 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;} + + /* "/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_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; + + /* "/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_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_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_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_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_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_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_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; + + /* "/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_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)); + __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; + + /* "/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_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; + + /* "/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_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; + + /* "/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_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; + + /* "/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_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_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_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_1, 2, ((PyObject *)__pyx_n_s__GO)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GO)); + 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; + + /* "/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_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_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_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_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_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_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_1, 5, ((PyObject *)__pyx_n_s__SP)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SP)); + 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; + + /* "/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_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_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_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_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_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_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_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_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_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_1, 8, ((PyObject *)__pyx_n_s__PL)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PL)); + 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; + + /* "/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_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_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_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_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_1, 3, ((PyObject *)__pyx_n_s__CL)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CL)); + 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; + + /* "/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_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; + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1718 + * int tid = 0, + * int start = 0, + * int end = max_pos, # <<<<<<<<<<<<<< + * **kwargs ): + * + */ + __pyx_k_58 = __pyx_v_9csamtools_max_pos; + + /* "/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_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); + + /* "/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_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_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; + + /* "/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_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_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; + + /* "/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_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_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; + + /* "/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_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_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; + + /* "/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_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_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_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; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2736 + * def _samtools_dispatch( method, + * args = (), + * catch_stdout = True, # <<<<<<<<<<<<<< + * catch_stderr = False, + * ): + */ + __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; + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3436 + * if self.owns_samfile: samclose( self.fp ) + * + * __all__ = ["Samfile", # <<<<<<<<<<<<<< + * "Fastafile", + * "IteratorRow", + */ + __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_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_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_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_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_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_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_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_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_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_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_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_3, 11, ((PyObject *)__pyx_n_s__IteratorIndelCalls)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorIndelCalls)); + __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; + + /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1 + * # cython: embedsignature=True # <<<<<<<<<<<<<< + * # cython: profile=True + * # adds doc-strings for sphinx + */ + __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_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; + __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_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; + __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_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; + __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_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; + __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_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_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; + __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___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; + __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_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; + __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___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; + __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_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; + __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___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; + __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_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; + __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__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; + __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_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; + __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__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; + __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_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; + __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___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; + __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_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; + __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_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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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__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_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_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_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___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_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 (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_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 (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_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 (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_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 (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_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 (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_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 (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; + + /* "/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); + __Pyx_XDECREF(__pyx_t_4); + if (__pyx_m) { + __Pyx_AddTraceback("init csamtools"); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init csamtools"); + } + __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; +} + + +#if CYTHON_PROFILE + +static int __Pyx_TraceSetupAndCall(PyCodeObject** code, + PyFrameObject** frame, + const char *funcname, + const char *srcfile, + int firstlineno) { + if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) { + if (*code == NULL) { + *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno); + if (*code == NULL) return 0; + } + *frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate*/ + *code, /*PyCodeObject *code*/ + PyModule_GetDict(__pyx_m), /*PyObject *globals*/ + 0 /*PyObject *locals*/ + ); + if (*frame == NULL) return 0; + } + else { + (*frame)->f_tstate = PyThreadState_GET(); + } + return PyThreadState_GET()->c_profilefunc(PyThreadState_GET()->c_profileobj, *frame, PyTrace_CALL, NULL) == 0; +} + +static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyCodeObject *py_code = 0; + + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + py_srcfile = PyString_FromString(srcfile); + #else + py_funcname = PyUnicode_FromString(funcname); + py_srcfile = PyUnicode_FromString(srcfile); + #endif + if (!py_funcname | !py_srcfile) 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,*/ + firstlineno, /*int firstlineno,*/ + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + + return py_code; +} + +#endif /* CYTHON_PROFILE */ + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +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 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 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 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; +} + + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +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 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; + q -= ((r != 0) & ((r ^ b) < 0)); + return q; +} + +static CYTHON_INLINE long __Pyx_mod_long(long a, long b) { + long r = a % b; + r += ((r != 0) & ((r ^ b) < 0)) * b; + return r; +} + + +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 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); + } +} + +#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 , */ + 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 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 PyObject *__Pyx_PyInt_to_py_int32_t(int32_t val) { + const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(int32_t) == sizeof(char)) || + (sizeof(int32_t) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(int32_t) == sizeof(int)) || + (sizeof(int32_t) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(int32_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(int32_t), + little, !is_unsigned); + } +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int64_t(int64_t val) { + const int64_t neg_one = (int64_t)-1, const_zero = (int64_t)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(int64_t) == sizeof(char)) || + (sizeof(int64_t) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(int64_t) == sizeof(int)) || + (sizeof(int64_t) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(int64_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(int64_t), + little, !is_unsigned); + } +} + +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; + if (sizeof(int32_t) == sizeof(char)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedChar(x); + else + return (int32_t)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(int32_t) == sizeof(short)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedShort(x); + else + return (int32_t)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(int32_t) == sizeof(int)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedInt(x); + else + return (int32_t)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(int32_t) == sizeof(long)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedLong(x); + else + return (int32_t)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (int32_t)__Pyx_PyInt_AsSignedLongLong(x); + } else { + int32_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 (int32_t)-1; + } +} + +static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t val) { + const uint8_t neg_one = (uint8_t)-1, const_zero = (uint8_t)0; + const int is_unsigned = const_zero < neg_one; + if ((sizeof(uint8_t) == sizeof(char)) || + (sizeof(uint8_t) == sizeof(short))) { + return PyInt_FromLong((long)val); + } else if ((sizeof(uint8_t) == sizeof(int)) || + (sizeof(uint8_t) == sizeof(long))) { + if (is_unsigned) + return PyLong_FromUnsignedLong((unsigned long)val); + else + return PyInt_FromLong((long)val); + } else if (sizeof(uint8_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(uint8_t), + little, !is_unsigned); + } +} + +#if PY_MAJOR_VERSION < 3 +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject((char *)"stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { + PyObject* v; + int i; + + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + v = PyTuple_GET_ITEM(arg_tuple, i); + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + Py_ssize_t len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + } + if (newline) { + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + } + return 0; +} + +#else /* Python 3 has a print function */ + +static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { + PyObject* kwargs = 0; + PyObject* result = 0; + PyObject* end_string; + if (unlikely(!__pyx_print)) { + __pyx_print = __Pyx_GetAttrString(__pyx_b, "print"); + if (!__pyx_print) + return -1; + } + if (stream) { + kwargs = PyDict_New(); + if (unlikely(!kwargs)) + return -1; + if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0)) + goto bad; + if (!newline) { + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + goto bad; + if (PyDict_SetItemString(kwargs, "end", end_string) < 0) { + Py_DECREF(end_string); + goto bad; + } + Py_DECREF(end_string); + } + } else if (!newline) { + if (unlikely(!__pyx_print_kwargs)) { + __pyx_print_kwargs = PyDict_New(); + if (unlikely(!__pyx_print_kwargs)) + return -1; + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + return -1; + if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) { + Py_DECREF(end_string); + return -1; + } + Py_DECREF(end_string); + } + kwargs = __pyx_print_kwargs; + } + result = PyObject_Call(__pyx_print, arg_tuple, kwargs); + if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) + Py_DECREF(kwargs); + if (!result) + return -1; + Py_DECREF(result); + return 0; +bad: + if (kwargs != __pyx_print_kwargs) + Py_XDECREF(kwargs); + return -1; +} + +#endif + +#if PY_MAJOR_VERSION < 3 + +static int __Pyx_PrintOne(PyObject* f, PyObject *o) { + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + if (PyFile_SoftSpace(f, 0)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + return 0; + /* the line below is just to avoid compiler + * compiler warnings about unused functions */ + return __Pyx_Print(f, NULL, 0); +} + +#else /* Python 3 has a print function */ + +static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { + int res; + PyObject* arg_tuple = PyTuple_New(1); + if (unlikely(!arg_tuple)) + return -1; + Py_INCREF(o); + PyTuple_SET_ITEM(arg_tuple, 0, o); + res = __Pyx_Print(stream, arg_tuple, 1); + Py_DECREF(arg_tuple); + return res; +} + +#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; + 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); + } +} + +#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_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/csamtools.pxd b/pysam/csamtools.pxd index b614a84..df37638 100644 --- a/pysam/csamtools.pxd +++ b/pysam/csamtools.pxd @@ -1,4 +1,3 @@ - cdef extern from "string.h": ctypedef int size_t void *memcpy(void *dst,void *src,size_t len) @@ -14,6 +13,9 @@ cdef extern from "stdlib.h": void qsort(void *base, size_t nmemb, size_t size, int (*compar)(void *,void *)) +cdef extern from "math.h": + double sqrt(double x) + cdef extern from "stdio.h": ctypedef struct FILE: pass @@ -52,6 +54,11 @@ cdef extern from "string.h": cdef extern from "Python.h": long _Py_HashPointer(void*) + FILE* PyFile_AsFile(object) + +cdef extern from "fileobject.h": + ctypedef class __builtin__.file [object PyFileObject]: + pass cdef extern from "razf.h": pass @@ -63,9 +70,10 @@ cdef extern from "stdint.h": ctypedef int uint8_t ctypedef int uint64_t - cdef extern from "bam.h": + # constants + int BAM_DEF_MASK # IF _IOLIB=2, bamFile = BGZF, see bgzf.h # samtools uses KNETFILE, check how this works @@ -123,8 +131,16 @@ cdef extern from "bam.h": ctypedef struct bam_plbuf_t: pass + ctypedef struct pair64_t: + uint64_t u, v + ctypedef struct bam_iter_t: - pass + int from_first + int tid, beg, end, n_off, i, finished + uint64_t curr_off + pair64_t *off + + # ctypedef __bam_iter_t * bam_iter_t bam1_t * bam_init1() void bam_destroy1(bam1_t *) @@ -176,20 +192,22 @@ cdef extern from "bam.h": ctypedef struct bam_plp_t: pass + ctypedef bam_pileup1_t * const_bam_pileup1_t_ptr "const bam_pileup1_t *" + ctypedef int (*bam_plp_auto_f)(void *data, bam1_t *b) bam_plp_t bam_plp_init( bam_plp_auto_f func, void *data) int bam_plp_push( bam_plp_t iter, bam1_t *b) - bam_pileup1_t *bam_plp_next( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp) - bam_pileup1_t *bam_plp_auto( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp) + bam_pileup1_t * bam_plp_next( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp) + bam_pileup1_t * bam_plp_auto( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp) void bam_plp_set_mask(bam_plp_t iter, int mask) void bam_plp_reset(bam_plp_t iter) void bam_plp_destroy(bam_plp_t iter) ################################################## - int bam_read1(bamFile fp, bam1_t *b) - + int bam_read1( bamFile fp, bam1_t *b) + int bam_validate1( bam_header_t *header, bam1_t *b) int bam_write1( bamFile fp, bam1_t *b) bam_header_t *bam_header_init() @@ -206,7 +224,7 @@ cdef extern from "bam.h": uint8_t *bam_aux_get(bam1_t *b, char tag[2]) - int bam_aux2i(uint8_t *s) + int32_t bam_aux2i(uint8_t *s) float bam_aux2f(uint8_t *s) double bam_aux2d(uint8_t *s) char bam_aux2A( uint8_t *s) @@ -216,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: @@ -228,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) @@ -238,6 +259,73 @@ cdef extern from "sam.h": int samwrite(samfile_t *fp, bam1_t *b) + int bam_prob_realn(bam1_t *b, char *ref) + int bam_cap_mapQ(bam1_t *b, char *ref, int thres) + + +cdef extern from "glf.h": + ctypedef struct glf1_t: + pass + +cdef extern from "bam_maqcns.h": + + ctypedef struct bam_maqcns_t: + float het_rate, theta + int n_hap, cap_mapQ, errmod, min_baseQ + float eta, q_r + double *fk, *coef + double *lhet + void *aux + + glf1_t *bam_maqcns_glfgen(int n, + bam_pileup1_t *pl, + uint8_t ref_base, + bam_maqcns_t *bm) + + ctypedef struct bam_maqindel_opt_t: + int q_indel + float r_indel + float r_snp + int mm_penalty, indel_err, ambi_thres + + uint32_t bam_maqcns_call(int n, bam_pileup1_t *pl, bam_maqcns_t *bm) + bam_maqcns_t * bam_maqcns_init() + void bam_maqcns_destroy(bam_maqcns_t *bm) + void bam_maqcns_prepare(bam_maqcns_t *bm) + + uint32_t glf2cns(glf1_t *g, int q_r) + + int BAM_ERRMOD_MAQ2 + int BAM_ERRMOD_MAQ + int BAM_ERRMOD_SOAP + + ctypedef struct bam_maqindel_ret_t: + int indel1 + int indel2 + int cnt1 + int cnt2 + int cnt_anti + int cnt_ref + int cnt_ambi + char *s[2] + int gt + int gl[2] + int q_cns + int q_ref + + void bam_maqindel_ret_destroy( bam_maqindel_ret_t * ) + + bam_maqindel_opt_t *bam_maqindel_opt_init() + + bam_maqindel_ret_t * bam_maqindel(int n, + int pos, + bam_maqindel_opt_t * mi, + bam_pileup1_t * pl, + char *ref, + int _n_types, + int * _types ) + + cdef extern from "faidx.h": ctypedef struct faidx_t: @@ -256,6 +344,7 @@ cdef extern from "faidx.h": char *faidx_fetch_seq(faidx_t *fai, char *c_name, int p_beg_i, int p_end_i, int *len) + cdef extern from "pysam_util.h": int pysam_pileup_next(bam1_t *b, @@ -280,4 +369,43 @@ cdef extern from "pysam_util.h": # translate char to unsigned char unsigned char pysam_translate_sequence( char s ) - + unsigned char * bam_nt16_table + + int pysam_reference2tid( bam_header_t *header, char * s ) + + void pysam_set_stderr( FILE * file ) + + 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 ) + diff --git a/pysam/csamtools.pyx b/pysam/csamtools.pyx index e94e0e6..471a445 100644 --- a/pysam/csamtools.pyx +++ b/pysam/csamtools.pyx @@ -1,11 +1,21 @@ # cython: embedsignature=True # cython: profile=True # adds doc-strings for sphinx - -import tempfile, os, sys, types, itertools, struct, ctypes - -from python_string cimport PyString_FromStringAndSize, PyString_AS_STRING -from python_exc cimport PyErr_SetString +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 @@ -48,26 +58,30 @@ DEF BAM_CSOFT_CLIP = 4 DEF BAM_CHARD_CLIP = 5 DEF BAM_CPAD = 6 +##################################################################### +# hard-coded constants +cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN" +cdef int max_pos = 2 << 29 + +# redirect stderr to 0 +_logfile = open(os.path.devnull, "w") +pysam_set_stderr( PyFile_AsFile( _logfile ) ) + ##################################################################### ##################################################################### ##################################################################### ## private factory methods ##################################################################### cdef class AlignedRead -cdef makeAlignedRead( bam1_t * src): +cdef makeAlignedRead(bam1_t * src): '''enter src into AlignedRead.''' - cdef AlignedRead dest - dest = AlignedRead() - # destroy dummy delegate created in constructor - # to prevent memory leak. - bam_destroy1(dest._delegate) + cdef AlignedRead dest = AlignedRead.__new__(AlignedRead) dest._delegate = bam_dup1(src) return dest cdef class PileupProxy cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ): - cdef PileupProxy dest - dest = PileupProxy() + cdef PileupProxy dest = PileupProxy.__new__(PileupProxy) dest.plp = plp dest.tid = tid dest.pos = pos @@ -77,8 +91,7 @@ cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ): cdef class PileupRead cdef makePileupRead( bam_pileup1_t * src ): '''fill a PileupRead object from a bam_pileup1_t * object.''' - cdef PileupRead dest - dest = PileupRead() + cdef PileupRead dest = PileupRead.__new__(PileupRead) dest._alignment = makeAlignedRead( src.b ) dest._qpos = src.qpos dest._indel = src.indel @@ -163,11 +176,13 @@ class StderrStore(): stderr is captured. ''' 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 ) def readAndRelease( self ): + return [] self.stderr_save.restore() lines = [] if os.path.exists(self.stderr_f): @@ -176,6 +191,7 @@ class StderrStore(): return lines def release(self): + return self.stderr_save.restore() if os.path.exists(self.stderr_f): os.remove( self.stderr_f ) @@ -183,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 + + ###################################################################### ###################################################################### ###################################################################### @@ -200,13 +227,13 @@ VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" ) 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" : { "ID" : str, "VN" : str, "CL" : str }, } + "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, } # 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" : ( "ID", "VN", "CL" ), } + "PG" : ( "PN", "ID", "VN", "CL" ), } ###################################################################### @@ -214,54 +241,220 @@ VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ), ###################################################################### ## Public methods ###################################################################### +cdef class Fastafile: + '''*(filename)* + + A *FASTA* file. The file is automatically opened. + + The file expects an indexed fasta file. + + TODO: + add automatic indexing. + add function to get sequence names. + ''' + + cdef char * _filename + # pointer to fastafile + cdef faidx_t * fastafile + + def __cinit__(self, *args, **kwargs ): + self.fastafile = NULL + self._filename = NULL + self._open( *args, **kwargs ) + + def _isOpen( self ): + '''return true if samfile has been opened.''' + return self.fastafile != NULL + + def __len__(self): + if self.fastafile == NULL: + raise ValueError( "calling len() on closed file" ) + + return faidx_fetch_nseq(self.fastafile) + + def _open( self, + char * filename ): + '''open an indexed fasta file. + + This method expects an indexed fasta file. + ''' + + # close a previously opened file + if self.fastafile != NULL: self.close() + if self._filename != NULL: free(self._filename) + self._filename = strdup(filename) + self.fastafile = fai_load( filename ) + + if self.fastafile == NULL: + raise IOError("could not open file `%s`" % filename ) + + def close( self ): + if self.fastafile != NULL: + fai_destroy( self.fastafile ) + self.fastafile = NULL + + def __dealloc__(self): + self.close() + if self._filename != NULL: free(self._filename) + + property filename: + '''number of :term:`filename` associated with this object.''' + def __get__(self): + if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + return self._filename + + def fetch( self, + reference = None, + start = None, + end = None, + region = None): + + '''*(reference = None, start = None, end = None, region = None)* + + fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. + + The region is specified by :term:`reference`, *start* and *end*. + + fetch returns an empty string if the region is out of range or addresses an unknown *reference*. + + If *reference* is given and *start* is None, the sequence from the + first base is returned. Similarly, if *end* is None, the sequence + until the last base is returned. + + Alternatively, a samtools :term:`region` string can be supplied. + ''' + + if not self._isOpen(): + raise ValueError( "I/O operation on closed file" ) + + cdef int length + cdef char * seq + + if not region: + if reference is None: raise ValueError( 'no sequence/region supplied.' ) + if start is None: start = 0 + if end is None: end = max_pos -1 + + 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 ) + 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, + # but use fai_fetch instead + # seq = faidx_fetch_seq(self.fastafile, + # reference, + # start, + # end-1, + # &length) + region = "%s:%i-%i" % (reference, start+1, end) + seq = fai_fetch( self.fastafile, + region, + &length ) + else: + # samtools adds a '\0' at the end + seq = fai_fetch( self.fastafile, region, &length ) + + # copy to python + if seq == NULL: + return "" + else: + try: + py_seq = PyString_FromStringAndSize(seq, length) + finally: + free(seq) + + return py_seq + + cdef char * _fetch( self, char * reference, int start, int end, int * length ): + '''fetch sequence for reference, start and end''' + + return faidx_fetch_seq(self.fastafile, + reference, + start, + end-1, + length ) + +#------------------------------------------------------------------------ +#------------------------------------------------------------------------ +#------------------------------------------------------------------------ +cdef int count_callback( bam1_t *alignment, void *f): + '''callback for bam_fetch - count number of reads. + ''' + cdef int* counter = (f) + counter[0] += 1; + +ctypedef struct MateData: + char * name + bam1_t * mate + uint32_t flag + +#------------------------------------------------------------------------ +#------------------------------------------------------------------------ +#------------------------------------------------------------------------ +cdef int mate_callback( bam1_t *alignment, void *f): + '''callback for bam_fetch = filter mate + ''' + cdef MateData * d = (f) + # printf("mate = %p, name1 = %s, name2=%s\t%i\t%i\t%i\n", + # d.mate, d.name, bam1_qname(alignment), + # d.flag, alignment.core.flag, alignment.core.flag & d.flag) + + if d.mate == NULL: + # could be sped up by comparing the lengths of query strings first + # using l_qname + # + # also, make sure that we get the other read by comparing + # the flags + if alignment.core.flag & d.flag != 0 and \ + strcmp( bam1_qname( alignment ), d.name ) == 0: + d.mate = bam_dup1( alignment ) + + 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 *SAM* file. The file is automatically opened. + 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``. - Currently valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. - - so to open a :term:`BAM` file for reading:: + Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open + a :term:`BAM` formatted file for reading, type:: - f=Samfile('ex1.bam','rb') + 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:: - For writing, the header of a :term:`TAM` file/:term:`BAM` file can be constituted from several - sources: + f1 = pysam.Samfile('ex1.bam' ) + f2 = pysam.Samfile('ex1.bam' ) - 1. If *template* is given, the header is copied from a another *Samfile* (*template* must be of type *Samfile*). + 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. - 2. If *header* is given, the header is build from a multi-level dictionary. The first level are the four types ('HD', 'SQ', ...). The second level is then a list of lines, with each line being a list of tag-value pairs. + For writing, the header of a :term:`SAM` file/:term:`BAM` file can be constituted from several + sources (see also the samtools format specification): + + 1. If *template* is given, the header is copied from a another *Samfile* + (*template* must be of type *Samfile*). + + 2. If *header* is given, the header is built from a multi-level dictionary. The first level + are the four types ('HD', 'SQ', ...). The second level are a list of lines, with each line + being a list of tag-value pairs. 3. If *text* is given, new header text is copied from raw text. 4. The names (*referencenames*) and lengths (*referencelengths*) are supplied directly as lists. - 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. ''' - 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 self.isbam = False self._open( *args, **kwargs ) @@ -278,7 +471,7 @@ cdef class Samfile: def _open( self, char * filename, - mode = 'r', + mode = None, Samfile template = None, referencenames = None, referencelengths = None, @@ -292,7 +485,24 @@ 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 # close a previously opened file if self.samfile != NULL: self.close() @@ -300,8 +510,9 @@ cdef class Samfile: cdef bam_header_t * header_to_write header_to_write = NULL - - self.filename = filename + + if self._filename != NULL: free(self._filename ) + self._filename = strdup( filename ) self.isbam = len(mode) > 1 and mode[1] == 'b' @@ -367,15 +578,17 @@ cdef class Samfile: not os.path.exists( filename ): raise IOError( "file `%s` not found" % filename) - store = StderrStore() + # try to detect errors self.samfile = samopen( filename, mode, NULL ) - result = store.readAndRelease() - # test for specific messages as open also outputs status messages - # that can be ignored. - if "[bam_header_read] invalid BAM binary header (this is not a BAM file).\n" in result: - raise ValueError( "invalid BAM binary header (is this a BAM file?)" ) - elif '[samopen] no @SQ lines in the header.\n' in result: - raise ValueError( "no @SQ lines in the header (is this a SAM file?)") + if self.samfile == NULL: + raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode) + + if self.samfile.header == NULL: + 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( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode) if self.samfile == NULL: raise IOError("could not open file `%s`" % filename ) @@ -396,26 +609,43 @@ 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 ): - '''(tid ) - convert numerical :term:`tid` into :ref:`reference` name.''' + ''' + convert numerical :term:`tid` into :term:`reference` name.''' + if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + if not 0 <= tid < self.samfile.header.n_targets: + raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) ) + return self.samfile.header.target_name[tid] + + 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" ) 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 _parseRegion( self, reference = None, start = None, - end = None, + end = None, region = None ): - '''parse region information. + ''' + parse region information. - raise Value for for invalid regions. + raise ValueError for for invalid regions. - returns a tuple of region, tid, start and end. Region - is a valid samtools :term:`region` or None if the region - extends over the whole file. + returns a tuple of flag, tid, start and end. Flag indicates + whether some coordinates were supplied. Note that regions are 1-based, while start,end are python coordinates. ''' @@ -424,34 +654,44 @@ cdef class Samfile: # implementing it all in pysam (makes use of khash). cdef int rtid - cdef int rstart - cdef int rend - cdef int max_pos - max_pos = 2 << 29 - - rtid = rstart = rend = 0 + cdef long long rstart + cdef long long rend - # translate to a region - if reference: - if start != None and end != None: - if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) ) - region = "%s:%i-%i" % (reference, start+1, end) - else: - region = reference + rtid = -1 + rstart = 0 + rend = max_pos + 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: - # this function might be called often (multiprocessing) - # thus avoid using StderrStore, see issue 46. - bam_parse_region( self.samfile.header, 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) ) - 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 ) - - return region, rtid, rstart, rend + parts = re.split( "[:-]", region ) + 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 + + 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 ) + + return 1, rtid, rstart, rend def seek( self, uint64_t offset, int where = 0): - '''move to current file to position *offset*''' + ''' + move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`. + ''' if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) @@ -460,7 +700,9 @@ cdef class Samfile: return bam_seek( self.samfile.x.bam, offset, where ) def tell( self ): - '''return current file position''' + ''' + return current file position + ''' if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) if not self.isbam: @@ -475,42 +717,39 @@ cdef class Samfile: region = None, callback = None, until_eof = False ): - '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)* - - fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. The region is specified by - :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied. + ''' + fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by + :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can + be supplied. Without *reference* or *region* all reads will be fetched. The reads will be returned ordered by reference sequence, which will not necessarily be the order within the file. If *until_eof* is given, all reads from the current file position will be returned - *as they are sorted within the file*. + *in order as they are within the file*. - If only *reference* is set, all reads matching on *reference* will be fetched. + If only *reference* is set, all reads aligned to *reference* will be fetched. The method returns an iterator of type :class:`pysam.IteratorRow` unless a *callback is provided. If *callback* is given, the callback will be executed for each position within the :term:`region`. Note that callbacks currently work only, if *region* or *reference* is given. - Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given, + Note that a :term:`SAM` file does not allow random access. If *region* or *reference* are given, an exception is raised. ''' - cdef int rtid - cdef int rstart - cdef int rend + cdef int rtid, rstart, rend, has_coord if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) - - region, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + 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: - if not region: - raise ValueError( "callback functionality requires a region/reference" ) + 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, @@ -520,20 +759,13 @@ cdef class Samfile: callback, fetch_callback ) else: - if region: - return IteratorRow( self, rtid, rstart, rend ) + if has_coord: + return IteratorRowRegion( self, rtid, rstart, rend ) else: if until_eof: return IteratorRowAll( self ) else: - # return all targets by chaining the individual targets together. - if not self._hasIndex(): raise ValueError( "no index available for fetch" ) - i = [] - rstart = 0 - rend = 1<<29 - for rtid from 0 <= rtid < self.nreferences: - i.append( IteratorRow( self, rtid, rstart, rend)) - return itertools.chain( *i ) + return IteratorRowAllRefs(self) else: # check if header is present - otherwise sam_read1 aborts # this happens if a bamfile is opened with mode 'r' @@ -547,41 +779,155 @@ cdef class Samfile: else: return IteratorRowAll( self ) - def pileup( self, reference = None, start = None, end = None, region = None, callback = None ): - '''run a pileup within a :term:`region` using 0-based indexing. The region is specified by - :term:`reference`, *start* and *end*. Alternatively, a samtools *region* string can be supplied. + def mate( self, + AlignedRead read ): + '''return the mate of :class:`AlignedRead` *read*. - Without *reference* or *region* all reads will be fetched. The reads will be returned + Throws a ValueError if read is unpaired or the mate + is unmapped. + + .. note:: + Calling this method will change the file position. + This might interfere with any iterators that have + not re-opened the file. + + ''' + 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 + + mate_data.name = bam1_qname(read._delegate) + mate_data.mate = NULL + # xor flags to get the other mate + cdef int x = BAM_FREAD1 + BAM_FREAD2 + mate_data.flag = ( flag ^ x) & x + + bam_fetch(self.samfile.x.bam, + self.index, + read._delegate.core.mtid, + read._delegate.core.mpos, + read._delegate.core.mpos + 1, + &mate_data, + mate_callback ) + + if mate_data.mate == NULL: + raise ValueError( "mate not found" ) + + cdef AlignedRead dest = AlignedRead.__new__(AlignedRead) + dest._delegate = mate_data.mate + return dest + + def count( self, + reference = None, + start = None, + end = None, + region = None, + until_eof = False ): + '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)* + + count reads :term:`region` using 0-based indexing. The region is specified by + :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied. + + Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given, + an exception is raised. + ''' + cdef int rtid + cdef int rstart + cdef int rend + + if not self._isOpen(): + raise ValueError( "I/O operation on closed file" ) + + region, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + + cdef int counter + counter = 0; + + 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: + 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, + rtid, + rstart, + rend, + &counter, + count_callback ) + return counter + else: + raise ValueError ("count for a region is not available for sam files" ) + + def pileup( self, + reference = None, + start = None, + end = None, + region = None, + callback = None, + **kwargs ): + ''' + perform a :term:`pileup` within a :term:`region`. The region is specified by + :term:`reference`, *start* and *end* (using 0-based indexing). + Alternatively, a samtools *region* string can be supplied. + + Without *reference* or *region* all reads will be used for the pileup. The reads will be returned ordered by :term:`reference` sequence, which will not necessarily be the order within the file. The method returns an iterator of type :class:`pysam.IteratorColumn` unless - a *callback is provided. If *callback* is given, the callback will be executed - for each position within the :term:`region`. + a *callback is provided. If a *callback* is given, the callback will be executed + for each column within the :term:`region`. - Note that samfiles do not allow random access. If *region* or *reference* are given, - an exception is raised. + Note that :term:`SAM` formatted files do not allow random access. + In these files, if a *region* or *reference* are given an exception is raised. - .. Note:: + Optional *kwargs* to the iterator: + + stepper + The stepper controlls how the iterator advances. + Possible options for the stepper are + + ``all`` + use all reads for pileup. + ``samtools`` + same filter and read processing as in :term:`csamtools` pileup + + fastafile + A :class:`FastaFile` object + + mask + Skip all reads with bits set in mask. + + + .. note:: *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 - cdef int rstart - cdef int rend + cdef int rtid, rstart, rend, has_coord cdef bam_plbuf_t *buf if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) - region, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) - + has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region ) + if self.isbam: if not self._hasIndex(): raise ValueError( "no index available for pileup" ) if callback: - if not region: - raise ValueError( "callback functionality requires a region/reference" ) + if not has_coord: raise ValueError( "callback functionality requires a region/reference" ) buf = bam_plbuf_init( pileup_callback, callback ) bam_fetch(self.samfile.x.bam, @@ -592,22 +938,21 @@ cdef class Samfile: bam_plbuf_push( NULL, buf) bam_plbuf_destroy(buf) else: - if region: - return IteratorColumn( self, rtid, rstart, rend ) + if has_coord: + return IteratorColumnRegion( self, + tid = rtid, + start = rstart, + end = rend, + **kwargs ) else: - # return all targets by chaining the individual targets together. - i = [] - rstart = 0 - rend = 1<<29 - for rtid from 0 <= rtid < self.nreferences: - i.append( IteratorColumn( self, rtid, rstart, rend)) - return itertools.chain( *i ) + return IteratorColumnAllRefs(self, **kwargs ) else: raise NotImplementedError( "pileup of samfiles not implemented yet" ) def close( self ): - '''closes file.''' + ''' + closes the :class:`pysam.Samfile`.''' if self.samfile != NULL: samclose( self.samfile ) bam_index_destroy(self.index); @@ -619,15 +964,16 @@ cdef class Samfile: # note: __del__ is not called. self.close() bam_destroy1(self.b) + if self._filename != NULL: free( self._filename ) - def write( self, AlignedRead read ): - '''(AlignedRead read ) - write a single :class:`pysam.AlignedRead`.. + cpdef int write( self, AlignedRead read ) except -1: + ''' + write a single :class:`pysam.AlignedRead` to disk. - return the number of bytes written. + 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 ) @@ -638,6 +984,17 @@ cdef class Samfile: self.close() return False + ############################################################### + ############################################################### + ############################################################### + ## properties + ############################################################### + property filename: + '''number of :term:`filename` associated with this object.''' + def __get__(self): + if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) + return self._filename + property nreferences: '''number of :term:`reference` sequences in the file.''' def __get__(self): @@ -654,7 +1011,8 @@ cdef class Samfile: return tuple(t) property lengths: - """tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as :attr:`pysam.Samfile.reference` + """tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as + :attr:`pysam.Samfile.references` """ def __get__(self): if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) @@ -698,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: @@ -720,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 ): @@ -779,6 +1148,14 @@ cdef class Samfile: return dest + ############################################################### + ############################################################### + ############################################################### + ## file-object like iterator access + ## note: concurrent access will cause errors (see IteratorRow + ## and reopen) + ## Possible solutions: deprecate or open new file handle + ############################################################### def __iter__(self): if not self._isOpen(): raise ValueError( "I/O operation on closed file" ) return self @@ -787,14 +1164,15 @@ cdef class Samfile: return self.b cdef int cnext(self): - '''cversion of iterator. Used by IteratorColumn''' + ''' + cversion of iterator. Used by :class:`pysam.Samfile.IteratorColumn`. + ''' cdef int ret return samread(self.samfile, self.b) def __next__(self): - """python version of next(). - - pyrex uses this non-standard name instead of next() + """ + python version of next(). """ cdef int ret ret = samread(self.samfile, self.b) @@ -803,121 +1181,36 @@ cdef class Samfile: else: raise StopIteration -cdef class Fastafile: - '''*(filename)* - - A *FASTA* file. The file is automatically opened. - - The file expects an indexed fasta file. - - TODO: - add automatic indexing. - add function to get sequence names. - ''' - - cdef char * filename - # pointer to fastafile - cdef faidx_t * fastafile - - def __cinit__(self, *args, **kwargs ): - self.fastafile = NULL - self._open( *args, **kwargs ) - - def _isOpen( self ): - '''return true if samfile has been opened.''' - return self.fastafile != NULL - - def __len__(self): - if self.fastafile == NULL: - raise ValueError( "calling len() on closed file" ) - - return faidx_fetch_nseq(self.fastafile) - - def _open( self, - char * filename ): - '''open an indexed fasta file. - - This method expects an indexed fasta file. - ''' - - # close a previously opened file - if self.fastafile != NULL: self.close() - self.filename = filename - self.fastafile = fai_load( filename ) +##------------------------------------------------------------------- +##------------------------------------------------------------------- +##------------------------------------------------------------------- +cdef class IteratorRow: + '''abstract base class for iterators over mapped reads. - if self.fastafile == NULL: - raise IOError("could not open file `%s`" % filename ) + Various iterators implement different behaviours for wrapping around + contig boundaries. Examples include: - def close( self ): - if self.fastafile != NULL: - fai_destroy( self.fastafile ) - self.fastafile = NULL + :class:`pysam.IteratorRowRegion` + iterate within a single contig and a defined region. - def fetch( self, - reference = None, - start = None, - end = None, - region = None): - - '''*(reference = None, start = None, end = None, region = None)* - - fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. - The region is specified by :term:`reference`, *start* and *end*. + :class:`pysam.IteratorRowAll` + iterate until EOF. This iterator will also include unmapped reads. - If *reference* is given and *start* is None, the sequence from the - first base is returned. Similarly, if *end* is None, the sequence - until the last base is returned. - - Alternatively, a samtools :term:`region` string can be supplied. - ''' + :class:`pysam.IteratorRowAllRefs` + iterate over all reads in all reference sequences. - if not self._isOpen(): - raise ValueError( "I/O operation on closed file" ) - - cdef int length, max_pos - cdef char * seq - max_pos = 2 << 29 - - if not region: - if reference is None: raise ValueError( 'no sequence/region supplied.' ) - if start is None: start = 0 - if end is None: end = max_pos -1 + The method :meth:`Samfile.fetch` returns an IteratorRow. + ''' + pass - 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 ) - if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end ) - seq = faidx_fetch_seq(self.fastafile, - reference, - start, - end-1, - &length) - else: - # samtools adds a '\0' at the end - seq = fai_fetch( self.fastafile, region, &length ) +cdef class IteratorRowRegion(IteratorRow): + """*(Samfile samfile, int tid, int beg, int end, int reopen = True )* - # copy to python - if seq == NULL: - return "" - else: - try: - py_seq = PyString_FromStringAndSize(seq, length) - finally: - free(seq) + iterate over mapped reads in a region. - return py_seq - -########################################################################### -########################################################################### -########################################################################### -## turning callbacks elegantly into iterators is an unsolved problem, see the following threads: -## http://groups.google.com/group/comp.lang.python/browse_frm/thread/0ce55373f128aa4e/1d27a78ca6408134?hl=en&pli=1 -## http://www.velocityreviews.com/forums/t359277-turning-a-callback-function-into-a-generator.html -## Thus I chose to rewrite the functions requiring callbacks. The downside is that if the samtools C-API or code -## changes, the changes have to be manually entered. -cdef class IteratorRow: - """iterates over mapped reads in a region. + 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 position between iterations do not change. @@ -935,14 +1228,16 @@ cdef class 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 ): + 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" ) if not samfile._hasIndex(): - raise ValueError( "no index available for pileup" ) + raise ValueError( "no index available for iteration" ) # makes sure that samfile stays alive as long as the # iterator is alive @@ -951,10 +1246,17 @@ cdef class IteratorRow: if samfile.isbam: mode = "rb" else: mode = "r" - # reopen the file - store = StderrStore() - self.fp = samopen( samfile.filename, mode, NULL ) - store.release() + # 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 = self.samfile.samfile + self.owns_samfile = False self.retval = 0 @@ -985,16 +1287,24 @@ cdef class IteratorRow: def __dealloc__(self): bam_destroy1(self.b) - samclose( self.fp ) + if self.owns_samfile: samclose( self.fp ) -cdef class IteratorRowAll: - """iterates over all mapped reads +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 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): + def __cinit__(self, Samfile samfile, int reopen = True ): if not samfile._isOpen(): raise ValueError( "I/O operation on closed file" ) @@ -1003,9 +1313,15 @@ cdef class IteratorRowAll: else: mode = "r" # reopen the file to avoid iterator conflict - store = StderrStore() - self.fp = samopen( samfile.filename, mode, NULL ) - store.release() + 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 = calloc(1, sizeof(bam1_t)) @@ -1035,90 +1351,434 @@ cdef class IteratorRowAll: 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 + """ + cdef Samfile samfile + cdef int tid + cdef IteratorRowRegion rowiter + + 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 + + def nextiter(self): + self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29) + + def __iter__(self): + return self + + def __next__(self): + """python version of next(). + + pyrex uses this non-standard name instead of next() + """ + # Create an initial iterator + if self.tid==-1: + if not self.samfile.nreferences: + raise StopIteration + self.tid = 0 + self.nextiter() + + while 1: + self.rowiter.cnext() + + # If current iterator is not exhausted, return aligned read + if self.rowiter.retval>0: + return makeAlignedRead(self.rowiter.b) + + self.tid += 1 + + # Otherwise, proceed to next reference or stop + if self.tidcalloc(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 ) +##------------------------------------------------------------------- +##------------------------------------------------------------------- +##------------------------------------------------------------------- ctypedef struct __iterdata: - bamFile fp + samfile_t * samfile bam_iter_t iter + faidx_t * fastafile + int tid + char * seq + int seq_len + +cdef int __advance_all( void * data, bam1_t * b ): + '''advance without any read filtering. + ''' + cdef __iterdata * d + d = <__iterdata*>data + return bam_iter_read( d.samfile.x.bam, d.iter, b ) -cdef int __advance( void * data, bam1_t * b ): +cdef int __advance_snpcalls( void * data, bam1_t * b ): + '''advance using same filter and read processing as in + the samtools pileup. + ''' cdef __iterdata * d d = <__iterdata*>data - return bam_iter_read( d.fp, d.iter, b ) + + 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 + cdef int is_nobaq = 0 + cdef int capQ_thres = 0 + + # 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, + 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], + d.tid)) + + + while ret >= 0: + + skip = 0 + + # 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: + 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 + + if not skip: break + # additional filters + + ret = bam_iter_read( d.samfile.x.bam, d.iter, b ) + + return ret cdef class IteratorColumn: - '''iterates over columns. + '''abstract base class for iterators over columns. - This iterator wraps the pileup functionality of samtools. + IteratorColumn objects wrap the pileup functionality of samtools. - For reasons of efficiency, the iterator returns the current - pileup buffer. As this buffer is updated at every iteration, - the contents of this iterator will change accordingly. Hence the conversion to - a list will not produce the expected result:: + For reasons of efficiency, the iterator points to the current + pileup buffer. The pileup buffer is updated at every iteration. + This might cause some unexpected behavious. For example, + consider the conversion to a list:: f = Samfile("file.bam", "rb") result = list( f.pileup() ) - Here, result will contain ``n`` objects of type :class:`PileupProxy` for ``n`` columns, - but each object will contain the same information. + Here, ``result`` will contain ``n`` objects of type :class:`PileupProxy` for ``n`` columns, + but each object in ``result`` will contain the same information. - If the results of several columns are required at the same time, the results - need to be stored explicitely:: + The desired behaviour can be achieved by list comprehension:: result = [ x.pileups() for x in f.pileup() ] - Here, result will be a list of ``n`` lists of objects of type :class:`PileupRead`. + ``result`` will be a list of ``n`` lists of objects of type :class:`PileupRead`. + + If the iterator is associated with a :class:`Fastafile` using the :meth:`addReference` + method, then the iterator will export the current sequence via the methods :meth:`getSequence` + and :meth:`seq_len`. + Optional kwargs to the iterator + + stepper + The stepper controlls how the iterator advances. + Possible options for the stepper are + + all + use all reads for pileup. + samtools + same filter and read processing as in :term:`csamtools` pileup + fastafile + A :class:`FastaFile` object + mask + Skip all reads with bits set in mask. + + ''' # result of the last plbuf_push - cdef IteratorRow iter + cdef IteratorRowRegion iter cdef int tid cdef int pos cdef int n_plp - cdef bam_pileup1_t * plp + cdef int mask + cdef const_bam_pileup1_t_ptr plp cdef bam_plp_t pileup_iter cdef __iterdata iterdata - def __cinit__(self, Samfile samfile, int tid, int start, int end ): - - self.iter = IteratorRow( samfile, tid, start, end ) - self.iterdata.fp = samfile.samfile.x.bam - self.iterdata.iter = self.iter.iter + cdef Samfile samfile + cdef Fastafile fastafile + cdef stepper - self.pileup_iter = bam_plp_init( &__advance, &self.iterdata ) - self.n_plp = 0 + 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 ) + self.iterdata.seq = NULL self.tid = 0 self.pos = 0 + self.n_plp = 0 self.plp = NULL + self.pileup_iter = NULL def __iter__(self): return self - cdef int cnext(self): - '''perform next iteration. - ''' - self.plp = bam_plp_auto( self.pileup_iter, - &self.tid, - &self.pos, - &self.n_plp ) + cdef int cnext(self): + '''perform next iteration. + + This method is analogous to the samtools bam_plp_auto method. + It has been re-implemented to permit for filtering. + ''' + self.plp = bam_plp_auto( self.pileup_iter, + &self.tid, + &self.pos, + &self.n_plp ) + + cdef char * getSequence( self ): + '''return current reference sequence underlying the iterator. + ''' + return self.iterdata.seq + + property seq_len: + '''current sequence length.''' + def __get__(self): return self.iterdata.seq_len + + def addReference( self, Fastafile fastafile ): + ''' + 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 + + def hasReference( self ): + ''' + return true if iterator is associated with a reference''' + return self.fastafile + + cdef setMask( self, mask ): + '''set masking flag in iterator. + + reads with bits set in *mask* will be skipped. + ''' + self.mask = mask + bam_plp_set_mask( self.pileup_iter, self.mask ) + + cdef setupIteratorData( self, + int tid, + int start, + int end, + int reopen = 0 ): + '''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 + self.iterdata.seq = NULL + self.iterdata.tid = -1 + + if self.fastafile != None: + self.iterdata.fastafile = self.fastafile.fastafile + else: + 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": + 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 ) + + cdef reset( self, tid, start, end ): + '''reset iterator position. + + This permits using the iterator multiple times without + having to incur the full set-up costs. + ''' + self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 ) + self.iterdata.iter = self.iter.iter + + # invalidate sequence if different tid + if self.tid != tid: + if self.iterdata.seq != NULL: free( self.iterdata.seq ) + self.iterdata.seq = NULL + self.iterdata.tid = -1 + + # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata ) + bam_plp_reset(self.pileup_iter) + + def __dealloc__(self): + # reset in order to avoid memory leak messages for iterators that have + # not been fully consumed + if self.pileup_iter != NULL: + bam_plp_reset(self.pileup_iter) + bam_plp_destroy(self.pileup_iter) + self.pileup_iter = NULL + + if self.iterdata.seq != NULL: + free(self.iterdata.seq) + self.iterdata.seq = NULL + +cdef class IteratorColumnRegion(IteratorColumn): + '''iterates over a region only. + ''' + def __cinit__(self, Samfile samfile, + int tid = 0, + int start = 0, + int end = max_pos, + **kwargs ): + + # initialize iterator + self.setupIteratorData( tid, start, end, 1 ) + + def __next__(self): + """python version of next(). + """ + + while 1: + self.cnext() + if self.n_plp < 0: + raise ValueError("error during iteration" ) + + if self.plp == NULL: + raise StopIteration + + return makePileupProxy( self.plp, + self.tid, + self.pos, + self.n_plp ) + +cdef class IteratorColumnAllRefs(IteratorColumn): + """iterates over all columns by chaining iterators over each reference + """ + + def __cinit__(self, + Samfile samfile, + **kwargs ): + + # no iteration over empty files + if not samfile.nreferences: raise StopIteration + + # initialize iterator + self.setupIteratorData( self.tid, 0, max_pos, 1 ) - def __next__(self): + def __next__(self): """python version of next(). - - pyrex uses this non-standard name instead of next() """ - self.cnext() - if self.n_plp < 0: - raise ValueError("error during iteration" ) - if self.plp == NULL: - raise StopIteration - - return makePileupProxy( self.plp, self.tid, self.pos, self.n_plp ) + while 1: + self.cnext() - def __dealloc__(self): - bam_plp_destroy(self.pileup_iter) + if self.n_plp < 0: + raise ValueError("error during iteration" ) + + # return result, if within same reference + if self.plp != NULL: + return makePileupProxy( self.plp, + self.tid, + self.pos, + self.n_plp ) + + # 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: + raise StopIteration +##------------------------------------------------------------------- +##------------------------------------------------------------------- +##------------------------------------------------------------------- cdef inline int32_t query_start(bam1_t *src) except -1: cdef uint32_t * cigar_p, op cdef uint32_t k @@ -1139,7 +1799,9 @@ cdef inline int32_t query_start(bam1_t *src) except -1: return start_offset - +##------------------------------------------------------------------- +##------------------------------------------------------------------- +##------------------------------------------------------------------- cdef inline int32_t query_end(bam1_t *src) except -1: cdef uint32_t * cigar_p, op cdef uint32_t k @@ -1168,7 +1830,6 @@ cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end): cdef uint8_t * p cdef uint32_t k cdef char * s - cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN" if not src.core.l_qseq: return None @@ -1205,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 @@ -1223,10 +1885,9 @@ 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 - def __cinit__( self ): + # Now only called when instances are created from Python + def __init__(self): # see bam_init1 self._delegate = calloc( 1, sizeof( bam1_t) ) # allocate some memory @@ -1240,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*''' @@ -1355,7 +2028,7 @@ cdef class AlignedRead: pysam_bam_update( src, src.core.n_cigar * 4, len(values) * 4, - p ) + p ) # length is number of cigar operations, not bytes src.core.n_cigar = len(values) @@ -1377,7 +2050,6 @@ cdef class AlignedRead: def __get__(self): cdef bam1_t * src cdef char * s - src = self._delegate if src.core.l_qseq == 0: return None @@ -1599,13 +2271,13 @@ cdef class AlignedRead: for pytag, value in tags: t = type(value) if t == types.FloatType: - fmt = "= -127: fmt, pytype = "= -32767: fmt, pytype = "> 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 @@ -1798,11 +2545,13 @@ cdef class AlignedRead: 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' or type == 'i': + if type == 'c' or type == 'C' or type == 's' or type == 'S': return bam_aux2i(v) - elif type == 'f': + elif type == 'i' or type == 'I': + return bam_aux2i(v) + elif type == 'f' or type == 'F': return bam_aux2f(v) - elif type == 'd': + elif type == 'd' or type == 'D': return bam_aux2d(v) elif type == 'A': # there might a more efficient way @@ -1871,8 +2620,8 @@ cdef class PileupProxy: cdef int pos cdef int n_pu - def __cinit__(self ): - pass + def __init__(self): + raise TypeError("This class cannot be instantiated from Python") def __str__(self): return "\t".join( map(str, (self.tid, self.pos, self.n))) +\ @@ -1915,8 +2664,8 @@ cdef class PileupRead: uint32_t _is_head uint32_t _is_tail - def __cinit__( self ): - pass + def __init__(self): + raise TypeError("This class cannot be instantiated from Python") 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 ) ) ) @@ -1967,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.) @@ -1981,7 +2731,11 @@ class Outs: os.close(self.streams[-1]) del self.streams[-1] -def _samtools_dispatch( method, args = () ): +def _samtools_dispatch( method, + args = (), + catch_stdout = True, + catch_stderr = False, + ): '''call ``method`` in samtools providing arguments in args. .. note:: @@ -2004,23 +2758,29 @@ def _samtools_dispatch( method, args = () ): # note that debugging this module can be a problem # as stdout/stderr will not appear + # some special cases + 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 + if catch_stderr: + stderr_h, stderr_f = tempfile.mkstemp() + stderr_save = Outs( sys.stderr.fileno() ) + stderr_save.setfd( stderr_h ) - # open files and redirect into it - stderr_h, stderr_f = tempfile.mkstemp() - stdout_h, stdout_f = tempfile.mkstemp() + if catch_stdout: + stdout_h, stdout_f = tempfile.mkstemp() + stdout_save = Outs( sys.stdout.fileno() ) + stdout_save.setfd( stdout_h ) - # patch for `samtools view` - # 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 + # patch for `samtools view` + # 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 - stdout_save = Outs( sys.stdout.fileno() ) - stdout_save.setfd( stdout_h ) - stderr_save = Outs( sys.stderr.fileno() ) - stderr_save.setfd( stderr_h ) # do the function call to samtools cdef char ** cargs @@ -2037,28 +2797,655 @@ def _samtools_dispatch( method, args = () ): # restore stdout/stderr. This will also flush, so # needs to be before reading back the file contents - stdout_save.restore() - stderr_save.restore() + if catch_stdout: + stdout_save.restore() + out_stdout = open( stdout_f, "r").readlines() + os.remove( stdout_f ) + else: + out_stdout = [] + + if catch_stderr: + stderr_save.restore() + out_stderr = open( stderr_f, "r").readlines() + os.remove( stderr_f ) + else: + out_stderr = [] + + return retval, out_stderr, out_stdout + +cdef class SNPCall: + '''the results of a SNP call.''' + cdef int _tid + cdef int _pos + cdef char _reference_base + cdef char _genotype + cdef int _consensus_quality + cdef int _snp_quality + cdef int _rms_mapping_quality + cdef int _coverage - # capture stderr/stdout. - out_stderr = open( stderr_f, "r").readlines() - out_stdout = open( stdout_f, "r").readlines() + property tid: + '''the chromosome ID as is defined in the header''' + def __get__(self): + return self._tid + + property pos: + '''nucleotide position of SNP.''' + def __get__(self): return self._pos - # clean up files - os.remove( stderr_f ) - os.remove( stdout_f ) + property reference_base: + '''reference base at pos. ``N`` if no reference sequence supplied.''' + def __get__(self): return PyString_FromStringAndSize( &self._reference_base, 1 ) - return retval, out_stderr, out_stdout + property genotype: + '''the genotype called.''' + def __get__(self): return PyString_FromStringAndSize( &self._genotype, 1 ) + + property consensus_quality: + '''the genotype quality (Phred-scaled).''' + def __get__(self): return self._consensus_quality + + property snp_quality: + '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.''' + def __get__(self): return self._snp_quality + + 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: + '''coverage or read depth - the number of reads involved in the call.''' + def __get__(self): return self._coverage + + def __str__(self): + + return "\t".join( map(str, ( + self.tid, + self.pos, + self.reference_base, + self.genotype, + self.consensus_quality, + self.snp_quality, + self.mapping_quality, + self.coverage ) ) ) + + +cdef class SNPCallerBase: + '''Base class for SNP callers. + + *min_baseQ* + minimum base quality (possibly capped by BAQ) + *capQ_threshold* + coefficient for adjusting mapQ of poor mappings + *theta* + theta in maq consensus calling model + *n_haplotypes* + number of haplotypes in the sample + *het_rate* + prior of a difference between two haplotypes + ''' + + cdef bam_maqcns_t * c + cdef IteratorColumn iter + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + + self.iter = iterator_column + self.c = bam_maqcns_init() + + # set the default parameterization according to + # samtools + + # new default mode for samtools >0.1.10 + self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 ) + + 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 ) + self.c.het_rate = kwargs.get( "het_rate", 0.001 ) + self.c.theta = kwargs.get( "theta", 0.83 ) + + if self.c.errmod != BAM_ERRMOD_MAQ2: + self.c.theta += 0.02 + + # call prepare AFTER setting parameters + bam_maqcns_prepare( self.c ) + + def __dealloc__(self): + bam_maqcns_destroy( self.c ) + + cdef __dump( self, glf1_t * g, uint32_t cns, int rb ): + '''debugging output.''' + + pysam_dump_glf( g, self.c ); + 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, + ) + + 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, + self.iter.n_plp, + rb, + cns >> 8 & 0xff, + cns >> 16 & 0xff, + cns & 0xff, + cns >> 28, + ) + + printf("-------------------------------------\n"); + sys.stdout.flush() + +cdef class IteratorSNPCalls( SNPCallerBase ): + """*(IteratorColumn iterator)* + + call SNPs within a region. + + *iterator* is a pileup iterator. SNPs will be called + on all positions returned by this iterator. + + This caller is fast if SNPs are called over large continuous + regions. It is slow, if instantiated frequently and in random + order as the sequence will have to be reloaded. + + """ + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + + assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence" + + def __iter__(self): + return self + + def __next__(self): + """python version of next(). + """ + + # the following code was adapted from bam_plcmd.c:pileup_func() + self.iter.cnext() + + if self.iter.n_plp < 0: + raise ValueError("error during iteration" ) + + if self.iter.plp == NULL: + raise StopIteration + + cdef char * seq = self.iter.getSequence() + cdef int seq_len = self.iter.seq_len + + assert seq != NULL + + # 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] + cdef uint32_t cns + cdef glf1_t * g + + g = bam_maqcns_glfgen( self.iter.n_plp, + self.iter.plp, + bam_nt16_table[rb], + self.c ) + + if pysam_glf_depth( g ) == 0: + cns = 0xfu << 28 | 0xf << 24 + else: + cns = glf2cns(g, (self.c.q_r + .499)) + + free(g) + + cdef SNPCall call + + call = SNPCall() + call._tid = self.iter.tid + call._pos = self.iter.pos + call._reference_base = rb + call._genotype = bam_nt16_rev_table[cns>>28] + call._consensus_quality = cns >> 8 & 0xff + call._snp_quality = cns & 0xff + call._rms_mapping_quality = cns >> 16&0xff + call._coverage = self.iter.n_plp + + return call + +cdef class SNPCaller( SNPCallerBase ): + '''*(IteratorColumn iterator_column )* + + The samtools SNP caller. + + This object will call SNPs in *samfile* against the reference + sequence in *fasta*. + + This caller is fast for calling few SNPs in selected regions. + + It is slow, if called over large genomic regions. + ''' + + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + + pass + + def call(self, reference, int pos ): + """call a snp on chromosome *reference* + and position *pos*. + + returns a :class:`SNPCall` object. + """ + + cdef int tid = self.iter.samfile.gettid( reference ) + + self.iter.reset( tid, pos, pos + 1 ) + + while 1: + self.iter.cnext() + + if self.iter.n_plp < 0: + raise ValueError("error during iteration" ) + + if self.iter.plp == NULL: + raise ValueError( "no reads in region - no call" ) + + if self.iter.pos == pos: break + + cdef char * seq = self.iter.getSequence() + cdef int seq_len = self.iter.seq_len + + assert seq != NULL + + # 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] + cdef uint32_t cns + cdef glf1_t * g + + g = bam_maqcns_glfgen( self.iter.n_plp, + self.iter.plp, + bam_nt16_table[rb], + self.c ) + + + if pysam_glf_depth( g ) == 0: + cns = 0xfu << 28 | 0xf << 24 + else: + cns = glf2cns(g, (self.c.q_r + .499)) + + free(g) + + cdef SNPCall call + + call = SNPCall() + call._tid = self.iter.tid + call._pos = self.iter.pos + call._reference_base = rb + call._genotype = bam_nt16_rev_table[cns>>28] + call._consensus_quality = cns >> 8 & 0xff + call._snp_quality = cns & 0xff + call._rms_mapping_quality = cns >> 16&0xff + call._coverage = self.iter.n_plp + + return call + +cdef class IndelCall: + '''the results of an indel call.''' + cdef int _tid + cdef int _pos + cdef int _coverage + cdef int _rms_mapping_quality + cdef bam_maqindel_ret_t * _r + + def __cinit__(self): + #assert r != NULL + #self._r = r + pass + + property tid: + '''the chromosome ID as is defined in the header''' + def __get__(self): + return self._tid + + property pos: + '''nucleotide position of SNP.''' + def __get__(self): return self._pos + + property genotype: + '''the genotype called.''' + 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: + s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1) + return "%s/%s" % (s,s) + else: + return "%s/%s" % (self.first_allele, self.second_allele ) + + property consensus_quality: + '''the genotype quality (Phred-scaled).''' + def __get__(self): return self._r.q_cns + + 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: + '''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: + '''coverage or read depth - the number of reads involved in the call.''' + def __get__(self): return self._coverage + + property first_allele: + '''sequence of first allele.''' + def __get__(self): return PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1) + + property second_allele: + '''sequence of second allele.''' + def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1) + + property reads_first: + '''reads supporting first allele.''' + def __get__(self): return self._r.cnt1 + + property reads_second: + '''reads supporting first allele.''' + def __get__(self): return self._r.cnt2 + + property reads_diff: + '''reads supporting first allele.''' + def __get__(self): return self._r.cnt_anti + + def __str__(self): + + return "\t".join( map(str, ( + self.tid, + self.pos, + self.genotype, + self.consensus_quality, + self.snp_quality, + self.mapping_quality, + self.coverage, + self.first_allele, + self.second_allele, + self.reads_first, + self.reads_second, + self.reads_diff ) ) ) + + def __dealloc__(self ): + bam_maqindel_ret_destroy(self._r) + +cdef class IndelCallerBase: + '''Base class for SNP callers. + + *min_baseQ* + minimum base quality (possibly capped by BAQ) + *capQ_threshold* + coefficient for adjusting mapQ of poor mappings + *theta* + theta in maq consensus calling model + *n_haplotypes* + number of haplotypes in the sample + *het_rate* + prior of a difference between two haplotypes + ''' + + cdef bam_maqindel_opt_t * options + cdef IteratorColumn iter + cdef int cap_mapQ + cdef int max_depth + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + + + self.iter = iterator_column + + assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence" + + self.options = bam_maqindel_opt_init() + + # set the default parameterization according to + # 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 ) + self.max_depth = kwargs.get( "max_depth", 1024 ) + + def __dealloc__(self): + free( self.options ) + + def _call( self ): + + cdef char * seq = self.iter.getSequence() + cdef int seq_len = self.iter.seq_len + + assert seq != NULL + + # 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 + + 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", + # m, self.options.q_indel, self.options.r_indel, self.options.r_snp, self.options.mm_penalty, + # self.options.indel_err, self.options.ambi_thres ); + + r = bam_maqindel(m, + self.iter.pos, + self.options, + self.iter.plp, + seq, + 0, + NULL) + + if r == NULL: return None + + cdef IndelCall call + call = IndelCall() + call._r = r + call._tid = self.iter.tid + call._pos = self.iter.pos + call._coverage = self.iter.n_plp + + cdef uint64_t rms_aux = 0 + cdef int i = 0 + cdef bam_pileup1_t * p + 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: + tmp = p.b.core.qual + else: + tmp = self.cap_mapQ + rms_aux += tmp * tmp + + call._rms_mapping_quality = (sqrt(rms_aux / self.iter.n_plp) + .499) + + return call + +cdef class IndelCaller( IndelCallerBase ): + '''*(IteratorColumn iterator_column )* + + The samtools SNP caller. + + This object will call SNPs in *samfile* against the reference + sequence in *fasta*. + + This caller is fast for calling few SNPs in selected regions. + + It is slow, if called over large genomic regions. + ''' + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + + pass + + def call(self, reference, int pos ): + """call a snp on chromosome *reference* + and position *pos*. + + returns a :class:`SNPCall` object or None, if no indel call could be made. + """ + + cdef int tid = self.iter.samfile.gettid( reference ) + + self.iter.reset( tid, pos, pos + 1 ) + + while 1: + self.iter.cnext() + + if self.iter.n_plp < 0: + raise ValueError("error during iteration" ) + + if self.iter.plp == NULL: + raise ValueError( "no reads in region - no call" ) + + if self.iter.pos == pos: break + + return self._call() + +cdef class IteratorIndelCalls( IndelCallerBase ): + """*(IteratorColumn iterator)* + + call indels within a region. + + *iterator* is a pileup iterator. SNPs will be called + on all positions returned by this iterator. + + This caller is fast if SNPs are called over large continuous + regions. It is slow, if instantiated frequently and in random + order as the sequence will have to be reloaded. + + """ + + def __cinit__(self, + IteratorColumn iterator_column, + **kwargs ): + pass + + + def __iter__(self): + return self + + def __next__(self): + """python version of next(). + """ + + # the following code was adapted from bam_plcmd.c:pileup_func() + self.iter.cnext() + + if self.iter.n_plp < 0: + raise ValueError("error during iteration" ) + + if self.iter.plp == NULL: + raise StopIteration + + 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 = 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", - "IteratorRowAll", "IteratorColumn", "AlignedRead", "PileupColumn", "PileupProxy", - "PileupRead" ] + "PileupRead", + "IteratorSNPCalls", + "SNPCaller", + "IndelCaller", + "IteratorIndelCalls", + "IndexedReads" ] diff --git a/pysam/ctabix.c b/pysam/ctabix.c new file mode 100644 index 0000000..11a2c6f --- /dev/null +++ b/pysam/ctabix.c @@ -0,0 +1,9005 @@ +/* Generated by Cython 0.13 on Thu May 5 14:57:46 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 /* 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 +#define __PYX_HAVE_API__ctabix +#include "string.h" +#include "stdlib.h" +#include "stdio.h" +#include "ctype.h" +#include "sys/types.h" +#include "sys/stat.h" +#include "fcntl.h" +#include "unistd.h" +#include "stdint.h" +#include "bgzf.h" +#include "tabix.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[] = { + "ctabix.pyx", + "bool.pxd", + "TabProxies.pxd", +}; + +/* Type declarations */ + +/* "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: # <<<<<<<<<<<<<< + * + * 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; +}; + +/* "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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":161 + * return result + * + * cdef class TabixIterator: # <<<<<<<<<<<<<< + * """iterates over rows in *tabixfile* in region + * given by *tid*, *start* and *end*. + */ + +struct __pyx_obj_6ctabix_TabixIterator { + PyObject_HEAD + ti_iter_t iterator; + tabix_t *tabixfile; +}; + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":304 + * ######################################################### + * ######################################################### + * cdef class TabixIteratorParsed: # <<<<<<<<<<<<<< + * """iterates over mapped reads in a region. + * + */ + +struct __pyx_obj_6ctabix_TabixIteratorParsed { + PyObject_HEAD + ti_iter_t iterator; + tabix_t *tabixfile; + struct __pyx_obj_6ctabix_Parser *parser; +}; + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":216 + * ti_iter_destroy(self.iterator) + * + * cdef class TabixHeaderIterator: # <<<<<<<<<<<<<< + * """return header lines. + * """ + */ + +struct __pyx_obj_6ctabix_TabixHeaderIterator { + PyObject_HEAD + ti_iter_t iterator; + tabix_t *tabixfile; +}; + +/* "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; +}; + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":277 + * return r + * + * cdef class asGTF(Parser): # <<<<<<<<<<<<<< + * '''converts a :term:`tabix row` into a GTF record.''' + * def __call__(self, char * buffer, int len): + */ + +struct __pyx_obj_6ctabix_asGTF { + struct __pyx_obj_6ctabix_Parser __pyx_base; +}; + +/* "/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): # <<<<<<<<<<<<<< + * '''converts a :term:`tabix row` into a python tuple.''' + * def __call__(self, char * buffer, int len): + */ + +struct __pyx_obj_6ctabix_asTuple { + struct __pyx_obj_6ctabix_Parser __pyx_base; +}; + + +/* "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":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; + + +/* "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; + +#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 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 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 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 int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +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 int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*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 int32_t __Pyx_PyInt_from_py_int32_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 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_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; + +/* Implementation of ctabix */ +static PyObject *__pyx_builtin_IOError; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_StopIteration; +static PyObject *__pyx_builtin_OSError; +static PyObject *__pyx_builtin_ord; +static PyObject *__pyx_builtin_KeyError; +static char __pyx_k_1[] = "invalid file opening mode `%s`"; +static char __pyx_k_2[] = ".tbi"; +static char __pyx_k_3[] = "file `%s` not found"; +static char __pyx_k_4[] = "index `%s` not found"; +static char __pyx_k_5[] = "could not open file `%s`"; +static char __pyx_k_6[] = "%s:%i-%i"; +static char __pyx_k_7[] = "invalid region `%s`"; +static char __pyx_k_8[] = "invalid region: start (%i) > end (%i)"; +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[] = "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"; +static char __pyx_k__ec[] = "ec"; +static char __pyx_k__fp[] = "fp"; +static char __pyx_k__os[] = "os"; +static char __pyx_k__sc[] = "sc"; +static char __pyx_k__bed[] = "bed"; +static char __pyx_k__end[] = "end"; +static char __pyx_k__gff[] = "gff"; +static char __pyx_k__idx[] = "idx"; +static char __pyx_k__len[] = "len"; +static char __pyx_k__ord[] = "ord"; +static char __pyx_k__sam[] = "sam"; +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__gzip[] = "gzip"; +static char __pyx_k__join[] = "join"; +static char __pyx_k__keys[] = "keys"; +static char __pyx_k__mode[] = "mode"; +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__start[] = "start"; +static char __pyx_k__types[] = "types"; +static char __pyx_k__buffer[] = "buffer"; +static char __pyx_k__ctypes[] = "ctypes"; +static char __pyx_k__exists[] = "exists"; +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__struct[] = "struct"; +static char __pyx_k__unlink[] = "unlink"; +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__seq_col[] = "seq_col"; +static char __pyx_k__KeyError[] = "KeyError"; +static char __pyx_k__O_RDONLY[] = "O_RDONLY"; +static char __pyx_k____main__[] = "__main__"; +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__iterator[] = "iterator"; +static char __pyx_k__tempfile[] = "tempfile"; +static char __pyx_k__Tabixfile[] = "Tabixfile"; +static char __pyx_k__itertools[] = "itertools"; +static char __pyx_k__line_skip[] = "line_skip"; +static char __pyx_k__meta_char[] = "meta_char"; +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__ValueError[] = "ValueError"; +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__StopIteration[] = "StopIteration"; +static char __pyx_k__TabixIterator[] = "TabixIterator"; +static char __pyx_k__tabix_compress[] = "tabix_compress"; +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_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_s_20; +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_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_s_4; +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__IOError; +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__TabixHeaderIterator; +static PyObject *__pyx_n_s__TabixIterator; +static PyObject *__pyx_n_s__TabixIteratorParsed; +static PyObject *__pyx_n_s__Tabixfile; +static PyObject *__pyx_n_s__ValueError; +static PyObject *__pyx_n_s____all__; +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__asBed; +static PyObject *__pyx_n_s__asGTF; +static PyObject *__pyx_n_s__asTuple; +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__copy; +static PyObject *__pyx_n_s__ctypes; +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__fetch; +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__gff; +static PyObject *__pyx_n_s__gzip; +static PyObject *__pyx_n_s__header; +static PyObject *__pyx_n_s__idx; +static PyObject *__pyx_n_s__iterator; +static PyObject *__pyx_n_s__itertools; +static PyObject *__pyx_n_s__join; +static PyObject *__pyx_n_s__keys; +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__ord; +static PyObject *__pyx_n_s__os; +static PyObject *__pyx_n_s__parser; +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__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__seq_col; +static PyObject *__pyx_n_s__start; +static PyObject *__pyx_n_s__start_col; +static PyObject *__pyx_n_s__struct; +static PyObject *__pyx_n_s__sys; +static PyObject *__pyx_n_s__tabix_compress; +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__types; +static PyObject *__pyx_n_s__unlink; +static PyObject *__pyx_n_s__vcf; +static PyObject *__pyx_n_s__w; +static PyObject *__pyx_n_s__zerobased; +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_neg_1; +static PyObject *__pyx_int_15; +static PyObject *__pyx_int_17; +static PyObject *__pyx_int_18; +static PyObject *__pyx_int_0x10000; +static PyObject *__pyx_k_14; +static PyObject *__pyx_k_19; +static PyObject *__pyx_k_21; + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":15 + * ''' + * + * def __cinit__(self, *args, **kwargs ): # <<<<<<<<<<<<<< + * self.tabixfile = NULL + * self._open( *args, **kwargs ) + */ + +static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_args = 0; + PyObject *__pyx_v_kwargs = 0; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__cinit__"); + if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1; + __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); + if (unlikely(!__pyx_v_kwargs)) return -1; + __Pyx_GOTREF(__pyx_v_kwargs); + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":16 + * + * def __cinit__(self, *args, **kwargs ): + * self.tabixfile = NULL # <<<<<<<<<<<<<< + * self._open( *args, **kwargs ) + * + */ + ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL; + + /* "/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 = 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 = 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 = 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; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_AddTraceback("ctabix.Tabixfile.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_args); + __Pyx_DECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":19 + * self._open( *args, **kwargs ) + * + * def _isOpen( self ): # <<<<<<<<<<<<<< + * '''return true if samfile has been opened.''' + * return self.tabixfile != NULL + */ + +static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_6ctabix_9Tabixfile__isOpen[] = "Tabixfile._isOpen(self)\nreturn true if samfile has been opened."; +static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("_isOpen"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":21 + * def _isOpen( self ): + * '''return true if samfile has been opened.''' + * return self.tabixfile != NULL # <<<<<<<<<<<<<< + * + * 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 = 21; __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.Tabixfile._isOpen"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":23 + * return self.tabixfile != NULL + * + * def _open( self, # <<<<<<<<<<<<<< + * char * filename, + * mode ='r', + */ + +static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6ctabix_9Tabixfile__open[] = "Tabixfile._open(self, char *filename, mode='r')\nopen a :term:`tabix file` for reading.\n "; +static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + char *__pyx_v_filename; + PyObject *__pyx_v_mode = 0; + PyObject *__pyx_v_filename_index; + 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; + char *__pyx_t_6; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,0}; + __Pyx_RefNannySetupContext("_open"); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[2] = {0,0}; + values[1] = ((PyObject *)__pyx_n_s__r); + 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__filename); + 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__mode); + 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), "_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 = 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 = 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 = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("ctabix.Tabixfile._open"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_filename_index = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":30 + * ''' + * + * assert mode in ( "r",), "invalid file opening mode `%s`" % mode # <<<<<<<<<<<<<< + * + * # close a previously opened file + */ + #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 = 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 = 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 = 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 = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":33 + * + * # close a previously opened file + * if self.tabixfile != NULL: self.close() # <<<<<<<<<<<<<< + * self.tabixfile = NULL + * + */ + __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 = 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 = 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; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":34 + * # close a previously opened file + * if self.tabixfile != NULL: self.close() + * self.tabixfile = NULL # <<<<<<<<<<<<<< + * + * self.filename = filename + */ + ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":36 + * self.tabixfile = NULL + * + * self.filename = filename # <<<<<<<<<<<<<< + * filename_index = filename + ".tbi" + * + */ + ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename = __pyx_v_filename; + + /* "/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 = 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 = 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; + + /* "/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 = 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 = 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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_3) { + goto __pyx_L7; + } + + /* "/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 = 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 = 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 = 43; __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/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 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 = 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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 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 = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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 = 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:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":54 + * self.tabixfile = ti_open( self.filename, filename_index ) + * + * if self.tabixfile == NULL: # <<<<<<<<<<<<<< + * raise IOError("could not open file `%s`" % filename ) + * + */ + __pyx_t_3 = (((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile == NULL); + if (__pyx_t_3) { + + /* "/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 = 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 = 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 = 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 = 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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L10; + } + __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_4); + __Pyx_AddTraceback("ctabix.Tabixfile._open"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_filename_index); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":57 + * raise IOError("could not open file `%s`" % filename ) + * + * def _parseRegion( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6ctabix_9Tabixfile__parseRegion[] = "Tabixfile._parseRegion(self, reference=None, start=None, end=None, region=None)\nparse region information.\n\n raise ValueError for for invalid regions.\n\n returns a tuple of region, tid, start and end. Region\n is a valid samtools :term:`region` or None if the region\n extends over the whole file.\n\n Note that regions are 1-based, while start,end are python coordinates.\n "; +static PyObject *__pyx_pf_6ctabix_9Tabixfile__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; + int __pyx_v_max_pos; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + PyObject *__pyx_t_8 = NULL; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0}; + __Pyx_RefNannySetupContext("_parseRegion"); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); + PyObject* values[4] = {0,0,0,0}; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58 + * + * def _parseRegion( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59 + * def _parseRegion( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None ): + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None ): + * '''parse region information. + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61 + * start = None, + * end = None, + * region = None ): # <<<<<<<<<<<<<< + * '''parse region information. + * + */ + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + 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), "_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]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58 + * + * def _parseRegion( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59 + * def _parseRegion( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None ): + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None ): + * '''parse region information. + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61 + * start = None, + * end = None, + * region = None ): # <<<<<<<<<<<<<< + * '''parse region information. + * + */ + __pyx_v_region = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_region); + + /* "/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 ) # <<<<<<<<<<<<<< + * + * cdef int rtid + */ + ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":78 + * cdef int rend + * cdef int max_pos + * max_pos = 2 << 29 # <<<<<<<<<<<<<< + * + * rtid = rstart = rend = 0 + */ + __pyx_v_max_pos = 1073741824; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":80 + * max_pos = 2 << 29 + * + * rtid = rstart = rend = 0 # <<<<<<<<<<<<<< + * + * # translate to a region + */ + __pyx_v_rtid = 0; + __pyx_v_rstart = 0; + __pyx_v_rend = 0; + + /* "/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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { + + /* "/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 = 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 = 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 = 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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_1; + } + if (__pyx_t_4) { + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_end); + 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 = 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); + __pyx_v_region = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L7; + } + + /* "/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 = 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 = 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 = 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 = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __pyx_t_1; + } else { + __pyx_t_3 = __pyx_t_4; + } + if (__pyx_t_3) { + + /* "/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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __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 = 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); + __pyx_v_region = ((PyObject *)__pyx_t_5); + __pyx_t_5 = 0; + goto __pyx_L7; + } + + /* "/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 = 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 = 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 = 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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_1 = __pyx_t_4; + } else { + __pyx_t_1 = __pyx_t_3; + } + if (__pyx_t_1) { + + /* "/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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2); + __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 = 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); + __pyx_v_region = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L7; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":91 + * region = "%s:%i-%i" % (reference, start+1, max_pos-1) + * else: + * region = reference # <<<<<<<<<<<<<< + * + * if region: + */ + __Pyx_INCREF(__pyx_v_reference); + __Pyx_DECREF(__pyx_v_region); + __pyx_v_region = __pyx_v_reference; + } + __pyx_L7:; + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { + + /* "/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 = 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)); + + /* "/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 ) # <<<<<<<<<<<<<< + * 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 ) + */ + __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 = 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 = 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 = 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 = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L9; + } + __pyx_L9:; + + /* "/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) ) # <<<<<<<<<<<<<< + * 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_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 = 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 = 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 = 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); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); + __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 = 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 = 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 = 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 = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L10; + } + __pyx_L10:; + + /* "/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 ) # <<<<<<<<<<<<<< + * if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend ) + * + */ + __pyx_t_1 = (0 <= __pyx_v_rstart); + if (__pyx_t_1) { + __pyx_t_1 = (__pyx_v_rstart < __pyx_v_max_pos); + } + __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 = 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 = 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 = 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 = 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 = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + + /* "/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 ) # <<<<<<<<<<<<<< + * + * return region, rtid, rstart, rend + */ + __pyx_t_3 = (0 <= __pyx_v_rend); + if (__pyx_t_3) { + __pyx_t_3 = (__pyx_v_rend < __pyx_v_max_pos); + } + __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 = 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 = 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 = 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 = 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 = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 # <<<<<<<<<<<<<< + * + * 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_region); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_6 = 0; + __pyx_t_5 = 0; + __pyx_t_2 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; + 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_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_region); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":102 + * return region, rtid, rstart, rend + * + * def fetch( self, # <<<<<<<<<<<<<< + * reference = None, + * start = None, + */ + +static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6ctabix_9Tabixfile_fetch[] = "Tabixfile.fetch(self, reference=None, start=None, end=None, region=None, parser=None)\n\n \n fetch one or more rows 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 be supplied.\n\n Without *reference* or *region* all entries will be fetched. \n \n If only *reference* is set, all reads matching on *reference* will be fetched.\n\n If *parser* is None, the results are returned as an unparsed string.\n Otherwise, *parser* is assumed to be a functor that will return parsed \n data (see for example :meth:`asTuple` and :meth:`asGTF`).\n "; +static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(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; + PyObject *__pyx_v_parser = 0; + PyObject *__pyx_v_rtid; + PyObject *__pyx_v_rstart; + PyObject *__pyx_v_rend; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__parser,0}; + __Pyx_RefNannySetupContext("fetch"); + 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/ctabix.pyx":103 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + values[0] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + values[1] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * parser = None ): + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * parser = None ): + * ''' + */ + values[3] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107 + * end = None, + * region = None, + * parser = None ): # <<<<<<<<<<<<<< + * ''' + * + */ + 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: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference); + if (value) { values[0] = value; kw_args--; } + } + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser); + 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 = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_reference = values[0]; + __pyx_v_start = values[1]; + __pyx_v_end = values[2]; + __pyx_v_region = values[3]; + __pyx_v_parser = values[4]; + } else { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":103 + * + * def fetch( self, + * reference = None, # <<<<<<<<<<<<<< + * start = None, + * end = None, + */ + __pyx_v_reference = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104 + * def fetch( self, + * reference = None, + * start = None, # <<<<<<<<<<<<<< + * end = None, + * region = None, + */ + __pyx_v_start = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105 + * reference = None, + * start = None, + * end = None, # <<<<<<<<<<<<<< + * region = None, + * parser = None ): + */ + __pyx_v_end = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106 + * start = None, + * end = None, + * region = None, # <<<<<<<<<<<<<< + * parser = None ): + * ''' + */ + __pyx_v_region = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107 + * end = None, + * region = None, + * parser = None ): # <<<<<<<<<<<<<< + * ''' + * + */ + __pyx_v_parser = ((PyObject *)Py_None); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: __pyx_v_parser = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + 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 = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("ctabix.Tabixfile.fetch"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_region); + __pyx_v_rtid = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_rstart = Py_None; __Pyx_INCREF(Py_None); + __pyx_v_rend = Py_None; __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":121 + * data (see for example :meth:`asTuple` and :meth:`asGTF`). + * ''' + * ti_lazy_index_load( self.tabixfile ) # <<<<<<<<<<<<<< + * + * if not self._isOpen(): + */ + ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile); + + /* "/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 = 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 = 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 = 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) { + + /* "/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 = 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 = 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 = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_reference); + __Pyx_INCREF(__pyx_v_start); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start); + __Pyx_GIVEREF(__pyx_v_start); + __Pyx_INCREF(__pyx_v_end); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end); + __Pyx_GIVEREF(__pyx_v_end); + __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 = 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; + 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_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1); + __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6); + __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_v_region); + __pyx_v_region = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_v_rtid); + __pyx_v_rtid = __pyx_t_1; + __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_rstart); + __pyx_v_rstart = __pyx_t_6; + __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_v_rend); + __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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_v_rtid); + __pyx_v_rtid = __pyx_t_1; + __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_v_rstart); + __pyx_v_rstart = __pyx_t_6; + __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_v_rend); + __pyx_v_rend = __pyx_t_7; + __pyx_t_7 = 0; + } + + /* "/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 = 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 = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_4) { + + /* "/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 = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":130 + * if parser == None: + * if region: + * return TabixIterator( self, rtid, rstart, rend ) # <<<<<<<<<<<<<< + * else: + * 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 = 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); + __Pyx_GIVEREF(__pyx_v_self); + __Pyx_INCREF(__pyx_v_rtid); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid); + __Pyx_GIVEREF(__pyx_v_rtid); + __Pyx_INCREF(__pyx_v_rstart); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart); + __Pyx_GIVEREF(__pyx_v_rstart); + __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 = 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; + __pyx_t_7 = 0; + goto __pyx_L0; + goto __pyx_L8; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":132 + * return TabixIterator( self, rtid, rstart, rend ) + * else: + * return TabixIterator( self, -1, 0, 0 ) # <<<<<<<<<<<<<< + * else: + * if region: + */ + __Pyx_XDECREF(__pyx_r); + __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); + __Pyx_GIVEREF(__pyx_v_self); + __Pyx_INCREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __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 = 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; + __pyx_t_5 = 0; + goto __pyx_L0; + } + __pyx_L8:; + goto __pyx_L7; + } + /*else*/ { + + /* "/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 = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":135 + * else: + * if region: + * return TabixIteratorParsed( self, rtid, rstart, rend, parser ) # <<<<<<<<<<<<<< + * else: + * 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 = 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); + __Pyx_GIVEREF(__pyx_v_self); + __Pyx_INCREF(__pyx_v_rtid); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid); + __Pyx_GIVEREF(__pyx_v_rtid); + __Pyx_INCREF(__pyx_v_rstart); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart); + __Pyx_GIVEREF(__pyx_v_rstart); + __Pyx_INCREF(__pyx_v_rend); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend); + __Pyx_GIVEREF(__pyx_v_rend); + __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 = 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; + __pyx_t_7 = 0; + goto __pyx_L0; + goto __pyx_L9; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":137 + * return TabixIteratorParsed( self, rtid, rstart, rend, parser ) + * else: + * return TabixIteratorParsed( self, -1, 0, 0, parser ) # <<<<<<<<<<<<<< + * + * property header: + */ + __Pyx_XDECREF(__pyx_r); + __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); + __Pyx_GIVEREF(__pyx_v_self); + __Pyx_INCREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __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 = 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; + __pyx_t_5 = 0; + goto __pyx_L0; + } + __pyx_L9:; + } + __pyx_L7:; + + __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_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("ctabix.Tabixfile.fetch"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_rtid); + __Pyx_DECREF(__pyx_v_rstart); + __Pyx_DECREF(__pyx_v_rend); + __Pyx_DECREF(__pyx_v_region); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/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 + */ + +static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_self) { + char **__pyx_v_sequences; + int __pyx_v_nsequences; + int __pyx_v_x; + PyObject *__pyx_v_result; + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__get__"); + __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile); + + /* "/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 = [] + */ + __pyx_v_sequences = ti_seqname(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile->idx, (&__pyx_v_nsequences)); + + /* "/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 = 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; + + /* "/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++) { + + /* "/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 = 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 = 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 = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + } + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":159 + * for x from 0 <= x < nsequences: + * result.append( sequences[x] ) + * return result # <<<<<<<<<<<<<< + * + * cdef class TabixIterator: + */ + __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_AddTraceback("ctabix.Tabixfile.contigs.__get__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":169 + * cdef tabix_t * tabixfile + * + * def __cinit__(self, Tabixfile tabixfile, # <<<<<<<<<<<<<< + * int tid, int start, int end ): + * + */ + +static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0; + int __pyx_v_tid; + int __pyx_v_start; + int __pyx_v_end; + int __pyx_r; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0}; + __Pyx_RefNannySetupContext("__cinit__"); + 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__tabixfile); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":172 + * int tid, int start, int end ): + * + * assert tabixfile._isOpen() # <<<<<<<<<<<<<< + * + * # 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 = 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 = 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 = 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 = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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 # <<<<<<<<<<<<<< + * + * if tid < 0: + */ + ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":178 + * self.tabixfile = tabixfile.tabixfile + * + * if tid < 0: # <<<<<<<<<<<<<< + * # seek to start of file to ensure iteration is over + * # all entries. + */ + __pyx_t_3 = (__pyx_v_tid < 0); + if (__pyx_t_3) { + + /* "/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) # <<<<<<<<<<<<<< + * self.iterator = ti_iter_first() + * else: + */ + bgzf_seek(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile->fp, 0, 0); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":182 + * # all entries. + * bgzf_seek( self.tabixfile.fp, 0, 0) + * self.iterator = ti_iter_first() # <<<<<<<<<<<<<< + * else: + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) + */ + ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator = ti_iter_first(); + goto __pyx_L6; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":184 + * self.iterator = ti_iter_first() + * else: + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) # <<<<<<<<<<<<<< + * + * if self.iterator == NULL: + */ + ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator = ti_queryi(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end); + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":186 + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) + * + * if self.iterator == NULL: # <<<<<<<<<<<<<< + * raise ValueError("malformatted query or wrong sequence name.\n") + * + */ + __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) == NULL); + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":187 + * + * if 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 = 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 = 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 = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":189 + * raise ValueError("malformatted query or wrong sequence name.\n") + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannySetupContext("__iter__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":190 + * + * def __iter__(self): + * 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/ctabix.pyx":192 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * + */ + +static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_6ctabix_13TabixIterator___next__[] = "python version of next().\n\n pyrex uses this non-standard name instead of next()\n "; +struct wrapperbase __pyx_wrapperbase_6ctabix_13TabixIterator___next__; +static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_self) { + char *__pyx_v_s; + int __pyx_v_len; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__next__"); + + /* "/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 + */ + while (1) { + if (!1) break; + + /* "/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 = 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_L6_break:; + + /* "/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 = 210; __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.TabixIterator.__next__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":212 + * return s + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) + */ + +static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self) { + int __pyx_t_1; + __Pyx_RefNannySetupContext("__dealloc__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":213 + * + * def __dealloc__(self): + * if self.iterator != NULL: # <<<<<<<<<<<<<< + * ti_iter_destroy(self.iterator) + * + */ + __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":214 + * def __dealloc__(self): + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) # <<<<<<<<<<<<<< + * + * cdef class TabixHeaderIterator: + */ + ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator); + goto __pyx_L5; + } + __pyx_L5:; + + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":223 + * cdef tabix_t * tabixfile + * + * def __cinit__(self, Tabixfile tabixfile ): # <<<<<<<<<<<<<< + * + * assert tabixfile._isOpen() + */ + +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; + 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)); + } + 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 -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;} + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":225 + * def __cinit__(self, Tabixfile tabixfile ): + * + * assert tabixfile._isOpen() # <<<<<<<<<<<<<< + * + * # 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 = 225; __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 = 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 = __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 (unlikely(!__pyx_t_3)) { + PyErr_SetNone(PyExc_AssertionError); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/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.iterator = ti_query(self.tabixfile, NULL, 0, 0) + */ + ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":231 + * self.tabixfile = tabixfile.tabixfile + * + * self.iterator = ti_query(self.tabixfile, NULL, 0, 0) # <<<<<<<<<<<<<< + * + * if self.iterator == NULL: + */ + ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator = ti_query(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, NULL, 0, 0); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":233 + * self.iterator = ti_query(self.tabixfile, NULL, 0, 0) + * + * if 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) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":234 + * + * if self.iterator == NULL: + * raise ValueError("can't open header.\n") # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + __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 = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":236 + * raise ValueError("can't open header.\n") + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +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; + __Pyx_RefNannySetupContext("__iter__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":237 + * + * def __iter__(self): + * 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/ctabix.pyx":239 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * + */ + +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; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("__next__"); + + /* "/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 = ti_read(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator, (&__pyx_v_len)); + + /* "/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_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:; + + /* "/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 + */ + __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:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":255 + * if s[0] != '#': raise StopIteration + * + * 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 = 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_2); + __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__next__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":257 + * return s + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) + */ + +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; + __Pyx_RefNannySetupContext("__dealloc__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":258 + * + * def __dealloc__(self): + * if self.iterator != NULL: # <<<<<<<<<<<<<< + * ti_iter_destroy(self.iterator) + * + */ + __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator) != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":259 + * def __dealloc__(self): + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) # <<<<<<<<<<<<<< + * + * ######################################################### + */ + ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator); + goto __pyx_L5; + } + __pyx_L5:; + + __Pyx_RefNannyFinishContext(); +} + +/* "/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() + */ + +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; + 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;} + } + } + 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_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;} + } + 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 NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":274 + * # need to copy - there were some + * # persistence issues with "present" + * r.copy( buffer, len ) # <<<<<<<<<<<<<< + * return r + * + */ + __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_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":275 + * # persistence issues with "present" + * r.copy( buffer, len ) + * return r # <<<<<<<<<<<<<< + * + * cdef class asGTF(Parser): + */ + __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_AddTraceback("ctabix.asTuple.__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/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_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; + 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 = 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), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __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 = 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_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("__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.asGTF.__call__"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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_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_DECREF(((PyObject *)__pyx_v_r)); + __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":282 + * cdef TabProxies.GTFProxy r + * r = TabProxies.GTFProxy() + * r.copy( buffer, len ) # <<<<<<<<<<<<<< + * return r + * + */ + __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; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":283 + * r = TabProxies.GTFProxy() + * r.copy( buffer, len ) + * return r # <<<<<<<<<<<<<< + * + * cdef class asBed( Parser ): + */ + __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_AddTraceback("ctabix.asGTF.__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/ctabix.pyx":287 + * 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() + */ + +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_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}; + __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 = 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 = 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 = 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 = 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 = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("ctabix.asBed.__call__"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)Py_None); __Pyx_INCREF(Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":289 + * def __call__(self, char * buffer, int len): + * cdef TabProxies.BedProxy r + * r = TabProxies.BedProxy() # <<<<<<<<<<<<<< + * r.copy( buffer, len ) + * return r + */ + __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_10TabProxies_BedProxy *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":291 + * r = TabProxies.BedProxy() + * r.copy( buffer, len ) + * return r # <<<<<<<<<<<<<< + * + * cdef class asVCF( Parser ): + */ + __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_AddTraceback("ctabix.asBed.__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/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_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_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}; + __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 = 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 = 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 = 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 = 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 = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("ctabix.asVCF.__call__"); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)Py_None); __Pyx_INCREF(Py_None); + + /* "/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_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_10TabProxies_VCFProxy *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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_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; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":299 + * r = TabProxies.VCFProxy() + * r.copy( buffer, len ) + * return r # <<<<<<<<<<<<<< + * + * ######################################################### + */ + __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_AddTraceback("ctabix.asVCF.__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/ctabix.pyx":314 + * cdef Parser parser + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * Tabixfile tabixfile, + * int tid, + */ + +static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0; + int __pyx_v_tid; + int __pyx_v_start; + int __pyx_v_end; + struct __pyx_obj_6ctabix_Parser *__pyx_v_parser = 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__tabixfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__parser,0}; + __Pyx_RefNannySetupContext("__cinit__"); + 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__tabixfile); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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;} + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":321 + * Parser parser ): + * + * assert tabixfile._isOpen() # <<<<<<<<<<<<<< + * self.parser = parser + * + */ + #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 = 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 = 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 = 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 = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #endif + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":322 + * + * assert tabixfile._isOpen() + * self.parser = parser # <<<<<<<<<<<<<< + * + * # makes sure that samfile stays alive as long as the + */ + __Pyx_INCREF(((PyObject *)__pyx_v_parser)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_parser)); + __Pyx_GOTREF(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser); + __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser)); + ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser = __pyx_v_parser; + + /* "/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 # <<<<<<<<<<<<<< + * + * if tid < 0: + */ + ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":328 + * self.tabixfile = tabixfile.tabixfile + * + * if tid < 0: # <<<<<<<<<<<<<< + * # seek to start of file to ensure iteration is over + * # all entries. + */ + __pyx_t_3 = (__pyx_v_tid < 0); + if (__pyx_t_3) { + + /* "/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) # <<<<<<<<<<<<<< + * self.iterator = ti_iter_first() + * else: + */ + bgzf_seek(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile->fp, 0, 0); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":332 + * # all entries. + * bgzf_seek( self.tabixfile.fp, 0, 0) + * self.iterator = ti_iter_first() # <<<<<<<<<<<<<< + * else: + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) + */ + ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator = ti_iter_first(); + goto __pyx_L6; + } + /*else*/ { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":334 + * self.iterator = ti_iter_first() + * else: + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) # <<<<<<<<<<<<<< + * + * if self.iterator == NULL: + */ + ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator = ti_queryi(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end); + } + __pyx_L6:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":336 + * self.iterator = ti_queryi(self.tabixfile, tid, start, end) + * + * if self.iterator == NULL: # <<<<<<<<<<<<<< + * raise ValueError("malformatted query or wrong sequence name.\n") + * + */ + __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) == NULL); + if (__pyx_t_3) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":337 + * + * if 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 = 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 = 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 = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__"); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":339 + * raise ValueError("malformatted query or wrong sequence name.\n") + * + * def __iter__(self): # <<<<<<<<<<<<<< + * return self + * + */ + +static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannySetupContext("__iter__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":340 + * + * def __iter__(self): + * 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/ctabix.pyx":342 + * return self + * + * def __next__(self): # <<<<<<<<<<<<<< + * """python version of next(). + * + */ + +static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_6ctabix_19TabixIteratorParsed___next__[] = "python version of next().\n\n pyrex uses this non-standard name instead of next()\n "; +struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__; +static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx_v_self) { + char *__pyx_v_s; + int __pyx_v_len; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("__next__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":350 + * cdef char * s + * cdef int len + * while 1: # <<<<<<<<<<<<<< + * s = ti_read(self.tabixfile, self.iterator, &len) + * if s == NULL: raise StopIteration + */ + while (1) { + if (!1) break; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":351 + * cdef int 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[0]) != '#'); + if (__pyx_t_1) { + goto __pyx_L6_break; + goto __pyx_L8; + } + __pyx_L8:; + } + __pyx_L6_break:; + + /* "/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 = 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 = 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 = 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)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __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 = 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; + __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_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__next__"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":358 + * return self.parser(s, len) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) + */ + +static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v_self) { + int __pyx_t_1; + __Pyx_RefNannySetupContext("__dealloc__"); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":359 + * + * def __dealloc__(self): + * if self.iterator != NULL: # <<<<<<<<<<<<<< + * ti_iter_destroy(self.iterator) + * + */ + __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) != NULL); + if (__pyx_t_1) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":360 + * def __dealloc__(self): + * if self.iterator != NULL: + * ti_iter_destroy(self.iterator) # <<<<<<<<<<<<<< + * + * def tabix_compress( filename_in, + */ + ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator); + goto __pyx_L5; + } + __pyx_L5:; + + __Pyx_RefNannyFinishContext(); +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":362 + * ti_iter_destroy(self.iterator) + * + * def tabix_compress( filename_in, # <<<<<<<<<<<<<< + * filename_out, + * force = False ): + */ + +static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6ctabix_tabix_compress[] = "tabix_compress(filename_in, filename_out, force=False)\n\n compress *filename_in* writing the output to *filename_out*.\n \n Raise an IOError if *filename_out* already exists, unless *force* is set.\n "; +static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_filename_in = 0; + PyObject *__pyx_v_filename_out = 0; + PyObject *__pyx_v_force = 0; + int __pyx_v_WINDOW_SIZE; + int __pyx_v_c; + int __pyx_v_r; + void *__pyx_v_buffer; + BGZF *__pyx_v_fp; + int __pyx_v_fd_src; + int __pyx_v_O_RDONLY; + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + char *__pyx_t_8; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename_in,&__pyx_n_s__filename_out,&__pyx_n_s__force,0}; + __Pyx_RefNannySetupContext("tabix_compress"); + __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_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); + 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__filename_in); + if (likely(values[0])) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + 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 = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__force); + 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), "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_14; + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: + __pyx_v_force = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: + __pyx_v_filename_out = PyTuple_GET_ITEM(__pyx_args, 1); + __pyx_v_filename_in = 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("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:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = __pyx_t_1; + } else { + __pyx_t_6 = __pyx_t_2; + } + if (__pyx_t_6) { + + /* "/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_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 = 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 = 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 = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_O_RDONLY = __pyx_t_7; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":384 + * O_RDONLY = os.O_RDONLY + * + * WINDOW_SIZE = 64 * 1024 # <<<<<<<<<<<<<< + * + * fp = bgzf_open( filename_out, "w") + */ + __pyx_v_WINDOW_SIZE = 65536; + + /* "/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 = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_fp = bgzf_open(__pyx_t_8, __pyx_k__w); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":387 + * + * fp = bgzf_open( filename_out, "w") + * if fp == NULL: # <<<<<<<<<<<<<< + * raise IOError( "could not open '%s' for writing" ) + * + */ + __pyx_t_6 = (__pyx_v_fp == NULL); + if (__pyx_t_6) { + + /* "/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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/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 = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_fd_src = open(__pyx_t_8, __pyx_v_O_RDONLY); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":391 + * + * fd_src = open(filename_in, O_RDONLY) + * if fd_src == 0: # <<<<<<<<<<<<<< + * raise IOError( "could not open '%s' for reading" ) + * + */ + __pyx_t_6 = (__pyx_v_fd_src == 0); + if (__pyx_t_6) { + + /* "/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 = 392; __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_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 = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":394 + * raise IOError( "could not open '%s' for reading" ) + * + * buffer = malloc(WINDOW_SIZE) # <<<<<<<<<<<<<< + * + * while c > 0: + */ + __pyx_v_buffer = malloc(__pyx_v_WINDOW_SIZE); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":396 + * buffer = malloc(WINDOW_SIZE) + * + * while c > 0: # <<<<<<<<<<<<<< + * c = read(fd_src, buffer, WINDOW_SIZE) + * r = bgzf_write(fp, buffer, c) + */ + while (1) { + __pyx_t_6 = (__pyx_v_c > 0); + if (!__pyx_t_6) break; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":397 + * + * while c > 0: + * c = read(fd_src, buffer, WINDOW_SIZE) # <<<<<<<<<<<<<< + * r = bgzf_write(fp, buffer, c) + * if r < 0: + */ + __pyx_v_c = read(__pyx_v_fd_src, __pyx_v_buffer, __pyx_v_WINDOW_SIZE); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":398 + * while c > 0: + * c = read(fd_src, buffer, WINDOW_SIZE) + * r = bgzf_write(fp, buffer, c) # <<<<<<<<<<<<<< + * if r < 0: + * free( buffer ) + */ + __pyx_v_r = bgzf_write(__pyx_v_fp, __pyx_v_buffer, __pyx_v_c); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":399 + * c = read(fd_src, buffer, WINDOW_SIZE) + * r = bgzf_write(fp, buffer, c) + * if r < 0: # <<<<<<<<<<<<<< + * free( buffer ) + * raise OSError("writing failed") + */ + __pyx_t_6 = (__pyx_v_r < 0); + if (__pyx_t_6) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":400 + * r = bgzf_write(fp, buffer, c) + * if r < 0: + * free( buffer ) # <<<<<<<<<<<<<< + * raise OSError("writing failed") + * + */ + free(__pyx_v_buffer); + + /* "/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 = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __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 = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; + } + __pyx_L11:; + } + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":403 + * raise OSError("writing failed") + * + * free( buffer ) # <<<<<<<<<<<<<< + * r = bgzf_close(fp) + * if r < 0: raise OSError("writing failed") + */ + free(__pyx_v_buffer); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":404 + * + * free( buffer ) + * r = bgzf_close(fp) # <<<<<<<<<<<<<< + * if r < 0: raise OSError("writing failed") + * + */ + __pyx_v_r = bgzf_close(__pyx_v_fp); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":405 + * free( buffer ) + * r = bgzf_close(fp) + * if r < 0: raise OSError("writing failed") # <<<<<<<<<<<<<< + * + * def tabix_index( filename, + */ + __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 = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __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 = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L12; + } + __pyx_L12:; + + __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_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("ctabix.tabix_compress"); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":407 + * if r < 0: raise OSError("writing failed") + * + * def tabix_index( filename, # <<<<<<<<<<<<<< + * force = False, + * seq_col = None, + */ + +static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6ctabix_tabix_index[] = "tabix_index(filename, force=False, seq_col=None, start_col=None, end_col=None, preset=None, meta_char='#', zerobased=False)\n\n index tab-separated *filename* using tabix.\n\n An existing index will not be overwritten unless\n *force* is set.\n\n The index will be built from coordinates\n in columns *seq_col*, *start_col* and *end_col*.\n\n The contents of *filename* have to be sorted by \n contig and position - the method does not check\n if the file is sorted.\n\n Column indices are 0-based. Coordinates in the file\n are assumed to be 1-based.\n\n If *preset* is provided, the column coordinates\n are taken from a preset. Valid values for preset\n are \"gff\", \"bed\", \"sam\", \"vcf\", psltbl\", \"pileup\".\n \n Lines beginning with *meta_char* and the first\n *line_skip* lines will be skipped.\n \n If *filename* does not end in \".gz\", it will be automatically\n compressed. The original file will be removed and only the \n compressed file will be retained. \n\n If *filename* ends in *gz*, the file is assumed to be already\n compressed with bgzf.\n\n returns the filename of the compressed data\n "; +static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_filename = 0; + PyObject *__pyx_v_force = 0; + PyObject *__pyx_v_seq_col = 0; + PyObject *__pyx_v_start_col = 0; + PyObject *__pyx_v_end_col = 0; + PyObject *__pyx_v_preset = 0; + PyObject *__pyx_v_meta_char = 0; + PyObject *__pyx_v_zerobased = 0; + PyObject *__pyx_v_preset2conf; + PyObject *__pyx_v_conf_data; + ti_conf_t __pyx_v_conf; + 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; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int32_t __pyx_t_11; + int32_t __pyx_t_12; + int32_t __pyx_t_13; + int32_t __pyx_t_14; + int32_t __pyx_t_15; + int32_t __pyx_t_16; + PyObject *__pyx_t_17 = NULL; + char *__pyx_t_18; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__force,&__pyx_n_s__seq_col,&__pyx_n_s__start_col,&__pyx_n_s__end_col,&__pyx_n_s__preset,&__pyx_n_s__meta_char,&__pyx_n_s__zerobased,0}; + __Pyx_RefNannySetupContext("tabix_index"); + __pyx_self = __pyx_self; + 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_19; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409 + * def tabix_index( filename, + * force = False, + * seq_col = None, # <<<<<<<<<<<<<< + * start_col = None, + * end_col = None, + */ + values[2] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410 + * force = False, + * seq_col = None, + * start_col = None, # <<<<<<<<<<<<<< + * end_col = None, + * preset = None, + */ + values[3] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411 + * seq_col = None, + * start_col = None, + * end_col = None, # <<<<<<<<<<<<<< + * preset = None, + * meta_char = "#", + */ + values[4] = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412 + * start_col = None, + * end_col = None, + * preset = None, # <<<<<<<<<<<<<< + * meta_char = "#", + * zerobased = False, + */ + values[5] = ((PyObject *)Py_None); + 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); + 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__filename); + 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__force); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq_col); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start_col); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end_col); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__preset); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__meta_char); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__zerobased); + if (value) { values[7] = value; kw_args--; } + } + } + 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 = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + __pyx_v_filename = values[0]; + __pyx_v_force = values[1]; + __pyx_v_seq_col = values[2]; + __pyx_v_start_col = values[3]; + __pyx_v_end_col = values[4]; + __pyx_v_preset = values[5]; + __pyx_v_meta_char = values[6]; + __pyx_v_zerobased = values[7]; + } else { + __pyx_v_force = __pyx_k_19; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409 + * def tabix_index( filename, + * force = False, + * seq_col = None, # <<<<<<<<<<<<<< + * start_col = None, + * end_col = None, + */ + __pyx_v_seq_col = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410 + * force = False, + * seq_col = None, + * start_col = None, # <<<<<<<<<<<<<< + * end_col = None, + * preset = None, + */ + __pyx_v_start_col = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411 + * seq_col = None, + * start_col = None, + * end_col = None, # <<<<<<<<<<<<<< + * preset = None, + * meta_char = "#", + */ + __pyx_v_end_col = ((PyObject *)Py_None); + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412 + * start_col = None, + * end_col = None, + * preset = None, # <<<<<<<<<<<<<< + * meta_char = "#", + * zerobased = False, + */ + __pyx_v_preset = ((PyObject *)Py_None); + __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); + case 6: __pyx_v_preset = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: __pyx_v_end_col = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: __pyx_v_start_col = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: __pyx_v_seq_col = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: __pyx_v_force = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: __pyx_v_filename = 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("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(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __Pyx_INCREF(__pyx_v_filename); + __Pyx_INCREF(__pyx_v_end_col); + __Pyx_INCREF(__pyx_v_preset); + __pyx_v_preset2conf = ((PyObject *)Py_None); __Pyx_INCREF(Py_None); + __pyx_v_conf_data = Py_None; __Pyx_INCREF(Py_None); + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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_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 = 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 = 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 = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/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 = 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 = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __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 = 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) { + + /* "/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 = 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_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 = 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); + __Pyx_GIVEREF(__pyx_v_filename); + 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 = 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 = 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; + + /* "/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 = 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 = 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 = 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 = 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; + + /* "/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_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; + __pyx_t_3 = 0; + goto __pyx_L7; + } + __pyx_L7:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_7 = __pyx_t_4; + } else { + __pyx_t_7 = __pyx_t_5; + } + if (__pyx_t_7) { + + /* "/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 = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; + } + __pyx_L8:; + + /* "/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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + + /* "/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 = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + __Pyx_INCREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_0x10000); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_0x10000); + __Pyx_INCREF(__pyx_int_15); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_15); + __Pyx_GIVEREF(__pyx_int_15); + __Pyx_INCREF(__pyx_int_17); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_17); + __Pyx_GIVEREF(__pyx_int_17); + __Pyx_INCREF(__pyx_int_18); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_18); + __Pyx_GIVEREF(__pyx_int_18); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "/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 = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __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 = 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); + __Pyx_GIVEREF(__pyx_int_3); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + 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 = 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; + + /* "/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 = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_7) { + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":473 + * + * if preset: + * try: # <<<<<<<<<<<<<< + * conf_data = preset2conf[preset] + * except KeyError: + */ + { + 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/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 = 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; + __pyx_t_2 = 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_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":475 + * try: + * conf_data = preset2conf[preset] + * except KeyError: # <<<<<<<<<<<<<< + * raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() ))) + * else: + */ + __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 = 475; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_3); + + /* "/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_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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_preset); + 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_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 = 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 = 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 = 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; + 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_L9; + } + /*else*/ { + + /* "/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 = 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 = 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); + __Pyx_DECREF(__pyx_v_end_col); + __pyx_v_end_col = __pyx_int_neg_1; + goto __pyx_L20; + } + __pyx_L20:; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":479 + * else: + * if end_col == None: end_col = -1 + * preset = 0 # <<<<<<<<<<<<<< + * + * # note that tabix internally works with 0-based coordinates and open/closed intervals. + */ + __Pyx_INCREF(__pyx_int_0); + __Pyx_DECREF(__pyx_v_preset); + __pyx_v_preset = __pyx_int_0; + + /* "/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 = 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 = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_v_preset); + __pyx_v_preset = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L21; + } + __pyx_L21:; + + /* "/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 = 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 = 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 = 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 = 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 = 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 = 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); + __Pyx_GIVEREF(__pyx_v_preset); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_3 = 0; + __pyx_t_6 = 0; + __pyx_t_2 = 0; + __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_v_conf_data); + __pyx_v_conf_data = __pyx_t_9; + __pyx_t_9 = 0; + } + __pyx_L9:; + + /* "/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 # <<<<<<<<<<<<<< + * + * ti_index_build( filename, &conf) + */ + 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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_conf.bc = __pyx_t_13; + __pyx_v_conf.ec = __pyx_t_14; + __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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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; + __pyx_v_conf.bc = __pyx_t_14; + __pyx_v_conf.ec = __pyx_t_13; + __pyx_v_conf.meta_char = __pyx_t_12; + __pyx_v_conf.line_skip = __pyx_t_11; + } + + /* "/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 = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + ti_index_build(__pyx_t_18, (&__pyx_v_conf)); + + /* "/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*/ +}; + +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 +}; + +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; + return o; +} + +static void __pyx_tp_dealloc_6ctabix_Parser(PyObject *o) { + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_6ctabix_Parser[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_Parser = { + 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_Parser = { + 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_Parser = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_Parser = { + #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_6ctabix_Parser = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("ctabix.Parser"), /*tp_name*/ + sizeof(struct __pyx_obj_6ctabix_Parser), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6ctabix_Parser, /*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_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_Parser, /*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_6ctabix_Parser, /*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_6ctabix_Parser, /*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_TabixIterator(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + if (__pyx_pf_6ctabix_13TabixIterator___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_6ctabix_TabixIterator(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_6ctabix_13TabixIterator___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_6ctabix_TabixIterator[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_13TabixIterator___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_13TabixIterator___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_TabixIterator = { + 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_TabixIterator = { + 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_TabixIterator = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_TabixIterator = { + #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_6ctabix_TabixIterator = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("ctabix.TabixIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_6ctabix_TabixIterator), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6ctabix_TabixIterator, /*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_TabixIterator, /*tp_as_number*/ + &__pyx_tp_as_sequence_TabixIterator, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_TabixIterator, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_TabixIterator, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __Pyx_DOCSTR("iterates over rows in *tabixfile* in region\n given by *tid*, *start* and *end*.\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pf_6ctabix_13TabixIterator___iter__, /*tp_iter*/ + __pyx_pf_6ctabix_13TabixIterator___next__, /*tp_iternext*/ + __pyx_methods_6ctabix_TabixIterator, /*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_6ctabix_TabixIterator, /*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_TabixHeaderIterator(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + if (__pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return 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_19TabixHeaderIterator___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} + +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_TabixHeaderIterator = { + 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_TabixHeaderIterator = { + 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_TabixHeaderIterator = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_TabixHeaderIterator = { + #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_6ctabix_TabixHeaderIterator = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("ctabix.TabixHeaderIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_6ctabix_TabixHeaderIterator), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6ctabix_TabixHeaderIterator, /*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_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_TabixHeaderIterator, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + __Pyx_DOCSTR("return header lines.\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __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*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6ctabix_TabixHeaderIterator, /*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_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_asTuple[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_asTuple = { + 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_asTuple = { + 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_asTuple = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_asTuple = { + #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_6ctabix_asTuple = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("ctabix.asTuple"), /*tp_name*/ + sizeof(struct __pyx_obj_6ctabix_asTuple), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6ctabix_Parser, /*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_asTuple, /*tp_as_number*/ + &__pyx_tp_as_sequence_asTuple, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_asTuple, /*tp_as_mapping*/ + 0, /*tp_hash*/ + __pyx_pf_6ctabix_7asTuple___call__, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__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("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_asTuple, /*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_6ctabix_asTuple, /*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_asGTF(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[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_asGTF = { + 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_asGTF = { + 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_asGTF = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_asGTF = { + #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_6ctabix_asGTF = { + PyVarObject_HEAD_INIT(0, 0) + __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*/ + 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_asGTF, /*tp_as_number*/ + &__pyx_tp_as_sequence_asGTF, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_asGTF, /*tp_as_mapping*/ + 0, /*tp_hash*/ + __pyx_pf_6ctabix_5asGTF___call__, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_asGTF, /*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*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6ctabix_asGTF, /*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_6ctabix_asGTF, /*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_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_asBed[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_asBed = { + 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_asBed = { + 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_asBed = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_asBed = { + #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_6ctabix_asBed = { + PyVarObject_HEAD_INIT(0, 0) + __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*/ + 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_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_5asBed___call__, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__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 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_asBed, /*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_6ctabix_asBed, /*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_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_asVCF[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_asVCF = { + 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_asVCF = { + 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_asVCF = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_asVCF = { + #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_6ctabix_asVCF = { + PyVarObject_HEAD_INIT(0, 0) + __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*/ + 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_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_5asVCF___call__, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__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 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_asVCF, /*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_6ctabix_asVCF, /*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_TabixIteratorParsed(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6ctabix_TabixIteratorParsed *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)o); + p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None); + if (__pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_6ctabix_TabixIteratorParsed(PyObject *o) { + struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->parser)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_6ctabix_TabixIteratorParsed(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o; + if (p->parser) { + e = (*v)(((PyObject*)p->parser), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6ctabix_TabixIteratorParsed(PyObject *o) { + struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o; + PyObject* tmp; + tmp = ((PyObject*)p->parser); + p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_6ctabix_TabixIteratorParsed[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_19TabixIteratorParsed___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixIteratorParsed___next__)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_TabixIteratorParsed = { + 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_TabixIteratorParsed = { + 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_TabixIteratorParsed = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_TabixIteratorParsed = { + #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_6ctabix_TabixIteratorParsed = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("ctabix.TabixIteratorParsed"), /*tp_name*/ + sizeof(struct __pyx_obj_6ctabix_TabixIteratorParsed), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6ctabix_TabixIteratorParsed, /*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_TabixIteratorParsed, /*tp_as_number*/ + &__pyx_tp_as_sequence_TabixIteratorParsed, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_TabixIteratorParsed, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 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\n Returns parsed data.\n "), /*tp_doc*/ + __pyx_tp_traverse_6ctabix_TabixIteratorParsed, /*tp_traverse*/ + __pyx_tp_clear_6ctabix_TabixIteratorParsed, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pf_6ctabix_19TabixIteratorParsed___iter__, /*tp_iter*/ + __pyx_pf_6ctabix_19TabixIteratorParsed___next__, /*tp_iternext*/ + __pyx_methods_6ctabix_TabixIteratorParsed, /*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_6ctabix_TabixIteratorParsed, /*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("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} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + __Pyx_NAMESTR("ctabix"), + 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_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_s_20, __pyx_k_20, sizeof(__pyx_k_20), 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_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_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 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__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 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__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__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____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__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__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__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__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__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 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__gff, __pyx_k__gff, sizeof(__pyx_k__gff), 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__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}, + {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1}, + {&__pyx_n_s__len, __pyx_k__len, sizeof(__pyx_k__len), 0, 0, 1, 1}, + {&__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__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}, + {&__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__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__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__seq_col, __pyx_k__seq_col, sizeof(__pyx_k__seq_col), 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__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}, + {&__pyx_n_s__tabix_index, __pyx_k__tabix_index, sizeof(__pyx_k__tabix_index), 0, 0, 1, 1}, + {&__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__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__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 = 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; +} + +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_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_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_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_0x10000 = PyInt_FromLong(0x10000); if (unlikely(!__pyx_int_0x10000)) {__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 initctabix(void); /*proto*/ +PyMODINIT_FUNC initctabix(void) +#else +PyMODINIT_FUNC PyInit_ctabix(void); /*proto*/ +PyMODINIT_FUNC PyInit_ctabix(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_ctabix(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("ctabix"), __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_ctabix) { + 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 ---*/ + 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_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 = 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 = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6ctabix_TabixIterator = &__pyx_type_6ctabix_TabixIterator; + 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_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_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_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 = 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 = 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; + __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 = 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 = 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 ---*/ + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":4 + * # adds doc-strings for sphinx + * + * 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); + 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;} + __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;} + __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;} + __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;} + __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;} + __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;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 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__itertools, __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__struct), 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__struct, __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__ctypes), 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__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; + + /* "/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 = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_k_14 = __pyx_t_1; + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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 = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_k_19 = __pyx_t_1; + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "/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 = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_k_21 = __pyx_t_1; + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":497 + * return filename + * + * __all__ = ["tabix_index", # <<<<<<<<<<<<<< + * "tabix_compress", + * "Tabixfile", + */ + __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)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_index)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_compress)); + PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__tabix_compress)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_compress)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__Tabixfile)); + PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__Tabixfile)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Tabixfile)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__asTuple)); + PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__asTuple)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asTuple)); + __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)); + __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; + + /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":1 + * # cython: embedsignature=True # <<<<<<<<<<<<<< + * # adds doc-strings for sphinx + * + */ + __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__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___isOpen); 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__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___open); 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__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___parseRegion); 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__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__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_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__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__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 = 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; + __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__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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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; + __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_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__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_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 (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 ctabix"); + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init ctabix"); + } + __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 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 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 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 int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +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; + 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 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 , */ + 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 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; + if (sizeof(int32_t) == sizeof(char)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedChar(x); + else + return (int32_t)__Pyx_PyInt_AsSignedChar(x); + } else if (sizeof(int32_t) == sizeof(short)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedShort(x); + else + return (int32_t)__Pyx_PyInt_AsSignedShort(x); + } else if (sizeof(int32_t) == sizeof(int)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedInt(x); + else + return (int32_t)__Pyx_PyInt_AsSignedInt(x); + } else if (sizeof(int32_t) == sizeof(long)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedLong(x); + else + return (int32_t)__Pyx_PyInt_AsSignedLong(x); + } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) { + if (is_unsigned) + return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x); + else + return (int32_t)__Pyx_PyInt_AsSignedLongLong(x); + } else { + int32_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 (int32_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; + } +} + +#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; +} + +#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/ctabix.pxd b/pysam/ctabix.pxd index ef735b6..950e28e 100644 --- a/pysam/ctabix.pxd +++ b/pysam/ctabix.pxd @@ -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 diff --git a/pysam/ctabix.pyx b/pysam/ctabix.pyx index 8715e5d..25c1a1e 100644 --- a/pysam/ctabix.pyx +++ b/pysam/ctabix.pyx @@ -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 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 = malloc( s ) - memcpy( 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 = calloc( max_fields, sizeof(char *) ) - - pos = buffer - self.fields[0] = pos - field += 1 - old_pos = pos + assert tabixfile._isOpen() - while 1: - - pos = 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 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 = malloc( s ) - memcpy( 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 = 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 = 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 = 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 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 index 0000000..82eae7d --- /dev/null +++ b/pysam/cvcf.c @@ -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 /* 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 +#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[] = ""; +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'] = '' + */ + __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'] = '' + * 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'] = '' # <<<<<<<<<<<<<< + * 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'] = '' + * 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 and D + */ + __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 and D + * 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 and D # <<<<<<<<<<<<<< + * 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 and D + * 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 and D + * 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 and D + */ + __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 and D + * 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 and D # <<<<<<<<<<<<<< + * 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 and D + * 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 and D + * 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 , */ + 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 index 0000000..477e0fa --- /dev/null +++ b/pysam/cvcf.pxd @@ -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 index 0000000..d3f92d3 --- /dev/null +++ b/pysam/cvcf.pyx @@ -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'] = '' + 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 and D + 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 and D + 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", ] + + diff --git a/pysam/pysam_util.c b/pysam/pysam_util.c index 91b6fa7..c9d4543 100644 --- a/pysam/pysam_util.c +++ b/pysam/pysam_util.c @@ -6,6 +6,21 @@ #include "bam_endian.h" #include "knetfile.h" #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; + +FILE * pysam_set_stderr( FILE * f ) +{ + pysamerr = f; + return f; +} // ####################################################### // utility routines to avoid using callbacks in bam_fetch @@ -32,6 +47,7 @@ typedef struct { KSORT_INIT(my_off, pair64_t, pair64_lt); KHASH_MAP_INIT_INT(my_i, bam_binlist_t); +KHASH_MAP_INIT_STR(s, int) struct __bam_index_t { @@ -164,6 +180,60 @@ int pysam_pileup_next(const bam1_t *b, return 1; } +typedef struct __bmc_aux_t { + int max; + uint32_t *info; + uint16_t *info16; + errmod_t *em; +} bmc_aux_t; + +uint32_t pysam_glf_depth( glf1_t * g ) +{ + return g->depth; +} + + +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, + g->max_mapQ, + g->min_lk, + g->depth ); + + for (x = 0; x < 10; ++x) + fprintf(stderr, ", lk%x=%i, ", x, g->lk[x]); + + fprintf(stderr, + "maqcns: het_rate=%f, theta=%f, n_hap=%i, cap_mapQ=%i, errmod=%i, min_baseQ=%i, eta=%f, q_r=%f, aux_max=%i", + c->het_rate, + c->theta, + c->n_hap, + c->cap_mapQ, + c->errmod, + c->min_baseQ, + c->eta, + c->q_r, + c->aux->max); + + for (x = 0; x < c->aux->max; ++x) + { + fprintf(stderr, ", info-%i=%i ", x, c->aux->info[x]); + if (c->aux->info[x] == 0) break; + } + + for (x = 0; x < c->aux->max; ++x) + { + fprintf(stderr, ", info16-%i=%i ", x, c->aux->info16[x]); + if (c->aux->info16[x] == 0) break; + } +} + + + + // pysam dispatch function to emulate the samtools // command line within python. // taken from the main function in bamtk.c @@ -183,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); @@ -191,8 +261,6 @@ int pysam_dispatch(int argc, char *argv[] ) knet_win32_init(); #endif #endif - - extern int optind; // reset getop optind = 1; @@ -204,7 +272,7 @@ int pysam_dispatch(int argc, char *argv[] ) else if (strcmp(argv[1], "pileup") == 0) return bam_pileup(argc-1, argv+1); else if (strcmp(argv[1], "merge") == 0) return bam_merge(argc-1, argv+1); else if (strcmp(argv[1], "sort") == 0) return bam_sort(argc-1, argv+1); - else if (strcmp(argv[1], "index") == 0) return bam_index(argc-1, argv+1); + else if (strcmp(argv[1], "index") == 0) return bam_index(argc-1, argv+1); else if (strcmp(argv[1], "faidx") == 0) return faidx_main(argc-1, argv+1); else if (strcmp(argv[1], "fixmate") == 0) return bam_mating(argc-1, argv+1); else if (strcmp(argv[1], "rmdup") == 0) return bam_rmdup(argc-1, argv+1); @@ -246,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); @@ -286,5 +356,31 @@ unsigned char pysam_translate_sequence( const unsigned char s ) } +void bam_init_header_hash(bam_header_t *header); + +// translate a reference string *s* to a tid +// code taken from bam_parse_region +int pysam_reference2tid( bam_header_t *header, const char * s ) +{ + + khiter_t iter; + khash_t(s) *h; + + bam_init_header_hash(header); + h = (khash_t(s)*)header->hash; + + iter = kh_get(s, h, s); /* get the ref_id */ + if (iter == kh_end(h)) { // name not found + return -1; + } + + return kh_value(h, iter); +} + + + + + + diff --git a/pysam/pysam_util.h b/pysam/pysam_util.h index bfbd6dd..89e381b 100644 --- a/pysam/pysam_util.h +++ b/pysam/pysam_util.h @@ -1,6 +1,10 @@ #ifndef PYSAM_UTIL_H #define PYSAM_UTIL_H +////////////////////////////////////////////////////////////////// +// set pysam standard error to point to stream +FILE * pysam_set_stderr( FILE * f ); + ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// @@ -38,5 +42,18 @@ bam1_t * pysam_bam_update( bam1_t * b, // translate a nucleotide character to binary code unsigned char pysam_translate_sequence( const unsigned char s ); +// defined in bam_import.c +extern unsigned char bam_nt16_table[256]; + +// translate a reference string *s* to a tid +int pysam_reference2tid( bam_header_t *header, const char * s ); + +// debugging functions +#include "glf.h" +uint32_t pysam_glf_depth( glf1_t * g); + +#include "bam_maqcns.h" +void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c ); + #endif diff --git a/pysam/tabix_util.c b/pysam/tabix_util.c new file mode 100644 index 0000000..b06a614 --- /dev/null +++ b/pysam/tabix_util.c @@ -0,0 +1,4 @@ +// Definition of pysamerr +#include "stdio.h" +FILE * pysamerr = NULL; + diff --git a/pysam/version.py b/pysam/version.py index 3b6c92a..34937f4 100644 --- a/pysam/version.py +++ b/pysam/version.py @@ -1,7 +1,7 @@ # pysam versioning information -__version__ = "0.3.1" +__version__ = "0.5" -__samtools_version__ = "0.1.8" +__samtools_version__ = "0.1.16" -__tabix_version__ = "0.2.1" +__tabix_version__ = "0.2.5" diff --git a/samtools/bam.c b/samtools/bam.c.pysam.c similarity index 82% rename from samtools/bam.c rename to samtools/bam.c.pysam.c index 94b0aa8..28cdbd7 100644 --- a/samtools/bam.c +++ b/samtools/bam.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -7,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"; /************************** @@ -79,11 +81,11 @@ 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(stderr, "[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) { - fprintf(stderr, "[bam_header_read] invalid BAM binary header (this is not a BAM file).\n"); + fprintf(pysamerr, "[bam_header_read] invalid BAM binary header (this is not a BAM file).\n"); return 0; } header = bam_header_init(); @@ -160,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); + } } } @@ -245,7 +260,11 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of) kputc('\t', &str); } if (c->tid < 0) kputsn("*\t", 2, &str); - else { kputs(header->target_name[c->tid], &str); kputc('\t', &str); } + else { + if (header) kputs(header->target_name[c->tid] , &str); + else kputw(c->tid, &str); + kputc('\t', &str); + } kputw(c->pos + 1, &str); kputc('\t', &str); kputw(c->qual, &str); kputc('\t', &str); if (c->n_cigar == 0) kputc('*', &str); else { @@ -257,7 +276,11 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of) kputc('\t', &str); if (c->mtid < 0) kputsn("*\t", 2, &str); else if (c->mtid == c->tid) kputsn("=\t", 2, &str); - else { kputs(header->target_name[c->mtid], &str); kputc('\t', &str); } + else { + if (header) kputs(header->target_name[c->mtid], &str); + else kputw(c->mtid, &str); + kputc('\t', &str); + } kputw(c->mpos + 1, &str); kputc('\t', &str); kputw(c->isize, &str); kputc('\t', &str); if (c->l_qseq) { for (i = 0; i < c->l_qseq; ++i) kputc(bam_nt16_rev_table[bam1_seqi(s, i)], &str); @@ -281,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; } @@ -297,6 +337,22 @@ void bam_view1(const bam_header_t *header, const bam1_t *b) free(s); } +int bam_validate1(const bam_header_t *header, const bam1_t *b) +{ + char *s; + + if (b->core.tid < -1 || b->core.mtid < -1) return 0; + if (header && (b->core.tid >= header->n_targets || b->core.mtid >= header->n_targets)) return 0; + + if (b->data_len < b->core.l_qname) return 0; + s = memchr(bam1_qname(b), '\0', b->core.l_qname); + if (s != &bam1_qname(b)[b->core.l_qname-1]) return 0; + + // FIXME: Other fields could also be checked, especially the auxiliary data + + return 1; +} + // FIXME: we should also check the LB tag associated with each alignment const char *bam_get_library(bam_header_t *h, const bam1_t *b) { diff --git a/samtools/bam.h b/samtools/bam.h index 8e26ea6..e7360bb 100644 --- a/samtools/bam.h +++ b/samtools/bam.h @@ -1,6 +1,6 @@ /* The MIT License - Copyright (c) 2008 Genome Research Ltd (GRL). + Copyright (c) 2008-2010 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 @@ -33,13 +33,15 @@ 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 #include #include @@ -230,7 +232,7 @@ typedef struct __bam_iter_t *bam_iter_t; @param b pointer to an alignment @return pointer to quality string */ -#define bam1_qual(b) ((b)->data + (b)->core.n_cigar*4 + (b)->core.l_qname + ((b)->core.l_qseq + 1)/2) +#define bam1_qual(b) ((b)->data + (b)->core.n_cigar*4 + (b)->core.l_qname + (((b)->core.l_qseq + 1)>>1)) /*! @function @abstract Get a base on read @@ -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]; @@ -455,6 +463,21 @@ extern "C" { char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of); + /*! + @abstract Check whether a BAM record is plausibly valid + @param header associated header structure, or NULL if unavailable + @param b alignment to validate + @return 0 if the alignment is invalid; non-zero otherwise + + @discussion Simple consistency check of some of the fields of the + alignment record. If the header is provided, several additional checks + are made. Not all fields are checked, so a non-zero result is not a + guarantee that the record is valid. However it is usually good enough + to detect when bam_seek() has been called with a virtual file offset + that is not the offset of an alignment record. + */ + int bam_validate1(const bam_header_t *header, const bam1_t *b); + const char *bam_get_library(bam_header_t *header, const bam1_t *b); @@ -480,7 +503,7 @@ extern "C" { bam1_t *b; int32_t qpos; int indel, level; - uint32_t is_del:1, is_head:1, is_tail:1; + uint32_t is_del:1, is_head:1, is_tail:1, is_refskip:1, aux:28; } bam_pileup1_t; typedef int (*bam_plp_auto_f)(void *data, bam1_t *b); @@ -493,6 +516,7 @@ extern "C" { const bam_pileup1_t *bam_plp_next(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp); const bam_pileup1_t *bam_plp_auto(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp); void bam_plp_set_mask(bam_plp_t iter, int mask); + void bam_plp_set_maxcnt(bam_plp_t iter, int maxcnt); void bam_plp_reset(bam_plp_t iter); void bam_plp_destroy(bam_plp_t iter); @@ -501,6 +525,7 @@ extern "C" { bam_mplp_t bam_mplp_init(int n, bam_plp_auto_f func, void **data); void bam_mplp_destroy(bam_mplp_t iter); + void bam_mplp_set_maxcnt(bam_mplp_t iter, int maxcnt); int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_pileup1_t **plp); /*! @typedef @@ -693,8 +718,8 @@ static inline bam1_t *bam_copy1(bam1_t *bdst, const bam1_t *bsrc) { uint8_t *data = bdst->data; int m_data = bdst->m_data; // backup data and m_data - if (m_data < bsrc->m_data) { // double the capacity - m_data = bsrc->m_data; kroundup32(m_data); + if (m_data < bsrc->data_len) { // double the capacity + m_data = bsrc->data_len; kroundup32(m_data); data = (uint8_t*)realloc(data, m_data); } memcpy(data, bsrc->data, bsrc->data_len); // copy var-len data @@ -721,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 diff --git a/samtools/bam2bcf.c.pysam.c b/samtools/bam2bcf.c.pysam.c new file mode 100644 index 0000000..06f8599 --- /dev/null +++ b/samtools/bam2bcf.c.pysam.c @@ -0,0 +1,262 @@ +#include "pysam.h" + +#include +#include +#include "bam.h" +#include "kstring.h" +#include "bam2bcf.h" +#include "errmod.h" +#include "bcftools/bcf.h" + +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 + +bcf_callaux_t *bcf_call_init(double theta, int min_baseQ) +{ + bcf_callaux_t *bca; + if (theta <= 0.) theta = CALL_DEFTHETA; + bca = calloc(1, sizeof(bcf_callaux_t)); + bca->capQ = 60; + 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; +} + +void bcf_call_destroy(bcf_callaux_t *bca) +{ + if (bca == 0) return; + errmod_destroy(bca->e); + free(bca->bases); free(bca->inscns); free(bca); +} +/* ref_base is the 4-bit representation of the reference base. It is + * negative if we are looking at an indel. */ +int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t *bca, bcf_callret1_t *r) +{ + int i, n, ref4, is_indel, ori_depth = 0; + memset(r, 0, sizeof(bcf_callret1_t)); + if (ref_base >= 0) { + ref4 = bam_nt16_nt4_table[ref_base]; + is_indel = 0; + } else ref4 = 4, is_indel = 1; + if (_n == 0) return -1; + // enlarge the bases array if necessary + if (bca->max_bases < _n) { + bca->max_bases = _n; + kroundup32(bca->max_bases); + bca->bases = (uint16_t*)realloc(bca->bases, 2 * bca->max_bases); + } + // fill the bases array + memset(r, 0, sizeof(bcf_callret1_t)); + for (i = n = 0; i < _n; ++i) { + const bam_pileup1_t *p = pl + i; + int q, b, mapQ, baseQ, is_diff, min_dist, seqQ; + // set base + if (p->is_del || p->is_refskip || (p->b->core.flag&BAM_FUNMAP)) continue; + ++ori_depth; + baseQ = q = is_indel? p->aux&0xff : (int)bam1_qual(p->b)[p->qpos]; // base/indel quality + seqQ = is_indel? (p->aux>>8&0xff) : 99; + if (q < bca->min_baseQ) continue; + if (q > seqQ) q = seqQ; + 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; + if (!is_indel) { + b = bam1_seqi(bam1_seq(p->b), p->qpos); // base + b = bam_nt16_nt4_table[b? b : ref_base]; // b is the 2-bit base + is_diff = (ref4 < 4 && b == ref4)? 0 : 1; + } else { + b = p->aux>>16&0x3f; + is_diff = (b != 0); + } + bca->bases[n++] = q<<5 | (int)bam1_strand(p->b)<<4 | b; + // collect annotations + 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; + if (min_dist > CAP_DIST) min_dist = CAP_DIST; + r->anno[1<<2|is_diff<<1|0] += baseQ; + r->anno[1<<2|is_diff<<1|1] += baseQ * baseQ; + r->anno[2<<2|is_diff<<1|0] += mapQ; + r->anno[2<<2|is_diff<<1|1] += mapQ * mapQ; + r->anno[3<<2|is_diff<<1|0] += min_dist; + r->anno[3<<2|is_diff<<1|1] += min_dist * min_dist; + } + r->depth = n; r->ori_depth = ori_depth; + // glfgen + errmod_cal(bca->e, n, 5, bca->bases, r->p); + return r->depth; +} + +int bcf_call_combine(int n, const bcf_callret1_t *calls, int ref_base /*4-bit*/, bcf_call_t *call) +{ + int ref4, i, j, qsum[4]; + int64_t tmp; + if (ref_base >= 0) { + call->ori_ref = ref4 = bam_nt16_nt4_table[ref_base]; + if (ref4 > 4) ref4 = 4; + } else call->ori_ref = -1, ref4 = 0; + // calculate qsum + memset(qsum, 0, 4 * sizeof(int)); + for (i = 0; i < n; ++i) + for (j = 0; j < 4; ++j) + qsum[j] += calls[i].qsum[j]; + for (j = 0; j < 4; ++j) qsum[j] = qsum[j] << 2 | j; + // find the top 2 alleles + for (i = 1; i < 4; ++i) // insertion sort + for (j = i; j > 0 && qsum[j] < qsum[j-1]; --j) + tmp = qsum[j], qsum[j] = qsum[j-1], qsum[j-1] = tmp; + // set the reference allele and alternative allele(s) + for (i = 0; i < 5; ++i) call->a[i] = -1; + call->unseen = -1; + call->a[0] = ref4; + for (i = 3, j = 1; i >= 0; --i) { + if ((qsum[i]&3) != ref4) { + if (qsum[i]>>2 != 0) call->a[j++] = qsum[i]&3; + else break; + } + } + if (ref_base >= 0) { // for SNPs, find the "unseen" base + if (((ref4 < 4 && j < 4) || (ref4 == 4 && j < 5)) && i >= 0) + call->unseen = j, call->a[j++] = qsum[i]&3; + call->n_alleles = j; + } else { + call->n_alleles = j; + if (call->n_alleles == 1) return -1; // no reliable supporting read. stop doing anything + } + // set the PL array + if (call->n < n) { + call->n = n; + call->PL = realloc(call->PL, 15 * n); + } + { + int x, g[15], z; + double sum_min = 0.; + x = call->n_alleles * (call->n_alleles + 1) / 2; + // get the possible genotypes + for (i = z = 0; i < call->n_alleles; ++i) + 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; + float min = 1e37; + for (j = 0; j < x; ++j) + if (min > r->p[g[j]]) min = r->p[g[j]]; + sum_min += min; + for (j = 0; j < x; ++j) { + int y; + y = (int)(r->p[g[j]] - min + .499); + if (y > 255) y = 255; + PL[j] = y; + } + } +// if (ref_base < 0) fprintf(pysamerr, "%d,%d,%f,%d\n", call->n_alleles, x, sum_min, call->unseen); + call->shift = (int)(sum_min + .499); + } + // combine annotations + memset(call->anno, 0, 16 * sizeof(int)); + for (i = call->depth = call->ori_depth = 0, tmp = 0; i < n; ++i) { + call->depth += calls[i].depth; + call->ori_depth += calls[i].ori_depth; + for (j = 0; j < 16; ++j) call->anno[j] += calls[i].anno[j]; + } + return 0; +} + +int bcf_call2bcf(int tid, int pos, bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bcr, int is_SP, + const bcf_callaux_t *bca, const char *ref) +{ + extern double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two); + kstring_t s; + int i, j; + b->n_smpl = bc->n; + b->tid = tid; b->pos = pos; b->qual = 0; + s.s = b->str; s.m = b->m_str; s.l = 0; + kputc('\0', &s); + if (bc->ori_ref < 0) { // an indel + // write REF + kputc(ref[pos], &s); + for (j = 0; j < bca->indelreg; ++j) kputc(ref[pos+1+j], &s); + kputc('\0', &s); + // write ALT + kputc(ref[pos], &s); + for (i = 1; i < 4; ++i) { + if (bc->a[i] < 0) break; + if (i > 1) { + kputc(',', &s); kputc(ref[pos], &s); + } + if (bca->indel_types[bc->a[i]] < 0) { // deletion + for (j = -bca->indel_types[bc->a[i]]; j < bca->indelreg; ++j) + kputc(ref[pos+1+j], &s); + } else { // insertion; cannot be a reference unless a bug + char *inscns = &bca->inscns[bc->a[i] * bca->maxins]; + for (j = 0; j < bca->indel_types[bc->a[i]]; ++j) + kputc("ACGTN"[(int)inscns[j]], &s); + for (j = 0; j < bca->indelreg; ++j) kputc(ref[pos+1+j], &s); + } + } + kputc('\0', &s); + } else { // a SNP + kputc("ACGTN"[bc->ori_ref], &s); kputc('\0', &s); + for (i = 1; i < 5; ++i) { + if (bc->a[i] < 0) break; + if (i > 1) kputc(',', &s); + kputc(bc->unseen == i? 'X' : "ACGT"[bc->a[i]], &s); + } + kputc('\0', &s); + } + kputc('\0', &s); + // INFO + if (bc->ori_ref < 0) kputs("INDEL;", &s); + kputs("DP=", &s); kputw(bc->ori_depth, &s); kputs(";I16=", &s); + for (i = 0; i < 16; ++i) { + if (i) kputc(',', &s); + kputw(bc->anno[i], &s); + } + kputc('\0', &s); + // FMT + kputs("PL", &s); + if (bcr) { + kputs(":DP", &s); + if (is_SP) kputs(":SP", &s); + } + kputc('\0', &s); + b->m_str = s.m; b->str = s.s; b->l_str = s.l; + bcf_sync(b); + memcpy(b->gi[0].data, bc->PL, b->gi[0].len * bc->n); + if (bcr) { + uint16_t *dp = (uint16_t*)b->gi[1].data; + uint8_t *sp = is_SP? b->gi[2].data : 0; + for (i = 0; i < bc->n; ++i) { + bcf_callret1_t *p = bcr + i; + dp[i] = p->depth < 0xffff? p->depth : 0xffff; + if (is_SP) { + if (p->anno[0] + p->anno[1] < 2 || p->anno[2] + p->anno[3] < 2 + || p->anno[0] + p->anno[2] < 2 || p->anno[1] + p->anno[3] < 2) + { + sp[i] = 0; + } else { + double left, right, two; + int x; + kt_fisher_exact(p->anno[0], p->anno[1], p->anno[2], p->anno[3], &left, &right, &two); + x = (int)(-4.343 * log(two) + .499); + if (x > 255) x = 255; + sp[i] = x; + } + } + } + } + return 0; +} diff --git a/samtools/bam2bcf.h b/samtools/bam2bcf.h new file mode 100644 index 0000000..9585672 --- /dev/null +++ b/samtools/bam2bcf.h @@ -0,0 +1,55 @@ +#ifndef BAM2BCF_H +#define BAM2BCF_H + +#include +#include "errmod.h" +#include "bcftools/bcf.h" + +#define B2B_INDEL_NULL 10000 + +typedef struct __bcf_callaux_t { + int capQ, min_baseQ; + 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]; + int maxins, indelreg; + char *inscns; + uint16_t *bases; + errmod_t *e; + void *rghash; +} bcf_callaux_t; + +typedef struct { + int depth, ori_depth, qsum[4]; + int anno[16]; + float p[25]; +} bcf_callret1_t; + +typedef struct { + int a[5]; // alleles: ref, alt, alt2, alt3 + int n, n_alleles, shift, ori_ref, unseen; + int anno[16], depth, ori_depth; + uint8_t *PL; +} bcf_call_t; + +#ifdef __cplusplus +extern "C" { +#endif + + bcf_callaux_t *bcf_call_init(double theta, int min_baseQ); + void bcf_call_destroy(bcf_callaux_t *bca); + int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t *bca, bcf_callret1_t *r); + int bcf_call_combine(int n, const bcf_callret1_t *calls, int ref_base /*4-bit*/, bcf_call_t *call); + int bcf_call2bcf(int tid, int pos, bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bcr, int is_SP, + const bcf_callaux_t *bca, const char *ref); + int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref, + const void *rghash); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/samtools/bam2bcf_indel.c.pysam.c b/samtools/bam2bcf_indel.c.pysam.c new file mode 100644 index 0000000..b728648 --- /dev/null +++ b/samtools/bam2bcf_indel.c.pysam.c @@ -0,0 +1,471 @@ +#include "pysam.h" + +#include +#include +#include +#include "bam.h" +#include "bam2bcf.h" +#include "ksort.h" +#include "kaln.h" +#include "kprobaln.h" +#include "khash.h" +KHASH_SET_INIT_STR(rg) + +#define MINUS_CONST 0x10000000 +#define INDEL_WINDOW_SIZE 50 + +void *bcf_call_add_rg(void *_hash, const char *hdtext, const char *list) +{ + const char *s, *p, *q, *r, *t; + khash_t(rg) *hash; + if (list == 0 || hdtext == 0) return _hash; + if (_hash == 0) _hash = kh_init(rg); + hash = (khash_t(rg)*)_hash; + if ((s = strstr(hdtext, "@RG\t")) == 0) return hash; + do { + t = strstr(s + 4, "@RG\t"); // the next @RG + if ((p = strstr(s, "\tID:")) != 0) p += 4; + if ((q = strstr(s, "\tPL:")) != 0) q += 4; + if (p && q && (t == 0 || (p < t && q < t))) { // ID and PL are both present + int lp, lq; + char *x; + for (r = p; *r && *r != '\t' && *r != '\n'; ++r); lp = r - p; + for (r = q; *r && *r != '\t' && *r != '\n'; ++r); lq = r - q; + x = calloc((lp > lq? lp : lq) + 1, 1); + for (r = q; *r && *r != '\t' && *r != '\n'; ++r) x[r-q] = *r; + if (strstr(list, x)) { // insert ID to the hash table + khint_t k; + int ret; + for (r = p; *r && *r != '\t' && *r != '\n'; ++r) x[r-p] = *r; + x[r-p] = 0; + k = kh_get(rg, hash, x); + if (k == kh_end(hash)) k = kh_put(rg, hash, x, &ret); + else free(x); + } else free(x); + } + s = t; + } while (s); + return hash; +} + +void bcf_call_del_rghash(void *_hash) +{ + khint_t k; + khash_t(rg) *hash = (khash_t(rg)*)_hash; + if (hash == 0) return; + for (k = kh_begin(hash); k < kh_end(hash); ++k) + if (kh_exist(hash, k)) + free((char*)kh_key(hash, k)); + kh_destroy(rg, hash); +} + +static int tpos2qpos(const bam1_core_t *c, const uint32_t *cigar, int32_t tpos, int is_left, int32_t *_tpos) +{ + int k, x = c->pos, y = 0, last_y = 0; + *_tpos = c->pos; + for (k = 0; k < c->n_cigar; ++k) { + int op = cigar[k] & BAM_CIGAR_MASK; + int l = cigar[k] >> BAM_CIGAR_SHIFT; + if (op == BAM_CMATCH) { + if (c->pos > tpos) return y; + if (x + l > tpos) { + *_tpos = tpos; + return y + (tpos - x); + } + x += l; y += l; + last_y = y; + } else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) y += l; + else if (op == BAM_CDEL || op == BAM_CREF_SKIP) { + if (x + l > tpos) { + *_tpos = is_left? x : x + l; + return y; + } + x += l; + } + } + *_tpos = x; + return last_y; +} +// FIXME: check if the inserted sequence is consistent with the homopolymer run +// l is the relative gap length and l_run is the length of the homopolymer on the reference +static inline int est_seqQ(const bcf_callaux_t *bca, int l, int l_run) +{ + int q, qh; + q = bca->openQ + bca->extQ * (abs(l) - 1); + qh = l_run >= 3? (int)(bca->tandemQ * (double)abs(l) / l_run + .499) : 1000; + return q < qh? q : qh; +} + +static inline int est_indelreg(int pos, const char *ref, int l, char *ins4) +{ + int i, j, max = 0, max_i = pos, score = 0; + l = abs(l); + for (i = pos + 1, j = 0; ref[i]; ++i, ++j) { + if (ins4) score += (toupper(ref[i]) != "ACGTN"[(int)ins4[j%l]])? -10 : 1; + else score += (toupper(ref[i]) != toupper(ref[pos+1+j%l]))? -10 : 1; + if (score < 0) break; + if (max < score) max = score, max_i = i; + } + return max_i - pos; +} + +int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref, + const void *rghash) +{ + 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, **ref_sample; + khash_t(rg) *hash = (khash_t(rg)*)rghash; + if (ref == 0 || bca == 0) return -1; + // mark filtered reads + if (rghash) { + N = 0; + for (s = N = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i) { + bam_pileup1_t *p = plp[s] + i; + const uint8_t *rg = bam_aux_get(p->b, "RG"); + p->aux = 1; // filtered by default + if (rg) { + khint_t k = kh_get(rg, hash, (const char*)(rg + 1)); + if (k != kh_end(hash)) p->aux = 0, ++N; // not filtered + } + } + } + if (N == 0) return -1; // no reads left + } + // determine if there is a gap + for (s = N = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i) + if (plp[s][i].indel != 0) break; + if (i < n_plp[s]) break; + } + if (s == n) return -1; // there is no indel at this position. + for (s = N = 0; s < n; ++s) N += n_plp[s]; // N is the total number of reads + { // find out how many types of indels are present + int m, n_alt = 0, n_tot = 0; + uint32_t *aux; + aux = calloc(N + 1, 4); + m = max_rd_len = 0; + aux[m++] = MINUS_CONST; // zero indel is always a type + for (s = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i) { + const bam_pileup1_t *p = plp[s] + i; + if (rghash == 0 || p->aux == 0) { + ++n_tot; + if (p->indel != 0) { + ++n_alt; + aux[m++] = MINUS_CONST + p->indel; + } + } + j = bam_cigar2qlen(&p->b->core, bam1_cigar(p->b)); + if (j > max_rd_len) max_rd_len = j; + } + } + ks_introsort(uint32_t, m, aux); + // 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 || (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)); + t = 0; + types[t++] = aux[0] - MINUS_CONST; + for (i = 1; i < m; ++i) + if (aux[i] != aux[i-1]) + types[t++] = aux[i] - MINUS_CONST; + free(aux); + for (t = 0; t < n_types; ++t) + if (types[t] == 0) break; + ref_type = t; // the index of the reference type (0) + assert(n_types < 64); + } + { // calculate left and right boundary + left = pos > INDEL_WINDOW_SIZE? pos - INDEL_WINDOW_SIZE : 0; + right = pos + INDEL_WINDOW_SIZE; + if (types[0] < 0) right -= types[0]; + // in case the alignments stand out the reference + for (i = pos; i < right; ++i) + 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; + else { + for (i = pos + 2; ref[i]; ++i) + if (bam_nt16_table[(int)ref[i]] != c) break; + l_run = i; + for (i = pos; i >= 0; --i) + if (bam_nt16_table[(int)ref[i]] != c) break; + l_run -= i + 1; + } + } + // construct the consensus sequence + max_ins = types[n_types - 1]; // max_ins is at least 0 + if (max_ins > 0) { + int *inscns_aux = calloc(4 * n_types * max_ins, sizeof(int)); + // count the number of occurrences of each base at each position for each type of insertion + for (t = 0; t < n_types; ++t) { + if (types[t] > 0) { + for (s = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i) { + bam_pileup1_t *p = plp[s] + i; + if (p->indel == types[t]) { + uint8_t *seq = bam1_seq(p->b); + for (k = 1; k <= p->indel; ++k) { + int c = bam_nt16_nt4_table[bam1_seqi(seq, p->qpos + k)]; + if (c < 4) ++inscns_aux[(t*max_ins+(k-1))*4 + c]; + } + } + } + } + } + } + // use the majority rule to construct the consensus + inscns = calloc(n_types * max_ins, 1); + for (t = 0; t < n_types; ++t) { + for (j = 0; j < types[t]; ++j) { + int max = 0, max_k = -1, *ia = &inscns_aux[(t*max_ins+j)*4]; + for (k = 0; k < 4; ++k) + if (ia[k] > max) + max = ia[k], max_k = k; + inscns[t*max_ins + j] = max? max_k : 4; + } + } + free(inscns_aux); + } + // compute the likelihood given each type of indel for each read + max_ref2 = right - left + 2 + 2 * (max_ins > -types[0]? max_ins : -types[0]); + ref2 = calloc(max_ref2, 1); + query = calloc(right - left + max_rd_len + max_ins + 2, 1); + score1 = calloc(N * n_types, sizeof(int)); + score2 = calloc(N * n_types, sizeof(int)); + bca->indelreg = 0; + for (t = 0; t < n_types; ++t) { + int l, ir; + kpa_par_t apf1 = { 1e-4, 1e-2, 10 }, apf2 = { 1e-6, 1e-3, 10 }; + apf1.bw = apf2.bw = abs(types[t]) + 3; + // compute indelreg + if (types[t] == 0) ir = 0; + else if (types[t] > 0) ir = est_indelreg(pos, ref, types[t], &inscns[t*max_ins]); + 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); + // 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, 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); + qend = tpos2qpos(&p->b->core, bam1_cigar(p->b), right, 1, &tend); + if (types[t] < 0) { + int l = -types[t]; + tbeg = tbeg - l > left? tbeg - l : left; + } + // write the query sequence + for (l = qbeg; l < qend; ++l) + query[l - qbeg] = bam_nt16_nt4_table[bam1_seqi(seq, l)]; + { // do realignment; this is the bottleneck + const uint8_t *qual = bam1_qual(p->b), *bq; + uint8_t *qq; + qq = calloc(qend - qbeg, 1); + bq = (uint8_t*)bam_aux_get(p->b, "ZQ"); + if (bq) ++bq; // skip type + for (l = qbeg; l < qend; ++l) { + qq[l - qbeg] = bq? qual[l] + (bq[l] - 64) : qual[l]; + if (qq[l - qbeg] > 30) qq[l - qbeg] = 30; + if (qq[l - qbeg] < 7) qq[l - qbeg] = 7; + } + sc = kpa_glocal((uint8_t*)ref2 + tbeg - left, tend - tbeg + abs(types[t]), + (uint8_t*)query, qend - qbeg, qq, &apf1, 0, 0); + l = (int)(100. * sc / (qend - qbeg) + .499); // used for adjusting indelQ below + if (l > 255) l = 255; + score1[K*n_types + t] = score2[K*n_types + t] = sc<<8 | l; + if (sc > 5) { + sc = kpa_glocal((uint8_t*)ref2 + tbeg - left, tend - tbeg + abs(types[t]), + (uint8_t*)query, qend - qbeg, qq, &apf2, 0, 0); + l = (int)(100. * sc / (qend - qbeg) + .499); + if (l > 255) l = 255; + score2[K*n_types + t] = sc<<8 | l; + } + free(qq); + } +/* + for (l = 0; l < tend - tbeg + abs(types[t]); ++l) + fputc("ACGTN"[(int)ref2[tbeg-left+l]], pysamerr); + fputc('\n', pysamerr); + for (l = 0; l < qend - qbeg; ++l) fputc("ACGTN"[(int)query[l]], pysamerr); + fputc('\n', pysamerr); + fprintf(pysamerr, "pos=%d type=%d read=%d:%d name=%s qbeg=%d tbeg=%d score=%d\n", pos, types[t], s, i, bam1_qname(p->b), qbeg, tbeg, sc); +*/ + } + } + } + free(ref2); free(query); + { // compute indelQ + int *sc, tmp, *sumq; + sc = alloca(n_types * sizeof(int)); + sumq = alloca(n_types * sizeof(int)); + memset(sumq, 0, sizeof(int) * n_types); + for (s = K = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i, ++K) { + bam_pileup1_t *p = plp[s] + i; + int *sct = &score1[K*n_types], indelQ1, indelQ2, seqQ, indelQ; + for (t = 0; t < n_types; ++t) sc[t] = sct[t]<<6 | t; + for (t = 1; t < n_types; ++t) // insertion sort + for (j = t; j > 0 && sc[j] < sc[j-1]; --j) + tmp = sc[j], sc[j] = sc[j-1], sc[j-1] = tmp; + /* errmod_cal() assumes that if the call is wrong, the + * likelihoods of other events are equal. This is about + * right for substitutions, but is not desired for + * indels. To reuse errmod_cal(), I have to make + * compromise for multi-allelic indels. + */ + if ((sc[0]&0x3f) == ref_type) { + indelQ1 = (sc[1]>>14) - (sc[0]>>14); + seqQ = est_seqQ(bca, types[sc[1]&0x3f], l_run); + } else { + for (t = 0; t < n_types; ++t) // look for the reference type + if ((sc[t]&0x3f) == ref_type) break; + indelQ1 = (sc[t]>>14) - (sc[0]>>14); + seqQ = est_seqQ(bca, types[sc[0]&0x3f], l_run); + } + tmp = sc[0]>>6 & 0xff; + indelQ1 = tmp > 111? 0 : (int)((1. - tmp/111.) * indelQ1 + .499); // reduce indelQ + sct = &score2[K*n_types]; + for (t = 0; t < n_types; ++t) sc[t] = sct[t]<<6 | t; + for (t = 1; t < n_types; ++t) // insertion sort + for (j = t; j > 0 && sc[j] < sc[j-1]; --j) + tmp = sc[j], sc[j] = sc[j-1], sc[j-1] = tmp; + if ((sc[0]&0x3f) == ref_type) { + indelQ2 = (sc[1]>>14) - (sc[0]>>14); + } else { + for (t = 0; t < n_types; ++t) // look for the reference type + if ((sc[t]&0x3f) == ref_type) break; + indelQ2 = (sc[t]>>14) - (sc[0]>>14); + } + tmp = sc[0]>>6 & 0xff; + indelQ2 = tmp > 111? 0 : (int)((1. - tmp/111.) * indelQ2 + .499); + // pick the smaller between indelQ1 and indelQ2 + indelQ = indelQ1 < indelQ2? indelQ1 : indelQ2; + 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 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 + bca->maxins = max_ins; + bca->inscns = realloc(bca->inscns, bca->maxins * 4); + for (t = 0; t < n_types; ++t) + sumq[t] = sumq[t]<<6 | t; + for (t = 1; t < n_types; ++t) // insertion sort + for (j = t; j > 0 && sumq[j] > sumq[j-1]; --j) + tmp = sumq[j], sumq[j] = sumq[j-1], sumq[j-1] = tmp; + for (t = 0; t < n_types; ++t) // look for the reference type + if ((sumq[t]&0x3f) == ref_type) break; + if (t) { // then move the reference type to the first + tmp = sumq[t]; + for (; t > 0; --t) sumq[t] = sumq[t-1]; + sumq[0] = tmp; + } + for (t = 0; t < 4; ++t) bca->indel_types[t] = B2B_INDEL_NULL; + for (t = 0; t < 4 && t < n_types; ++t) { + bca->indel_types[t] = types[sumq[t]&0x3f]; + memcpy(&bca->inscns[t * bca->maxins], &inscns[(sumq[t]&0x3f) * max_ins], bca->maxins); + } + // update p->aux + for (s = n_alt = 0; s < n; ++s) { + for (i = 0; i < n_plp[s]; ++i) { + bam_pileup1_t *p = plp[s] + i; + int x = types[p->aux>>16&0x3f]; + for (j = 0; j < 4; ++j) + if (x == bca->indel_types[j]) break; + p->aux = j<<16 | (j == 4? 0 : (p->aux&0xffff)); + if ((p->aux>>16&0x3f) > 0) ++n_alt; +// fprintf(pysamerr, "X pos=%d read=%d:%d name=%s call=%d type=%d q=%d seqQ=%d\n", pos, s, i, bam1_qname(p->b), p->aux>>16&63, bca->indel_types[p->aux>>16&63], p->aux&0xff, p->aux>>8&0xff); + } + } + } + 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 index 0000000..d22837e --- /dev/null +++ b/samtools/bam2depth.c.pysam.c @@ -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 +#include +#include +#include +#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] [...]\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; +} diff --git a/samtools/bam_aux.c b/samtools/bam_aux.c.pysam.c similarity index 90% rename from samtools/bam_aux.c rename to samtools/bam_aux.c.pysam.c index fbcd982..a1c1890 100644 --- a/samtools/bam_aux.c +++ b/samtools/bam_aux.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include "bam.h" #include "khash.h" @@ -26,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]) { @@ -126,7 +126,7 @@ int bam_parse_region(bam_header_t *header, const char *str, int *ref_id, int *be if (*begin > 0) --*begin; free(s); if (*begin > *end) { - fprintf(stderr, "[bam_parse_region] invalid region.\n"); + fprintf(pysamerr, "[bam_parse_region] invalid region.\n"); return -1; } return 0; @@ -180,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 index 0000000..0cc1167 --- /dev/null +++ b/samtools/bam_cat.c.pysam.c @@ -0,0 +1,186 @@ +#include "pysam.h" + +/* + +bam_cat -- efficiently concatenates bam files + +bam_cat can be used to concatenate BAM files. Under special +circumstances, it can be used as an alternative to 'samtools merge' to +concatenate multiple sorted files into a single sorted file. For this +to work each file must be sorted, and the sorted files must be given +as command line arguments in order such that the final read in file i +is less than or equal to the first read in file i+1. + +This code is derived from the bam_reheader function in samtools 0.1.8 +and modified to perform concatenation by Chris Saunders on behalf of +Illumina. + + +########## License: + +The MIT License + +Original SAMtools work copyright (c) 2008-2009 Genome Research Ltd. +Modified SAMtools work copyright (c) 2010 Illumina, Inc. + +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. + +*/ + + +/* +makefile: +""" +CC=gcc +CFLAGS+=-g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -I$(SAMTOOLS_DIR) +LDFLAGS+=-L$(SAMTOOLS_DIR) +LDLIBS+=-lbam -lz + +all:bam_cat +""" +*/ + + +#include +#include +#include + +#include "bgzf.h" +#include "bam.h" + +#define BUF_SIZE 0x10000 + +#define GZIPID1 31 +#define GZIPID2 139 + +#define BGZF_EMPTY_BLOCK_SIZE 28 + + +int bam_cat(int nfn, char * const *fn, const bam_header_t *h, const char* outbam) +{ + BGZF *fp; + FILE* fp_file; + uint8_t *buf; + uint8_t ebuf[BGZF_EMPTY_BLOCK_SIZE]; + const int es=BGZF_EMPTY_BLOCK_SIZE; + int i; + + fp = strcmp(outbam, "-")? bgzf_open(outbam, "w") : bgzf_fdopen(fileno(stdout), "w"); + if (fp == 0) { + fprintf(pysamerr, "[%s] ERROR: fail to open output file '%s'.\n", __func__, outbam); + return 1; + } + if (h) bam_header_write(fp, h); + + buf = (uint8_t*) malloc(BUF_SIZE); + for(i = 0; i < nfn; ++i){ + BGZF *in; + bam_header_t *old; + int len,j; + + in = strcmp(fn[i], "-")? bam_open(fn[i], "r") : bam_dopen(fileno(stdin), "r"); + if (in == 0) { + fprintf(pysamerr, "[%s] ERROR: fail to open file '%s'.\n", __func__, fn[i]); + return -1; + } + if (in->open_mode != 'r') return -1; + + old = bam_header_read(in); + if (h == 0 && i == 0) bam_header_write(fp, old); + + if (in->block_offset < in->block_length) { + bgzf_write(fp, in->uncompressed_block + in->block_offset, in->block_length - in->block_offset); + bgzf_flush(fp); + } + + j=0; +#ifdef _USE_KNETFILE + fp_file=fp->x.fpw; + while ((len = knet_read(in->x.fpr, buf, BUF_SIZE)) > 0) { +#else + fp_file=fp->file; + while (!feof(in->file) && (len = fread(buf, 1, BUF_SIZE, in->file)) > 0) { +#endif + if(len= 0) { + switch (c) { + case 'h': { + tamFile fph = sam_open(optarg); + if (fph == 0) { + fprintf(pysamerr, "[%s] ERROR: fail to read the header from '%s'.\n", __func__, argv[1]); + return 1; + } + h = sam_header_read(fph); + sam_close(fph); + break; + } + case 'o': outfn = strdup(optarg); break; + } + } + if (argc - optind < 2) { + fprintf(pysamerr, "Usage: samtools cat [-h header.sam] [-o out.bam] [...]\n"); + return 1; + } + ret = bam_cat(argc - optind, argv + optind, h, outfn? outfn : "-"); + free(outfn); + return ret; +} diff --git a/samtools/bam_color.c b/samtools/bam_color.c.pysam.c similarity index 99% rename from samtools/bam_color.c rename to samtools/bam_color.c.pysam.c index ce637f7..f71c65f 100644 --- a/samtools/bam_color.c +++ b/samtools/bam_color.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include "bam.h" diff --git a/samtools/bam_import.c b/samtools/bam_import.c.pysam.c similarity index 84% rename from samtools/bam_import.c rename to samtools/bam_import.c.pysam.c index 9d84328..da25f03 100644 --- a/samtools/bam_import.c +++ b/samtools/bam_import.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -136,7 +138,7 @@ bam_header_t *sam_header_read2(const char *fn) len = atoi(str->s); k = kh_put(ref, hash, s, &ret); if (ret == 0) { - fprintf(stderr, "[sam_header_read2] duplicated sequence name: %s\n", s); + fprintf(pysamerr, "[sam_header_read2] duplicated sequence name: %s\n", s); error = 1; } kh_value(hash, k) = (uint64_t)len<<32 | i; @@ -146,7 +148,7 @@ bam_header_t *sam_header_read2(const char *fn) ks_destroy(ks); gzclose(fp); free(str->s); free(str); - fprintf(stderr, "[sam_header_read2] %d sequences loaded.\n", kh_size(hash)); + fprintf(pysamerr, "[sam_header_read2] %d sequences loaded.\n", kh_size(hash)); if (error) return 0; header = hash2header(hash); kh_destroy(ref, hash); @@ -163,7 +165,7 @@ static inline uint8_t *alloc_data(bam1_t *b, int size) } static inline void parse_error(int64_t n_lines, const char * __restrict msg) { - fprintf(stderr, "Parse error at line %lld: %s\n", (long long)n_lines, msg); + fprintf(pysamerr, "Parse error at line %lld: %s\n", (long long)n_lines, msg); abort(); } static inline void append_text(bam_header_t *header, kstring_t *str) @@ -176,14 +178,14 @@ static inline void append_text(bam_header_t *header, kstring_t *str) header->text = (char*)realloc(header->text, y); if ( !header->text ) { - fprintf(stderr,"realloc failed to alloc %ld bytes\n", y); + fprintf(pysamerr,"realloc failed to alloc %ld bytes\n", y); abort(); } } // Sanity check if ( header->l_text+str->l+1 >= header->n_text ) { - fprintf(stderr,"append_text FIXME: %ld>=%ld, x=%ld,y=%ld\n", header->l_text+str->l+1,header->n_text,x,y); + fprintf(pysamerr,"append_text FIXME: %ld>=%ld, x=%ld,y=%ld\n", header->l_text+str->l+1,header->n_text,x,y); abort(); } strncpy(header->text + header->l_text, str->s, str->l+1); // we cannot use strcpy() here. @@ -275,9 +277,9 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b) ret = ks_getuntil(ks, KS_SEP_TAB, str, &dret); z += str->l + 1; c->tid = bam_get_tid(header, str->s); if (c->tid < 0 && strcmp(str->s, "*")) { if (header->n_targets == 0) { - fprintf(stderr, "[sam_read1] missing header? Abort!\n"); + fprintf(pysamerr, "[sam_read1] missing header? Abort!\n"); exit(1); - } else fprintf(stderr, "[sam_read1] reference '%s' is recognized as '*'.\n", str->s); + } else fprintf(pysamerr, "[sam_read1] reference '%s' is recognized as '*'.\n", str->s); } ret = ks_getuntil(ks, KS_SEP_TAB, str, &dret); z += str->l + 1; c->pos = isdigit(str->s[0])? atoi(str->s) - 1 : -1; ret = ks_getuntil(ks, KS_SEP_TAB, str, &dret); z += str->l + 1; c->qual = isdigit(str->s[0])? atoi(str->s) : 0; @@ -315,7 +317,7 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b) doff += c->n_cigar * 4; } else { if (!(c->flag&BAM_FUNMAP)) { - fprintf(stderr, "Parse warning at line %lld: mapped sequence without CIGAR\n", (long long)fp->n_lines); + fprintf(pysamerr, "Parse warning at line %lld: mapped sequence without CIGAR\n", (long long)fp->n_lines); c->flag |= BAM_FUNMAP; } c->bin = bam_reg2bin(c->pos, c->pos + 1); @@ -383,7 +385,7 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b) *s++ = 'i'; *(int32_t*)s = (int32_t)x; s += 4; doff += 5; if (x < -2147483648ll) - fprintf(stderr, "Parse warning at line %lld: integer %lld is out of range.", + fprintf(pysamerr, "Parse warning at line %lld: integer %lld is out of range.", (long long)fp->n_lines, x); } } else { @@ -397,7 +399,7 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b) *s++ = 'I'; *(uint32_t*)s = (uint32_t)x; s += 4; doff += 5; if (x > 4294967295ll) - fprintf(stderr, "Parse warning at line %lld: integer %lld is out of range.", + fprintf(pysamerr, "Parse warning at line %lld: integer %lld is out of range.", (long long)fp->n_lines, x); } } @@ -427,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; } diff --git a/samtools/bam_index.c b/samtools/bam_index.c.pysam.c similarity index 89% rename from samtools/bam_index.c rename to samtools/bam_index.c.pysam.c index 4152f20..e6c90bd 100644 --- a/samtools/bam_index.c +++ b/samtools/bam_index.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include "bam.h" @@ -180,7 +182,7 @@ bam_index_t *bam_index_core(bamFile fp) last_tid = c->tid; last_bin = 0xffffffffu; } else if (last_coor > c->pos) { - fprintf(stderr, "[bam_index_core] the alignment is not sorted (%s): %u > %u in %d-th chr\n", + fprintf(pysamerr, "[bam_index_core] the alignment is not sorted (%s): %u > %u in %d-th chr\n", bam1_qname(b), last_coor, c->pos, c->tid+1); exit(1); } @@ -201,7 +203,7 @@ bam_index_t *bam_index_core(bamFile fp) if (save_tid < 0) break; } if (bam_tell(fp) <= last_off) { - fprintf(stderr, "[bam_index_core] bug in BGZF/RAZF: %llx < %llx\n", + fprintf(pysamerr, "[bam_index_core] bug in BGZF/RAZF: %llx < %llx\n", (unsigned long long)bam_tell(fp), (unsigned long long)last_off); exit(1); } @@ -212,14 +214,21 @@ bam_index_t *bam_index_core(bamFile fp) } if (save_tid >= 0) { insert_offset(idx->index[save_tid], save_bin, save_off, bam_tell(fp)); - insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, off_end); + insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, bam_tell(fp)); insert_offset(idx->index[save_tid], BAM_MAX_BIN, n_mapped, n_unmapped); } merge_chunks(idx); fill_missing(idx); - if (ret >= 0) - while ((ret = bam_read1(fp, b)) >= 0) ++n_no_coor; - if (ret < -1) fprintf(stderr, "[bam_index_core] truncated file? Continue anyway. (%d)\n", ret); + 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; return idx; @@ -313,12 +322,12 @@ static bam_index_t *bam_index_load_core(FILE *fp) char magic[4]; bam_index_t *idx; if (fp == 0) { - fprintf(stderr, "[bam_index_load_core] fail to load index.\n"); + fprintf(pysamerr, "[bam_index_load_core] fail to load index.\n"); return 0; } fread(magic, 1, 4, fp); if (strncmp(magic, "BAI\1", 4)) { - fprintf(stderr, "[bam_index_load] wrong magic number.\n"); + fprintf(pysamerr, "[bam_index_load] wrong magic number.\n"); fclose(fp); return 0; } @@ -417,11 +426,11 @@ static void download_from_remote(const char *url) ++fn; // fn now points to the file name fp_remote = knet_open(url, "r"); if (fp_remote == 0) { - fprintf(stderr, "[download_from_remote] fail to open remote file.\n"); + fprintf(pysamerr, "[download_from_remote] fail to open remote file.\n"); return; } if ((fp = fopen(fn, "wb")) == 0) { - fprintf(stderr, "[download_from_remote] fail to create file in the working directory.\n"); + fprintf(pysamerr, "[download_from_remote] fail to create file in the working directory.\n"); knet_close(fp_remote); return; } @@ -446,11 +455,11 @@ bam_index_t *bam_index_load(const char *fn) if (idx == 0 && (strstr(fn, "ftp://") == fn || strstr(fn, "http://") == fn)) { char *fnidx = calloc(strlen(fn) + 5, 1); strcat(strcpy(fnidx, fn), ".bai"); - fprintf(stderr, "[bam_index_load] attempting to download the remote index file.\n"); + fprintf(pysamerr, "[bam_index_load] attempting to download the remote index file.\n"); download_from_remote(fnidx); idx = bam_index_load_local(fn); } - if (idx == 0) fprintf(stderr, "[bam_index_load] fail to load BAM index.\n"); + if (idx == 0) fprintf(pysamerr, "[bam_index_load] fail to load BAM index.\n"); return idx; } @@ -461,7 +470,7 @@ int bam_index_build2(const char *fn, const char *_fnidx) bamFile fp; bam_index_t *idx; if ((fp = bam_open(fn, "r")) == 0) { - fprintf(stderr, "[bam_index_build2] fail to open the BAM file.\n"); + fprintf(pysamerr, "[bam_index_build2] fail to open the BAM file.\n"); return -1; } idx = bam_index_core(fp); @@ -472,7 +481,7 @@ int bam_index_build2(const char *fn, const char *_fnidx) } else fnidx = strdup(_fnidx); fpidx = fopen(fnidx, "wb"); if (fpidx == 0) { - fprintf(stderr, "[bam_index_build2] fail to create the index file.\n"); + fprintf(pysamerr, "[bam_index_build2] fail to create the index file.\n"); free(fnidx); return -1; } @@ -491,7 +500,7 @@ int bam_index_build(const char *fn) int bam_index(int argc, char *argv[]) { if (argc < 2) { - fprintf(stderr, "Usage: samtools index [out.index]\n"); + fprintf(pysamerr, "Usage: samtools index [out.index]\n"); return 1; } if (argc >= 3) bam_index_build2(argv[1], argv[2]); @@ -506,15 +515,15 @@ int bam_idxstats(int argc, char *argv[]) bamFile fp; int i; if (argc < 2) { - fprintf(stderr, "Usage: samtools idxstats \n"); + fprintf(pysamerr, "Usage: samtools idxstats \n"); return 1; } fp = bam_open(argv[1], "r"); - if (fp == 0) { fprintf(stderr, "[%s] fail to open BAM.\n", __func__); return 1; } + if (fp == 0) { fprintf(pysamerr, "[%s] fail to open BAM.\n", __func__); return 1; } header = bam_header_read(fp); bam_close(fp); idx = bam_index_load(argv[1]); - if (idx == 0) { fprintf(stderr, "[%s] fail to load the index.\n", __func__); return 1; } + if (idx == 0) { fprintf(pysamerr, "[%s] fail to load the index.\n", __func__); return 1; } for (i = 0; i < idx->n; ++i) { khint_t k; khash_t(i) *h = idx->index[i]; @@ -608,6 +617,9 @@ bam_iter_t bam_iter_query(const bam_index_t *idx, int tid, int beg, int end) } } free(bins); + if (n_off == 0) { + free(off); return iter; + } { bam1_t *b = (bam1_t*)calloc(1, sizeof(bam1_t)); int l; @@ -656,17 +668,17 @@ void bam_iter_destroy(bam_iter_t iter) int bam_iter_read(bamFile fp, bam_iter_t iter, bam1_t *b) { - if (iter->finished) return -1; - if (iter->from_first) { - int ret = bam_read1(fp, b); - if (ret < 0) iter->finished = 1; + int ret; + if (iter && iter->finished) return -1; + if (iter == 0 || iter->from_first) { + ret = bam_read1(fp, b); + if (ret < 0 && iter) iter->finished = 1; return ret; } if (iter->off == 0) return -1; for (;;) { - int ret; if (iter->curr_off == 0 || iter->curr_off >= iter->off[iter->i].v) { // then jump to the next chunk - if (iter->i == iter->n_off - 1) break; // no more chunks + if (iter->i == iter->n_off - 1) { ret = -1; break; } // no more chunks if (iter->i >= 0) assert(iter->curr_off == iter->off[iter->i].v); // otherwise bug if (iter->i < 0 || iter->off[iter->i].v != iter->off[iter->i+1].u) { // not adjacent chunks; then seek bam_seek(fp, iter->off[iter->i+1].u, SEEK_SET); @@ -674,23 +686,28 @@ int bam_iter_read(bamFile fp, bam_iter_t iter, bam1_t *b) } ++iter->i; } - if ((ret = bam_read1(fp, b)) > 0) { + if ((ret = bam_read1(fp, b)) >= 0) { iter->curr_off = bam_tell(fp); - if (b->core.tid != iter->tid || b->core.pos >= iter->end) break; // no need to proceed + if (b->core.tid != iter->tid || b->core.pos >= iter->end) { // no need to proceed + ret = bam_validate1(NULL, b)? -1 : -5; // determine whether end of region or error + break; + } else if (is_overlap(iter->beg, iter->end, b)) return ret; - } else break; // end of file + } else break; // end of file or error } iter->finished = 1; - return -1; + return ret; } int bam_fetch(bamFile fp, const bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func) { + int ret; bam_iter_t iter; bam1_t *b; b = bam_init1(); iter = bam_iter_query(idx, tid, beg, end); - while (bam_iter_read(fp, iter, b) >= 0) func(b, data); + while ((ret = bam_iter_read(fp, iter, b)) >= 0) func(b, data); + bam_iter_destroy(iter); bam_destroy1(b); - return 0; + return (ret == -1)? 0 : ret; } diff --git a/samtools/bam_lpileup.c b/samtools/bam_lpileup.c.pysam.c similarity index 95% rename from samtools/bam_lpileup.c rename to samtools/bam_lpileup.c.pysam.c index d4dd63b..a5c5b04 100644 --- a/samtools/bam_lpileup.c +++ b/samtools/bam_lpileup.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -152,14 +154,14 @@ static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl } tv->n_pre = l; /* - fprintf(stderr, "%d\t", pos+1); + fprintf(pysamerr, "%d\t", pos+1); for (i = 0; i < n; ++i) { const bam_pileup1_t *p = pl + i; - if (p->is_head) fprintf(stderr, "^"); - if (p->is_tail) fprintf(stderr, "$"); - fprintf(stderr, "%d,", p->level); + if (p->is_head) fprintf(pysamerr, "^"); + if (p->is_tail) fprintf(pysamerr, "$"); + fprintf(pysamerr, "%d,", p->level); } - fprintf(stderr, "\n"); + fprintf(pysamerr, "\n"); */ return 0; } diff --git a/samtools/bam_maqcns.c b/samtools/bam_maqcns.c.pysam.c similarity index 87% rename from samtools/bam_maqcns.c rename to samtools/bam_maqcns.c.pysam.c index cad63d7..513a251 100644 --- a/samtools/bam_maqcns.c +++ b/samtools/bam_maqcns.c.pysam.c @@ -1,8 +1,11 @@ +#include "pysam.h" + #include #include #include "bam.h" #include "bam_maqcns.h" #include "ksort.h" +#include "errmod.h" #include "kaln.h" KSORT_INIT_GENERIC(uint32_t) @@ -12,16 +15,15 @@ KSORT_INIT_GENERIC(uint32_t) typedef struct __bmc_aux_t { int max; uint32_t *info; + uint16_t *info16; + errmod_t *em; } bmc_aux_t; typedef struct { float esum[4], fsum[4]; uint32_t c[4]; - uint32_t rms_mapQ; } 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() = \theta \sum_{i=1}^{N-1} 1/i P(D|) = \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] @@ -41,7 +43,7 @@ static void cal_het(bam_maqcns_t *aa) for (n1 = 0; n1 < 256; ++n1) { for (n2 = 0; n2 < 256; ++n2) { long double sum = 0.0; - double lC = aa->is_soap? 0 : lgamma(n1+n2+1) - lgamma(n1+1) - lgamma(n2+1); // \binom{n1+n2}{n1} + double lC = aa->errmod == BAM_ERRMOD_SOAP? 0 : lgamma(n1+n2+1) - lgamma(n1+1) - lgamma(n2+1); for (k = 1; k <= aa->n_hap - 1; ++k) { double pk = 1.0 / k / sum_harmo; double log1 = log((double)k/aa->n_hap); @@ -62,6 +64,7 @@ static void cal_coef(bam_maqcns_t *aa) long double sum_a[257], b[256], q_c[256], tmp[256], fk2[256]; double *lC; + if (aa->errmod == BAM_ERRMOD_MAQ2) return; // no need to do the following // aa->lhet will be allocated and initialized free(aa->fk); free(aa->coef); aa->coef = 0; @@ -71,7 +74,7 @@ static void cal_coef(bam_maqcns_t *aa) aa->fk[n] = pow(aa->theta, n) * (1.0 - aa->eta) + aa->eta; fk2[n] = aa->fk[n>>1]; // this is an approximation, assuming reads equally likely come from both strands } - if (aa->is_soap) return; + if (aa->errmod == BAM_ERRMOD_SOAP) return; aa->coef = (double*)calloc(256*256*64, sizeof(double)); lC = (double*)calloc(256 * 256, sizeof(double)); for (n = 1; n != 256; ++n) @@ -107,28 +110,31 @@ bam_maqcns_t *bam_maqcns_init() bm = (bam_maqcns_t*)calloc(1, sizeof(bam_maqcns_t)); bm->aux = (bmc_aux_t*)calloc(1, sizeof(bmc_aux_t)); bm->het_rate = 0.001; - bm->theta = 0.85; + bm->theta = 0.83f; bm->n_hap = 2; bm->eta = 0.03; bm->cap_mapQ = 60; + bm->min_baseQ = 13; return bm; } void bam_maqcns_prepare(bam_maqcns_t *bm) { + if (bm->errmod == BAM_ERRMOD_MAQ2) bm->aux->em = errmod_init(1. - bm->theta); cal_coef(bm); cal_het(bm); } void bam_maqcns_destroy(bam_maqcns_t *bm) { if (bm == 0) return; - free(bm->lhet); free(bm->fk); free(bm->coef); free(bm->aux->info); + free(bm->lhet); free(bm->fk); free(bm->coef); free(bm->aux->info); free(bm->aux->info16); + if (bm->aux->em) errmod_destroy(bm->aux->em); free(bm->aux); free(bm); } glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam_maqcns_t *bm) { - glf_call_aux_t *b; + glf_call_aux_t *b = 0; int i, j, k, w[8], c, n; glf1_t *g = (glf1_t*)calloc(1, sizeof(glf1_t)); float p[16], min_p = 1e30; @@ -142,28 +148,39 @@ glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam bm->aux->max = _n; kroundup32(bm->aux->max); bm->aux->info = (uint32_t*)realloc(bm->aux->info, 4 * bm->aux->max); + bm->aux->info16 = (uint16_t*)realloc(bm->aux->info16, 2 * bm->aux->max); } - for (i = n = 0; i < _n; ++i) { + for (i = n = 0, rms = 0; i < _n; ++i) { const bam_pileup1_t *p = pl + i; uint32_t q, x = 0, qq; - if (p->is_del || (p->b->core.flag&BAM_FUNMAP)) continue; + uint16_t y = 0; + if (p->is_del || p->is_refskip || (p->b->core.flag&BAM_FUNMAP)) continue; q = (uint32_t)bam1_qual(p->b)[p->qpos]; + if (q < bm->min_baseQ) continue; x |= (uint32_t)bam1_strand(p->b) << 18 | q << 8 | p->b->core.qual; + y |= bam1_strand(p->b)<<4; if (p->b->core.qual < q) q = p->b->core.qual; + c = p->b->core.qual < bm->cap_mapQ? p->b->core.qual : bm->cap_mapQ; + rms += c * c; x |= q << 24; + y |= q << 5; qq = bam1_seqi(bam1_seq(p->b), p->qpos); q = bam_nt16_nt4_table[qq? qq : ref_base]; - if (!p->is_del && q < 4) x |= 1 << 21 | q << 16; + if (!p->is_del && !p->is_refskip && q < 4) x |= 1 << 21 | q << 16, y |= q; + bm->aux->info16[n] = y; bm->aux->info[n++] = x; } + rms = (uint8_t)(sqrt((double)rms / n) + .499); + if (bm->errmod == BAM_ERRMOD_MAQ2) { + errmod_cal(bm->aux->em, n, 4, bm->aux->info16, p); + goto goto_glf; + } ks_introsort(uint32_t, n, bm->aux->info); // generate esum and fsum b = (glf_call_aux_t*)calloc(1, sizeof(glf_call_aux_t)); for (k = 0; k != 8; ++k) w[k] = 0; - rms = 0; for (j = n - 1; j >= 0; --j) { // calculate esum and fsum uint32_t info = bm->aux->info[j]; - int tmp; if (info>>24 < 4 && (info>>8&0x3f) != 0) info = 4<<24 | (info&0xffffff); k = info>>16&7; if (info>>24 > 0) { @@ -172,17 +189,14 @@ glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam if (w[k] < 0xff) ++w[k]; ++b->c[k&3]; } - tmp = (int)(info&0xff) < bm->cap_mapQ? (int)(info&0xff) : bm->cap_mapQ; - rms += tmp * tmp; } - b->rms_mapQ = (uint8_t)(sqrt((double)rms / n) + .499); // rescale ->c[] for (j = c = 0; j != 4; ++j) c += b->c[j]; if (c > 255) { for (j = 0; j != 4; ++j) b->c[j] = (int)(254.0 * b->c[j] / c + 0.5); for (j = c = 0; j != 4; ++j) c += b->c[j]; } - if (!bm->is_soap) { + if (bm->errmod == BAM_ERRMOD_MAQ) { // generate likelihood for (j = 0; j != 4; ++j) { // homozygous @@ -234,7 +248,7 @@ glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam if (max1 > max2 && (min_k != max_k || min1 + 1.0 > min2)) p[max_k<<2|max_k] = min1 > 1.0? min1 - 1.0 : 0.0; } - } else { // apply the SOAP model + } else if (bm->errmod == BAM_ERRMOD_SOAP) { // apply the SOAP model // generate likelihood for (j = 0; j != 4; ++j) { float tmp; @@ -251,8 +265,9 @@ glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam } } +goto_glf: // convert necessary information to glf1_t - g->ref_base = ref_base; g->max_mapQ = b->rms_mapQ; + g->ref_base = ref_base; g->max_mapQ = rms; g->depth = n > 16777215? 16777215 : n; for (j = 0; j != 4; ++j) for (k = j; k < 4; ++k) @@ -268,26 +283,25 @@ glf1_t *bam_maqcns_glfgen(int _n, const bam_pileup1_t *pl, uint8_t ref_base, bam uint32_t glf2cns(const glf1_t *g, int q_r) { - int i, j, k, tmp[16], min = 10000, min2 = 10000, min3 = 10000, min_g = -1, min_g2 = -1; + int i, j, k, p[10], ref4; uint32_t x = 0; + ref4 = bam_nt16_nt4_table[g->ref_base]; for (i = k = 0; i < 4; ++i) for (j = i; j < 4; ++j) { - tmp[j<<2|i] = -1; - tmp[i<<2|j] = g->lk[k++] + (i == j? 0 : q_r); + int prior = (i == ref4 && j == ref4? 0 : i == ref4 || j == ref4? q_r : q_r + 3); + p[k] = (g->lk[k] + prior)<<4 | i<<2 | j; + ++k; } - for (i = 0; i < 16; ++i) { - if (tmp[i] < 0) continue; - if (tmp[i] < min) { - min3 = min2; min2 = min; min = tmp[i]; min_g2 = min_g; min_g = i; - } else if (tmp[i] < min2) { - min3 = min2; min2 = tmp[i]; min_g2 = i; - } else if (tmp[i] < min3) min3 = tmp[i]; - } - x = min_g >= 0? (1U<<(min_g>>2&3) | 1U<<(min_g&3)) << 28 : 0xf << 28; - x |= min_g2 >= 0? (1U<<(min_g2>>2&3) | 1U<<(min_g2&3)) << 24 : 0xf << 24; - x |= (uint32_t)g->max_mapQ << 16; - x |= min2 < 10000? (min2 - min < 256? min2 - min : 255) << 8 : 0xff << 8; - x |= min2 < 10000 && min3 < 10000? (min3 - min2 < 256? min3 - min2 : 255) : 0xff; + for (i = 1; i < 10; ++i) // insertion sort + for (j = i; j > 0 && p[j] < p[j-1]; --j) + k = p[j], p[j] = p[j-1], p[j-1] = k; + x = (1u<<(p[0]&3) | 1u<<(p[0]>>2&3)) << 28; // the best genotype + x |= (uint32_t)g->max_mapQ << 16; // rms mapQ + x |= ((p[1]>>4) - (p[0]>>4) < 256? (p[1]>>4) - (p[0]>>4) : 255) << 8; // consensus Q + for (k = 0; k < 10; ++k) + if ((p[k]&0xf) == (ref4<<2|ref4)) break; + if (k == 10) k = 9; + x |= (p[k]>>4) - (p[0]>>4) < 256? (p[k]>>4) - (p[0]>>4) : 255; // snp Q return x; } @@ -297,7 +311,7 @@ uint32_t bam_maqcns_call(int n, const bam_pileup1_t *pl, bam_maqcns_t *bm) uint32_t x; if (n) { g = bam_maqcns_glfgen(n, pl, 0xf, bm); - x = glf2cns(g, (int)(bm->q_r + 0.5)); + x = g->depth == 0? (0xfU<<28 | 0xfU<<24) : glf2cns(g, (int)(bm->q_r + 0.5)); free(g); } else x = 0xfU<<28 | 0xfU<<24; return x; @@ -448,7 +462,7 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c for (i = 0; i < n_types; ++i) { ka_param_t ap = ka_param_blast; ap.band_width = 2 * types[n_types - 1] + 2; - ap.gap_end = 0; + ap.gap_end_ext = 0; // write ref2 for (k = 0, j = left; j <= pos; ++j) ref2[k++] = bam_nt16_nt4_table[bam_nt16_table[(int)ref[j]]]; @@ -503,14 +517,14 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c } pscore[i*n+j] = ps; /*if (1) { // for debugging only - fprintf(stderr, "id=%d, pos=%d, type=%d, j=%d, score=%d, psore=%d, %d, %d, %d, %d, %d, ", + fprintf(pysamerr, "id=%d, pos=%d, type=%d, j=%d, score=%d, psore=%d, %d, %d, %d, %d, %d, ", j, pos+1, types[i], j, score[i*n+j], pscore[i*n+j], tbeg, tend, qbeg, qend, mi->q_indel); - for (l = 0; l < n_acigar; ++l) fprintf(stderr, "%d%c", acigar[l]>>4, "MIDS"[acigar[l]&0xf]); - fprintf(stderr, "\n"); - for (l = 0; l < tend - tbeg + types[i]; ++l) fputc("ACGTN"[ref2[l+tbeg-left]], stderr); - fputc('\n', stderr); - for (l = 0; l < qend - qbeg; ++l) fputc("ACGTN"[rs[l]], stderr); - fputc('\n', stderr); + for (l = 0; l < n_acigar; ++l) fprintf(pysamerr, "%d%c", acigar[l]>>4, "MIDS"[acigar[l]&0xf]); + fprintf(pysamerr, "\n"); + for (l = 0; l < tend - tbeg + types[i]; ++l) fputc("ACGTN"[ref2[l+tbeg-left]], pysamerr); + fputc('\n', pysamerr); + for (l = 0; l < qend - qbeg; ++l) fputc("ACGTN"[rs[l]], pysamerr); + fputc('\n', pysamerr); }*/ free(acigar); } @@ -573,7 +587,7 @@ bam_maqindel_ret_t *bam_maqindel(int n, int pos, const bam_maqindel_opt_t *mi, c ret->gl[0] = ret->gl[1] = 0; for (j = 0; j < n; ++j) { int s1 = pscore[max1_i*n + j], s2 = pscore[max2_i*n + j]; - //fprintf(stderr, "id=%d, %d, %d, %d, %d, %d\n", j, pl[j].b->core.pos+1, types[max1_i], types[max2_i], s1, s2); + //fprintf(pysamerr, "id=%d, %d, %d, %d, %d, %d\n", j, pl[j].b->core.pos+1, types[max1_i], types[max2_i], s1, s2); if (s1 > s2) ret->gl[0] += s1 - s2 < seq_err? s1 - s2 : seq_err; else ret->gl[1] += s2 - s1 < seq_err? s2 - s1 : seq_err; } diff --git a/samtools/bam_maqcns.h b/samtools/bam_maqcns.h index 6cc5355..291ae53 100644 --- a/samtools/bam_maqcns.h +++ b/samtools/bam_maqcns.h @@ -3,11 +3,15 @@ #include "glf.h" +#define BAM_ERRMOD_MAQ2 0 +#define BAM_ERRMOD_MAQ 1 +#define BAM_ERRMOD_SOAP 2 + struct __bmc_aux_t; typedef struct { float het_rate, theta; - int n_hap, cap_mapQ, is_soap; + int n_hap, cap_mapQ, errmod, min_baseQ; float eta, q_r; double *fk, *coef; diff --git a/samtools/bam_mate.c b/samtools/bam_mate.c.pysam.c similarity index 96% rename from samtools/bam_mate.c rename to samtools/bam_mate.c.pysam.c index 61f808a..ebb797b 100644 --- a/samtools/bam_mate.c +++ b/samtools/bam_mate.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include "bam.h" @@ -59,7 +61,7 @@ int bam_mating(int argc, char *argv[]) { bamFile in, out; if (argc < 3) { - fprintf(stderr, "samtools fixmate \n"); + fprintf(pysamerr, "samtools fixmate \n"); return 1; } in = (strcmp(argv[1], "-") == 0)? bam_dopen(fileno(stdin), "r") : bam_open(argv[1], "r"); diff --git a/samtools/bam_md.c b/samtools/bam_md.c deleted file mode 100644 index 17b0a4a..0000000 --- a/samtools/bam_md.c +++ /dev/null @@ -1,175 +0,0 @@ -#include -#include -#include -#include -#include "faidx.h" -#include "sam.h" -#include "kstring.h" - -void bam_fillmd1_core(bam1_t *b, char *ref, int is_equal, int max_nm) -{ - uint8_t *seq = bam1_seq(b); - uint32_t *cigar = bam1_cigar(b); - bam1_core_t *c = &b->core; - int i, x, y, u = 0; - kstring_t *str; - uint8_t *old_md, *old_nm; - int32_t old_nm_i = -1, nm = 0; - - str = (kstring_t*)calloc(1, sizeof(kstring_t)); - for (i = y = 0, x = c->pos; i < c->n_cigar; ++i) { - int j, l = cigar[i]>>4, op = cigar[i]&0xf; - if (op == BAM_CMATCH) { - for (j = 0; j < l; ++j) { - int z = y + j; - int c1 = bam1_seqi(seq, z), c2 = bam_nt16_table[(int)ref[x+j]]; - if (ref[x+j] == 0) break; // out of boundary - if ((c1 == c2 && c1 != 15 && c2 != 15) || c1 == 0) { // a match - if (is_equal) seq[z/2] &= (z&1)? 0xf0 : 0x0f; - ++u; - } else { - ksprintf(str, "%d", u); - kputc(ref[x+j], str); - u = 0; ++nm; - } - } - if (j < l) break; - x += l; y += l; - } else if (op == BAM_CDEL) { - ksprintf(str, "%d", u); - kputc('^', str); - for (j = 0; j < l; ++j) { - if (ref[x+j] == 0) break; - kputc(ref[x+j], str); - } - u = 0; - if (j < l) break; - x += l; nm += l; - } else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) { - y += l; - if (op == BAM_CINS) nm += l; - } else if (op == BAM_CREF_SKIP) { - x += l; - } - } - ksprintf(str, "%d", u); - // apply max_nm - if (max_nm > 0 && nm >= max_nm) { - for (i = y = 0, x = c->pos; i < c->n_cigar; ++i) { - int j, l = cigar[i]>>4, op = cigar[i]&0xf; - if (op == BAM_CMATCH) { - for (j = 0; j < l; ++j) { - int z = y + j; - int c1 = bam1_seqi(seq, z), c2 = bam_nt16_table[(int)ref[x+j]]; - if (ref[x+j] == 0) break; // out of boundary - if ((c1 == c2 && c1 != 15 && c2 != 15) || c1 == 0) { // a match - seq[z/2] |= (z&1)? 0x0f : 0xf0; - bam1_qual(b)[z] = 0; - } - } - if (j < l) break; - 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; - } - } - // update NM - old_nm = bam_aux_get(b, "NM"); - if (c->flag & BAM_FUNMAP) return; - if (old_nm) old_nm_i = bam_aux2i(old_nm); - if (!old_nm) bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); - else if (nm != old_nm_i) { - fprintf(stderr, "[bam_fillmd1] different NM for read '%s': %d -> %d\n", bam1_qname(b), old_nm_i, nm); - bam_aux_del(b, old_nm); - bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); - } - // update MD - old_md = bam_aux_get(b, "MD"); - if (!old_md) bam_aux_append(b, "MD", 'Z', str->l + 1, (uint8_t*)str->s); - else { - int is_diff = 0; - if (strlen((char*)old_md+1) == str->l) { - for (i = 0; i < str->l; ++i) - if (toupper(old_md[i+1]) != toupper(str->s[i])) - break; - if (i < str->l) is_diff = 1; - } else is_diff = 1; - if (is_diff) { - fprintf(stderr, "[bam_fillmd1] different MD for read '%s': '%s' -> '%s'\n", bam1_qname(b), old_md+1, str->s); - bam_aux_del(b, old_md); - bam_aux_append(b, "MD", 'Z', str->l + 1, (uint8_t*)str->s); - } - } - free(str->s); free(str); -} - -void bam_fillmd1(bam1_t *b, char *ref, int is_equal) -{ - bam_fillmd1_core(b, ref, is_equal, 0); -} - -int bam_fillmd(int argc, char *argv[]) -{ - int c, is_equal = 0, tid = -2, ret, len, is_bam_out, is_sam_in, is_uncompressed, max_nm = 0; - samfile_t *fp, *fpout = 0; - faidx_t *fai; - char *ref = 0, mode_w[8], mode_r[8]; - bam1_t *b; - - is_bam_out = is_sam_in = is_uncompressed = 0; - mode_w[0] = mode_r[0] = 0; - strcpy(mode_r, "r"); strcpy(mode_w, "w"); - while ((c = getopt(argc, argv, "eubSn:")) >= 0) { - switch (c) { - case 'e': is_equal = 1; break; - case 'b': is_bam_out = 1; break; - case 'u': is_uncompressed = is_bam_out = 1; break; - case 'S': is_sam_in = 1; break; - case 'n': max_nm = atoi(optarg); break; - default: fprintf(stderr, "[bam_fillmd] unrecognized option '-%c'\n", c); return 1; - } - } - if (!is_sam_in) strcat(mode_r, "b"); - if (is_bam_out) strcat(mode_w, "b"); - else strcat(mode_w, "h"); - if (is_uncompressed) strcat(mode_w, "u"); - if (optind + 1 >= argc) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: samtools fillmd [-eubS] \n\n"); - fprintf(stderr, "Options: -e change identical bases to '='\n"); - fprintf(stderr, " -u uncompressed BAM output (for piping)\n"); - fprintf(stderr, " -b compressed BAM output\n"); - fprintf(stderr, " -S the input is SAM with header\n\n"); - return 1; - } - fp = samopen(argv[optind], mode_r, 0); - if (fp == 0) return 1; - if (is_sam_in && (fp->header == 0 || fp->header->n_targets == 0)) { - fprintf(stderr, "[bam_fillmd] input SAM does not have header. Abort!\n"); - return 1; - } - fpout = samopen("-", mode_w, fp->header); - fai = fai_load(argv[optind+1]); - - b = bam_init1(); - while ((ret = samread(fp, b)) >= 0) { - if (b->core.tid >= 0) { - if (tid != b->core.tid) { - free(ref); - ref = fai_fetch(fai, fp->header->target_name[b->core.tid], &len); - tid = b->core.tid; - if (ref == 0) - fprintf(stderr, "[bam_fillmd] fail to find sequence '%s' in the reference.\n", - fp->header->target_name[tid]); - } - if (ref) bam_fillmd1_core(b, ref, is_equal, max_nm); - } - samwrite(fpout, b); - } - bam_destroy1(b); - - free(ref); - fai_destroy(fai); - samclose(fp); samclose(fpout); - return 0; -} diff --git a/samtools/bam_md.c.pysam.c b/samtools/bam_md.c.pysam.c new file mode 100644 index 0000000..c6568b7 --- /dev/null +++ b/samtools/bam_md.c.pysam.c @@ -0,0 +1,359 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include +#include "faidx.h" +#include "sam.h" +#include "kstring.h" +#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); + uint32_t *cigar = bam1_cigar(b); + bam1_core_t *c = &b->core; + int i, x, y, u = 0; + kstring_t *str; + uint8_t *old_md, *old_nm; + int32_t old_nm_i = -1, nm = 0; + + str = (kstring_t*)calloc(1, sizeof(kstring_t)); + for (i = y = 0, x = c->pos; i < c->n_cigar; ++i) { + int j, l = cigar[i]>>4, op = cigar[i]&0xf; + if (op == BAM_CMATCH) { + for (j = 0; j < l; ++j) { + int z = y + j; + int c1 = bam1_seqi(seq, z), c2 = bam_nt16_table[(int)ref[x+j]]; + if (ref[x+j] == 0) break; // out of boundary + if ((c1 == c2 && c1 != 15 && c2 != 15) || c1 == 0) { // a match + if (is_equal) seq[z/2] &= (z&1)? 0xf0 : 0x0f; + ++u; + } else { + ksprintf(str, "%d", u); + kputc(ref[x+j], str); + u = 0; ++nm; + } + } + if (j < l) break; + x += l; y += l; + } else if (op == BAM_CDEL) { + ksprintf(str, "%d", u); + kputc('^', str); + for (j = 0; j < l; ++j) { + if (ref[x+j] == 0) break; + kputc(ref[x+j], str); + } + u = 0; + if (j < l) break; + x += l; nm += l; + } else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) { + y += l; + if (op == BAM_CINS) nm += l; + } else if (op == BAM_CREF_SKIP) { + x += l; + } + } + ksprintf(str, "%d", u); + // apply max_nm + if (max_nm > 0 && nm >= max_nm) { + for (i = y = 0, x = c->pos; i < c->n_cigar; ++i) { + int j, l = cigar[i]>>4, op = cigar[i]&0xf; + if (op == BAM_CMATCH) { + for (j = 0; j < l; ++j) { + int z = y + j; + int c1 = bam1_seqi(seq, z), c2 = bam_nt16_table[(int)ref[x+j]]; + if (ref[x+j] == 0) break; // out of boundary + if ((c1 == c2 && c1 != 15 && c2 != 15) || c1 == 0) { // a match + seq[z/2] |= (z&1)? 0x0f : 0xf0; + bam1_qual(b)[z] = 0; + } + } + if (j < l) break; + 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; + } + } + // update NM + old_nm = bam_aux_get(b, "NM"); + if (c->flag & BAM_FUNMAP) return; + if (old_nm) old_nm_i = bam_aux2i(old_nm); + if (!old_nm) bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); + else if (nm != old_nm_i) { + fprintf(pysamerr, "[bam_fillmd1] different NM for read '%s': %d -> %d\n", bam1_qname(b), old_nm_i, nm); + bam_aux_del(b, old_nm); + bam_aux_append(b, "NM", 'i', 4, (uint8_t*)&nm); + } + // update MD + old_md = bam_aux_get(b, "MD"); + if (!old_md) bam_aux_append(b, "MD", 'Z', str->l + 1, (uint8_t*)str->s); + else { + int is_diff = 0; + if (strlen((char*)old_md+1) == str->l) { + for (i = 0; i < str->l; ++i) + if (toupper(old_md[i+1]) != toupper(str->s[i])) + break; + if (i < str->l) is_diff = 1; + } else is_diff = 1; + if (is_diff) { + fprintf(pysamerr, "[bam_fillmd1] different MD for read '%s': '%s' -> '%s'\n", bam1_qname(b), old_md+1, str->s); + bam_aux_del(b, old_md); + bam_aux_append(b, "MD", 'Z', str->l + 1, (uint8_t*)str->s); + } + } + free(str->s); free(str); +} + +void bam_fillmd1(bam1_t *b, char *ref, int is_equal) +{ + bam_fillmd1_core(b, ref, is_equal, 0); +} + +int bam_cap_mapQ(bam1_t *b, char *ref, int thres) +{ + uint8_t *seq = bam1_seq(b), *qual = bam1_qual(b); + uint32_t *cigar = bam1_cigar(b); + bam1_core_t *c = &b->core; + int i, x, y, mm, q, len, clip_l, clip_q; + double t; + if (thres < 0) thres = 40; // set the default + mm = q = len = clip_l = clip_q = 0; + for (i = y = 0, x = c->pos; i < c->n_cigar; ++i) { + int j, l = cigar[i]>>4, op = cigar[i]&0xf; + if (op == BAM_CMATCH) { + for (j = 0; j < l; ++j) { + int z = y + j; + int c1 = bam1_seqi(seq, z), c2 = bam_nt16_table[(int)ref[x+j]]; + if (ref[x+j] == 0) break; // out of boundary + if (c2 != 15 && c1 != 15 && qual[z] >= 13) { // not ambiguous + ++len; + if (c1 && c1 != c2 && qual[z] >= 13) { // mismatch + ++mm; + q += qual[z] > 33? 33 : qual[z]; + } + } + } + if (j < l) break; + x += l; y += l; len += l; + } else if (op == BAM_CDEL) { + for (j = 0; j < l; ++j) + if (ref[x+j] == 0) break; + if (j < l) break; + x += l; + } else if (op == BAM_CSOFT_CLIP) { + for (j = 0; j < l; ++j) clip_q += qual[y+j]; + clip_l += l; + y += l; + } else if (op == BAM_CHARD_CLIP) { + clip_q += 13 * l; + clip_l += l; + } else if (op == BAM_CINS) y += l; + else if (op == BAM_CREF_SKIP) x += l; + } + for (i = 0, t = 1; i < mm; ++i) + t *= (double)len / (i+1); + t = q - 4.343 * log(t) + clip_q / 5.; + if (t > thres) return -1; + if (t < 0) t = 0; + t = sqrt((thres - t) / thres) * thres; +// fprintf(pysamerr, "%s %lf %d\n", bam1_qname(b), t, q); + return (int)(t + .499); +} + +int bam_prob_realn_core(bam1_t *b, const char *ref, int flag) +{ + 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) || 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; + if (bq && zq) { // remove the ZQ tag + bam_aux_del(b, zq-1); + zq = 0; + } + if (bq || zq) { + if ((apply_baq && zq) || (!apply_baq && bq)) return -3; // in both cases, do nothing + if (bq && apply_baq) { // then convert BQ to ZQ + for (i = 0; i < c->l_qseq; ++i) + qual[i] = qual[i] + 64 < bq[i]? 0 : qual[i] - ((int)bq[i] - 64); + *(bq - 3) = 'Z'; + } else if (zq && !apply_baq) { // then convert ZQ to BQ + for (i = 0; i < c->l_qseq; ++i) + qual[i] += (int)zq[i] - 64; + *(zq - 3) = 'B'; + } + return 0; + } + // find the start and end of the alignment + x = c->pos, y = 0, yb = ye = xb = xe = -1; + for (k = 0; k < c->n_cigar; ++k) { + int op, l; + op = cigar[k]&0xf; l = cigar[k]>>4; + if (op == BAM_CMATCH) { + if (yb < 0) yb = y; + if (xb < 0) xb = x; + ye = y + l; xe = x + l; + x += l; y += l; + } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) y += l; + else if (op == BAM_CDEL) x += l; + else if (op == BAM_CREF_SKIP) return -1; // do nothing if there is a reference skip + } + // set bandwidth and the start and the end + bw = 7; + if (abs((xe - xb) - (ye - yb)) > bw) + bw = abs((xe - xb) - (ye - yb)) + 3; + conf.bw = bw; + xb -= yb + bw/2; if (xb < 0) xb = 0; + xe += c->l_qseq - ye + bw/2; + if (xe - xb - c->l_qseq > bw) + xb += (xe - xb - c->l_qseq - bw) / 2, xe -= (xe - xb - c->l_qseq - bw) / 2; + { // glocal + uint8_t *s, *r, *q, *seq = bam1_seq(b), *bq; + int *state; + bq = calloc(c->l_qseq + 1, 1); + memcpy(bq, qual, c->l_qseq); + 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) { + 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); + 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); + } + 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); + } else bam_aux_append(b, "BQ", 'Z', c->l_qseq + 1, bq); + free(bq); free(s); free(r); free(q); free(state); + } + return 0; +} + +int bam_prob_realn(bam1_t *b, const char *ref) +{ + return bam_prob_realn_core(b, ref, 1); +} + +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, 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 = capQ = baq_flag = 0; + mode_w[0] = mode_r[0] = 0; + strcpy(mode_r, "r"); strcpy(mode_w, "w"); + while ((c = getopt(argc, argv, "EreubSC:n:A")) >= 0) { + switch (c) { + case 'r': is_realn = 1; break; + case 'e': is_equal = 1; break; + case 'b': is_bam_out = 1; break; + case 'u': is_uncompressed = is_bam_out = 1; break; + case 'S': is_sam_in = 1; break; + case 'n': max_nm = atoi(optarg); break; + case 'C': capQ = atoi(optarg); 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; + } + } + if (!is_sam_in) strcat(mode_r, "b"); + if (is_bam_out) strcat(mode_w, "b"); + else strcat(mode_w, "h"); + if (is_uncompressed) strcat(mode_w, "u"); + if (optind + 1 >= argc) { + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: samtools fillmd [-eubrS] \n\n"); + fprintf(pysamerr, "Options: -e change identical bases to '='\n"); + fprintf(pysamerr, " -u uncompressed BAM output (for piping)\n"); + 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 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); + if (fp == 0) return 1; + if (is_sam_in && (fp->header == 0 || fp->header->n_targets == 0)) { + fprintf(pysamerr, "[bam_fillmd] input SAM does not have header. Abort!\n"); + return 1; + } + fpout = samopen("-", mode_w, fp->header); + fai = fai_load(argv[optind+1]); + + b = bam_init1(); + while ((ret = samread(fp, b)) >= 0) { + if (b->core.tid >= 0) { + if (tid != b->core.tid) { + free(ref); + ref = fai_fetch(fai, fp->header->target_name[b->core.tid], &len); + tid = b->core.tid; + if (ref == 0) + 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, baq_flag); + if (capQ > 10) { + int q = bam_cap_mapQ(b, ref, capQ); + if (b->core.qual > q) b->core.qual = q; + } + if (ref) bam_fillmd1_core(b, ref, is_equal, max_nm); + } + samwrite(fpout, b); + } + bam_destroy1(b); + + free(ref); + fai_destroy(fai); + samclose(fp); samclose(fpout); + return 0; +} diff --git a/samtools/bam_pileup.c b/samtools/bam_pileup.c.pysam.c similarity index 65% rename from samtools/bam_pileup.c rename to samtools/bam_pileup.c.pysam.c index 3c41a16..59e54c0 100644 --- a/samtools/bam_pileup.c +++ b/samtools/bam_pileup.c.pysam.c @@ -1,12 +1,21 @@ +#include "pysam.h" + #include #include #include #include #include "sam.h" +typedef struct { + int k, x, y, end; +} cstate_t; + +static cstate_t g_cstate_null = { -1, 0, 0, 0 }; + typedef struct __linkbuf_t { bam1_t b; uint32_t beg, end; + cstate_t s; struct __linkbuf_t *next; } lbnode_t; @@ -53,68 +62,86 @@ static inline void mp_free(mempool_t *mp, lbnode_t *p) /* --- BEGIN: Auxiliary functions */ -static inline int resolve_cigar(bam_pileup1_t *p, uint32_t pos) +/* s->k: the index of the CIGAR operator that has just been processed. + s->x: the reference coordinate of the start of s->k + s->y: the query coordiante of the start of s->k + */ +static inline int resolve_cigar2(bam_pileup1_t *p, uint32_t pos, cstate_t *s) { - unsigned k; +#define _cop(c) ((c)&BAM_CIGAR_MASK) +#define _cln(c) ((c)>>BAM_CIGAR_SHIFT) + bam1_t *b = p->b; bam1_core_t *c = &b->core; - uint32_t x = c->pos, y = 0; - int ret = 1, is_restart = 1; - - if (c->flag&BAM_FUNMAP) return 0; // unmapped read - assert(x <= pos); // otherwise a bug - p->qpos = -1; p->indel = 0; p->is_del = p->is_head = p->is_tail = 0; - for (k = 0; k < c->n_cigar; ++k) { - int op = bam1_cigar(b)[k] & BAM_CIGAR_MASK; // operation - int l = bam1_cigar(b)[k] >> BAM_CIGAR_SHIFT; // length - if (op == BAM_CMATCH) { // NOTE: this assumes the first and the last operation MUST BE a match or a clip - if (x + l > pos) { // overlap with pos - p->indel = p->is_del = 0; - p->qpos = y + (pos - x); - if (x == pos && is_restart) p->is_head = 1; - if (x + l - 1 == pos) { // come to the end of a match - int has_next_match = 0; - unsigned i; - for (i = k + 1; i < c->n_cigar; ++i) { - uint32_t cigar = bam1_cigar(b)[i]; - int opi = cigar&BAM_CIGAR_MASK; - if (opi == BAM_CMATCH) { - has_next_match = 1; - break; - } else if (opi == BAM_CSOFT_CLIP || opi == BAM_CREF_SKIP || opi == BAM_CHARD_CLIP) break; - } - if (!has_next_match) p->is_tail = 1; - if (k < c->n_cigar - 1 && has_next_match) { // there are additional operation(s) - uint32_t cigar = bam1_cigar(b)[k+1]; // next CIGAR - int op_next = cigar&BAM_CIGAR_MASK; // next CIGAR operation - if (op_next == BAM_CDEL) p->indel = -(int32_t)(cigar>>BAM_CIGAR_SHIFT); // del - else if (op_next == BAM_CINS) p->indel = cigar>>BAM_CIGAR_SHIFT; // ins - else if (op_next == BAM_CPAD && k + 2 < c->n_cigar) { // no working for adjacent padding - cigar = bam1_cigar(b)[k+2]; op_next = cigar&BAM_CIGAR_MASK; - if (op_next == BAM_CDEL) p->indel = -(int32_t)(cigar>>BAM_CIGAR_SHIFT); // del - else if (op_next == BAM_CINS) p->indel = cigar>>BAM_CIGAR_SHIFT; // ins - } - } + uint32_t *cigar = bam1_cigar(b); + int k, is_head = 0; + // determine the current CIGAR operation +// fprintf(pysamerr, "%s\tpos=%d\tend=%d\t(%d,%d,%d)\n", bam1_qname(b), pos, s->end, s->k, s->x, s->y); + if (s->k == -1) { // never processed + is_head = 1; + if (c->n_cigar == 1) { // just one operation, save a loop + if (_cop(cigar[0]) == BAM_CMATCH) s->k = 0, s->x = c->pos, s->y = 0; + } else { // find the first match or deletion + for (k = 0, s->x = c->pos, s->y = 0; k < c->n_cigar; ++k) { + int op = _cop(cigar[k]); + int l = _cln(cigar[k]); + if (op == BAM_CMATCH || op == BAM_CDEL) break; + else if (op == BAM_CREF_SKIP) s->x += l; + else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) s->y += l; + } + assert(k < c->n_cigar); + s->k = k; + } + } else { // the read has been processed before + int op, l = _cln(cigar[s->k]); + if (pos - s->x >= l) { // jump to the next operation + assert(s->k < c->n_cigar); // otherwise a bug: this function should not be called in this case + op = _cop(cigar[s->k+1]); + if (op == BAM_CMATCH || op == BAM_CDEL || op == BAM_CREF_SKIP) { // jump to the next without a loop + if (_cop(cigar[s->k]) == BAM_CMATCH) s->y += l; + s->x += l; + ++s->k; + } else { // find the next M/D/N + if (_cop(cigar[s->k]) == BAM_CMATCH) s->y += l; + s->x += l; + for (k = s->k + 1; k < c->n_cigar; ++k) { + op = _cop(cigar[k]), l = _cln(cigar[k]); + if (op == BAM_CMATCH || op == BAM_CDEL || op == BAM_CREF_SKIP) break; + else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) s->y += l; } + s->k = k; } - x += l; y += l; - } else if (op == BAM_CDEL) { // then set ->is_del - if (x + l > pos) { - p->indel = 0; p->is_del = 1; - p->qpos = y + (pos - x); + assert(s->k < c->n_cigar); // otherwise a bug + } // else, do nothing + } + { // collect pileup information + int op, l; + op = _cop(cigar[s->k]); l = _cln(cigar[s->k]); + p->is_del = p->indel = p->is_refskip = 0; + if (s->x + l - 1 == pos && s->k + 1 < c->n_cigar) { // peek the next operation + int op2 = _cop(cigar[s->k+1]); + int l2 = _cln(cigar[s->k+1]); + if (op2 == BAM_CDEL) p->indel = -(int)l2; + else if (op2 == BAM_CINS) p->indel = l2; + else if (op2 == BAM_CPAD && s->k + 2 < c->n_cigar) { // no working for adjacent padding + int l3 = 0; + for (k = s->k + 2; k < c->n_cigar; ++k) { + op2 = _cop(cigar[k]); l2 = _cln(cigar[k]); + if (op2 == BAM_CINS) l3 += l2; + else if (op2 == BAM_CDEL || op2 == BAM_CMATCH || op2 == BAM_CREF_SKIP) break; + } + if (l3 > 0) p->indel = l3; } - x += l; - } else if (op == BAM_CREF_SKIP) x += l; - else if (op == BAM_CINS || op == BAM_CSOFT_CLIP) y += l; - if (is_restart) is_restart ^= (op == BAM_CMATCH); - else is_restart ^= (op == BAM_CREF_SKIP || op == BAM_CSOFT_CLIP || op == BAM_CHARD_CLIP); - if (x > pos) { - if (op == BAM_CREF_SKIP) ret = 0; // then do not put it into pileup at all - break; } + if (op == BAM_CMATCH) { + p->qpos = s->y + (pos - s->x); + } else if (op == BAM_CDEL || op == BAM_CREF_SKIP) { + p->is_del = 1; p->qpos = s->y; // FIXME: distinguish D and N!!!!! + p->is_refskip = (op == BAM_CREF_SKIP); + } // cannot be other operations; otherwise a bug + p->is_head = (pos == c->pos); p->is_tail = (pos == s->end); } - assert(x > pos); // otherwise a bug - return ret; + return 1; } /* --- END: Auxiliary functions */ @@ -127,7 +154,7 @@ struct __bam_plp_t { mempool_t *mp; lbnode_t *head, *tail, *dummy; int32_t tid, pos, max_tid, max_pos; - int is_eof, flag_mask, max_plp, error; + int is_eof, flag_mask, max_plp, error, maxcnt; bam_pileup1_t *plp; // for the "auto" interface only bam1_t *b; @@ -144,6 +171,7 @@ bam_plp_t bam_plp_init(bam_plp_auto_f func, void *data) iter->dummy = mp_alloc(iter->mp); iter->max_tid = iter->max_pos = -1; iter->flag_mask = BAM_DEF_MASK; + iter->maxcnt = 8000; if (func) { iter->func = func; iter->data = data; @@ -157,7 +185,7 @@ void bam_plp_destroy(bam_plp_t iter) mp_free(iter->mp, iter->dummy); mp_free(iter->mp, iter->head); if (iter->mp->cnt != 0) - fprintf(stderr, "[bam_plp_destroy] memory leak: %d. Continue anyway.\n", iter->mp->cnt); + fprintf(pysamerr, "[bam_plp_destroy] memory leak: %d. Continue anyway.\n", iter->mp->cnt); mp_destroy(iter->mp); if (iter->b) bam_destroy1(iter->b); free(iter->plp); @@ -183,7 +211,7 @@ const bam_pileup1_t *bam_plp_next(bam_plp_t iter, int *_tid, int *_pos, int *_n_ iter->plp = (bam_pileup1_t*)realloc(iter->plp, sizeof(bam_pileup1_t) * iter->max_plp); } iter->plp[n_plp].b = &p->b; - if (resolve_cigar(iter->plp + n_plp, iter->pos)) ++n_plp; // skip the read if we are looking at ref-skip + if (resolve_cigar2(iter->plp + n_plp, iter->pos, &p->s)) ++n_plp; // actually always true... } } iter->head = iter->dummy->next; // dummy->next may be changed @@ -191,7 +219,7 @@ const bam_pileup1_t *bam_plp_next(bam_plp_t iter, int *_tid, int *_pos, int *_n_ // update iter->tid and iter->pos if (iter->head->next) { if (iter->tid > iter->head->b.core.tid) { - fprintf(stderr, "[%s] unsorted input. Pileup aborts.\n", __func__); + fprintf(pysamerr, "[%s] unsorted input. Pileup aborts.\n", __func__); iter->error = 1; *_n_plp = -1; return 0; @@ -215,15 +243,17 @@ int bam_plp_push(bam_plp_t iter, const bam1_t *b) if (b) { if (b->core.tid < 0) return 0; if (b->core.flag & iter->flag_mask) return 0; + if (iter->tid == b->core.tid && iter->pos == b->core.pos && iter->mp->cnt > iter->maxcnt) return 0; bam_copy1(&iter->tail->b, b); iter->tail->beg = b->core.pos; iter->tail->end = bam_calend(&b->core, bam1_cigar(b)); + iter->tail->s = g_cstate_null; iter->tail->s.end = iter->tail->end - 1; // initialize cstate_t if (b->core.tid < iter->max_tid) { - fprintf(stderr, "[bam_pileup_core] the input is not sorted (chromosomes out of order)\n"); + fprintf(pysamerr, "[bam_pileup_core] the input is not sorted (chromosomes out of order)\n"); iter->error = 1; return -1; } if ((b->core.tid == iter->max_tid) && (iter->tail->beg < iter->max_pos)) { - fprintf(stderr, "[bam_pileup_core] the input is not sorted (reads out of order)\n"); + fprintf(pysamerr, "[bam_pileup_core] the input is not sorted (reads out of order)\n"); iter->error = 1; return -1; } @@ -241,7 +271,7 @@ const bam_pileup1_t *bam_plp_auto(bam_plp_t iter, int *_tid, int *_pos, int *_n_ const bam_pileup1_t *plp; if (iter->func == 0 || iter->error) { *_n_plp = -1; return 0; } if ((plp = bam_plp_next(iter, _tid, _pos, _n_plp)) != 0) return plp; - else { + else { // no pileup line can be obtained; read alignments *_n_plp = 0; if (iter->is_eof) return 0; while (iter->func(iter->data, iter->b) >= 0) { @@ -250,6 +280,7 @@ const bam_pileup1_t *bam_plp_auto(bam_plp_t iter, int *_tid, int *_pos, int *_n_ return 0; } if ((plp = bam_plp_next(iter, _tid, _pos, _n_plp)) != 0) return plp; + // otherwise no pileup line can be returned; read the next alignment. } bam_plp_push(iter, 0); if ((plp = bam_plp_next(iter, _tid, _pos, _n_plp)) != 0) return plp; @@ -276,6 +307,11 @@ void bam_plp_set_mask(bam_plp_t iter, int mask) iter->flag_mask = mask < 0? BAM_DEF_MASK : (BAM_FUNMAP | mask); } +void bam_plp_set_maxcnt(bam_plp_t iter, int maxcnt) +{ + iter->maxcnt = maxcnt; +} + /***************** * callback APIs * *****************/ @@ -363,6 +399,13 @@ bam_mplp_t bam_mplp_init(int n, bam_plp_auto_f func, void **data) return iter; } +void bam_mplp_set_maxcnt(bam_mplp_t iter, int maxcnt) +{ + int i; + for (i = 0; i < iter->n; ++i) + iter->iter[i]->maxcnt = maxcnt; +} + void bam_mplp_destroy(bam_mplp_t iter) { int i; @@ -387,7 +430,7 @@ int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_p if (new_min == (uint64_t)-1) return 0; *_tid = new_min>>32; *_pos = (uint32_t)new_min; for (i = 0; i < iter->n; ++i) { - if (iter->pos[i] == iter->min) { + if (iter->pos[i] == iter->min) { // FIXME: valgrind reports "uninitialised value(s) at this line" n_plp[i] = iter->n_plp[i], plp[i] = iter->plp[i]; ++ret; } else n_plp[i] = 0, plp[i] = 0; diff --git a/samtools/bam_plcmd.c b/samtools/bam_plcmd.c deleted file mode 100644 index 6804795..0000000 --- a/samtools/bam_plcmd.c +++ /dev/null @@ -1,570 +0,0 @@ -#include -#include -#include -#include -#include "sam.h" -#include "faidx.h" -#include "bam_maqcns.h" -#include "khash.h" -#include "glf.h" -#include "kstring.h" - -typedef int *indel_list_t; -KHASH_MAP_INIT_INT64(64, indel_list_t) - -#define BAM_PLF_SIMPLE 0x01 -#define BAM_PLF_CNS 0x02 -#define BAM_PLF_INDEL_ONLY 0x04 -#define BAM_PLF_GLF 0x08 -#define BAM_PLF_VAR_ONLY 0x10 -#define BAM_PLF_2ND 0x20 -#define BAM_PLF_RANBASE 0x40 -#define BAM_PLF_1STBASE 0x80 -#define BAM_PLF_ALLBASE 0x100 -#define BAM_PLF_READPOS 0x200 - -typedef struct { - bam_header_t *h; - bam_maqcns_t *c; - bam_maqindel_opt_t *ido; - faidx_t *fai; - khash_t(64) *hash; - uint32_t format; - int tid, len, last_pos; - int mask; - int max_depth; // for indel calling, ignore reads with the depth too high. 0 for unlimited - char *ref; - glfFile fp_glf; // for glf output only -} pu_data_t; - -char **__bam_get_lines(const char *fn, int *_n); -void bam_init_header_hash(bam_header_t *header); -int32_t bam_get_tid(const bam_header_t *header, const char *seq_name); - -static khash_t(64) *load_pos(const char *fn, bam_header_t *h) -{ - char **list; - int i, j, n, *fields, max_fields; - khash_t(64) *hash; - bam_init_header_hash(h); - list = __bam_get_lines(fn, &n); - hash = kh_init(64); - max_fields = 0; fields = 0; - for (i = 0; i < n; ++i) { - char *str = list[i]; - int chr, n_fields, ret; - khint_t k; - uint64_t x; - n_fields = ksplit_core(str, 0, &max_fields, &fields); - if (n_fields < 2) continue; - chr = bam_get_tid(h, str + fields[0]); - if (chr < 0) { - fprintf(stderr, "[load_pos] unknown reference sequence name: %s\n", str + fields[0]); - continue; - } - x = (uint64_t)chr << 32 | (atoi(str + fields[1]) - 1); - k = kh_put(64, hash, x, &ret); - if (ret == 0) { - fprintf(stderr, "[load_pos] position %s:%s has been loaded.\n", str+fields[0], str+fields[1]); - continue; - } - kh_val(hash, k) = 0; - if (n_fields > 2) { - // count - for (j = 2; j < n_fields; ++j) { - char *s = str + fields[j]; - if ((*s != '+' && *s != '-') || !isdigit(s[1])) break; - } - if (j > 2) { // update kh_val() - int *q, y, z; - q = kh_val(hash, k) = (int*)calloc(j - 1, sizeof(int)); - q[0] = j - 2; z = j; y = 1; - for (j = 2; j < z; ++j) - q[y++] = atoi(str + fields[j]); - } - } - free(str); - } - free(list); free(fields); - return hash; -} - -// an analogy to pileup_func() below -static int glt3_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pu, void *data) -{ - pu_data_t *d = (pu_data_t*)data; - bam_maqindel_ret_t *r = 0; - int rb, *proposed_indels = 0; - glf1_t *g; - glf3_t *g3; - - if (d->fai == 0) { - fprintf(stderr, "[glt3_func] reference sequence is required for generating GLT. Abort!\n"); - exit(1); - } - if (d->hash) { // only output a list of sites - khint_t k = kh_get(64, d->hash, (uint64_t)tid<<32|pos); - if (k == kh_end(d->hash)) return 0; - proposed_indels = kh_val(d->hash, k); - } - g3 = glf3_init1(); - if (d->fai && (int)tid != d->tid) { - if (d->ref) { // then write the end mark - g3->rtype = GLF3_RTYPE_END; - glf3_write1(d->fp_glf, g3); - } - glf3_ref_write(d->fp_glf, d->h->target_name[tid], d->h->target_len[tid]); // write reference - free(d->ref); - d->ref = fai_fetch(d->fai, d->h->target_name[tid], &d->len); - d->tid = tid; - d->last_pos = 0; - } - rb = (d->ref && (int)pos < d->len)? d->ref[pos] : 'N'; - g = bam_maqcns_glfgen(n, pu, bam_nt16_table[rb], d->c); - memcpy(g3, g, sizeof(glf1_t)); - g3->rtype = GLF3_RTYPE_SUB; - g3->offset = pos - d->last_pos; - d->last_pos = pos; - glf3_write1(d->fp_glf, g3); - if (pos < d->len) { - int m = (!d->max_depth || d->max_depth>n) ? n : d->max_depth; - if (proposed_indels) - 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); - } - if (r) { // then write indel line - int het = 3 * n, min; - min = het; - if (min > r->gl[0]) min = r->gl[0]; - if (min > r->gl[1]) min = r->gl[1]; - g3->ref_base = 0; - g3->rtype = GLF3_RTYPE_INDEL; - memset(g3->lk, 0, 10); - g3->lk[0] = r->gl[0] - min < 255? r->gl[0] - min : 255; - g3->lk[1] = r->gl[1] - min < 255? r->gl[1] - min : 255; - g3->lk[2] = het - min < 255? het - min : 255; - g3->offset = 0; - g3->indel_len[0] = r->indel1; - g3->indel_len[1] = r->indel2; - g3->min_lk = min < 255? min : 255; - g3->max_len = (abs(r->indel1) > abs(r->indel2)? abs(r->indel1) : abs(r->indel2)) + 1; - g3->indel_seq[0] = strdup(r->s[0]+1); - g3->indel_seq[1] = strdup(r->s[1]+1); - glf3_write1(d->fp_glf, g3); - bam_maqindel_ret_destroy(r); - } - free(g); - glf3_destroy1(g3); - return 0; -} - -static void pileup_seq(const bam_pileup1_t *p, int pos, int ref_len, const char *ref) -{ - if (p->is_head) printf("^%c", p->b->core.qual > 93? 126 : p->b->core.qual + 33); - if (!p->is_del) { - int j, rb, c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos)]; - rb = (ref && pos < ref_len)? ref[pos] : 'N'; - if (c == '=' || toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.'; - else c = bam1_strand(p->b)? tolower(c) : toupper(c); - putchar(c); - if (p->indel > 0) { - printf("+%d", p->indel); - for (j = 1; j <= p->indel; ++j) { - c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos + j)]; - putchar(bam1_strand(p->b)? tolower(c) : toupper(c)); - } - } else if (p->indel < 0) { - printf("%d", p->indel); - for (j = 1; j <= -p->indel; ++j) { - c = (ref && (int)pos+j < ref_len)? ref[pos+j] : 'N'; - putchar(bam1_strand(p->b)? tolower(c) : toupper(c)); - } - } - } else putchar('*'); - if (p->is_tail) putchar('$'); -} - -static int pileup_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pu, void *data) -{ - pu_data_t *d = (pu_data_t*)data; - bam_maqindel_ret_t *r = 0; - int i, rb, rms_mapq = -1, *proposed_indels = 0; - uint64_t rms_aux; - uint32_t cns = 0; - - // if GLF is required, suppress -c completely - if (d->format & BAM_PLF_GLF) return glt3_func(tid, pos, n, pu, data); - // if d->hash is initialized, only output the sites in the hash table - if (d->hash) { - khint_t k = kh_get(64, d->hash, (uint64_t)tid<<32|pos); - if (k == kh_end(d->hash)) return 0; - proposed_indels = kh_val(d->hash, k); - } - // update d->ref if necessary - if (d->fai && (int)tid != d->tid) { - free(d->ref); - d->ref = faidx_fetch_seq(d->fai, d->h->target_name[tid], 0, 0x7fffffff, &d->len); - d->tid = tid; - } - rb = (d->ref && (int)pos < d->len)? d->ref[pos] : 'N'; - // when the indel-only mode is asked for, return if no reads mapped with indels - if (d->format & BAM_PLF_INDEL_ONLY) { - for (i = 0; i < n; ++i) - if (pu[i].indel != 0) break; - if (i == n) return 0; - } - // call the consensus and indel - if (d->format & BAM_PLF_CNS) { // call consensus - if (d->format & (BAM_PLF_RANBASE|BAM_PLF_1STBASE)) { // use a random base or the 1st base as the consensus call - const bam_pileup1_t *p = (d->format & BAM_PLF_1STBASE)? pu : pu + (int)(drand48() * n); - int q = bam1_qual(p->b)[p->qpos]; - int mapQ = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; - uint32_t b = bam1_seqi(bam1_seq(p->b), p->qpos); - cns = b<<28 | 0xf<<24 | mapQ<<16 | q<<8; - } else if (d->format & BAM_PLF_ALLBASE) { // collapse all bases - uint64_t rmsQ = 0; - uint32_t b = 0; - for (i = 0; i < n; ++i) { - const bam_pileup1_t *p = pu + i; - int q = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; - b |= bam1_seqi(bam1_seq(p->b), p->qpos); - rmsQ += q * q; - } - rmsQ = (uint64_t)(sqrt((double)rmsQ / n) + .499); - cns = b<<28 | 0xf<<24 | rmsQ<<16 | 60<<8; - } else cns = bam_maqcns_call(n, pu, d->c); - } - if ((d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY)) && d->ref && pos < d->len) { // call indels - int m = (!d->max_depth || d->max_depth>n) ? n : d->max_depth; - 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)) { - if (!(bam_nt16_table[rb] != 15 && cns>>28 != bam_nt16_table[rb])) { // not a SNP - if (!(r && (r->gt == 2 || strcmp(r->s[r->gt], "*")))) { // not an indel - if (r) bam_maqindel_ret_destroy(r); - return 0; - } - } - } - // print the first 3 columns - printf("%s\t%d\t%c\t", d->h->target_name[tid], pos + 1, rb); - // print consensus information if required - if (d->format & BAM_PLF_CNS) { - int ref_q, rb4 = bam_nt16_table[rb]; - ref_q = 0; - if (rb4 != 15 && cns>>28 != 15 && cns>>28 != rb4) { // a SNP - ref_q = ((cns>>24&0xf) == rb4)? cns>>8&0xff : (cns>>8&0xff) + (cns&0xff); - if (ref_q > 255) ref_q = 255; - } - rms_mapq = cns>>16&0xff; - printf("%c\t%d\t%d\t%d\t", bam_nt16_rev_table[cns>>28], cns>>8&0xff, ref_q, rms_mapq); - } - // print pileup sequences - printf("%d\t", n); - rms_aux = 0; // we need to recalculate rms_mapq when -c is not flagged on the command line - for (i = 0; i < n; ++i) { - const bam_pileup1_t *p = pu + i; - int tmp = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; - rms_aux += tmp * tmp; - pileup_seq(p, pos, d->len, d->ref); - } - // finalize rms_mapq - rms_aux = (uint64_t)(sqrt((double)rms_aux / n) + .499); - if (rms_mapq < 0) rms_mapq = rms_aux; - putchar('\t'); - // print quality - for (i = 0; i < n; ++i) { - const bam_pileup1_t *p = pu + i; - int c = bam1_qual(p->b)[p->qpos] + 33; - if (c > 126) c = 126; - putchar(c); - } - if (d->format & BAM_PLF_2ND) { // print 2nd calls and qualities - const unsigned char *q; - putchar('\t'); - for (i = 0; i < n; ++i) { - const bam_pileup1_t *p = pu + i; - q = bam_aux_get(p->b, "E2"); - putchar(q? q[p->qpos + 1] : 'N'); - } - putchar('\t'); - for (i = 0; i < n; ++i) { - const bam_pileup1_t *p = pu + i; - q = bam_aux_get(p->b, "U2"); - putchar(q? q[p->qpos + 1] : '!'); - } - } - // print mapping quality if -s is flagged on the command line - if (d->format & BAM_PLF_SIMPLE) { - putchar('\t'); - for (i = 0; i < n; ++i) { - int c = pu[i].b->core.qual + 33; - if (c > 126) c = 126; - putchar(c); - } - } - // print read position - if (d->format & BAM_PLF_READPOS) { - putchar('\t'); - for (i = 0; i < n; ++i) { - int x = pu[i].qpos; - int l = pu[i].b->core.l_qseq; - printf("%d,", x < l/2? x+1 : -((l-1)-x+1)); - } - } - putchar('\n'); - // print the indel line if r has been calculated. This only happens if: - // a) -c or -i are flagged, AND b) the reference sequence is available - if (r) { - printf("%s\t%d\t*\t", d->h->target_name[tid], pos + 1); - if (r->gt < 2) printf("%s/%s\t", r->s[r->gt], r->s[r->gt]); - else printf("%s/%s\t", r->s[0], r->s[1]); - printf("%d\t%d\t", r->q_cns, r->q_ref); - printf("%d\t%d\t", rms_mapq, n); - printf("%s\t%s\t", r->s[0], r->s[1]); - //printf("%d\t%d\t", r->gl[0], r->gl[1]); - printf("%d\t%d\t%d\t", r->cnt1, r->cnt2, r->cnt_anti); - printf("%d\t%d\n", r->cnt_ref, r->cnt_ambi); - bam_maqindel_ret_destroy(r); - } - return 0; -} - -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 = 0; - d->tid = -1; d->mask = BAM_DEF_MASK; - d->c = bam_maqcns_init(); - d->c->is_soap = 1; // change the default model - d->ido = bam_maqindel_opt_init(); - while ((c = getopt(argc, argv, "st:f:cT:N:r:l:d:im:gI:G:vM:S2aR:PA")) >= 0) { - switch (c) { - case 'a': d->c->is_soap = 1; break; - case 'A': d->c->is_soap = 0; break; - case 's': d->format |= BAM_PLF_SIMPLE; break; - case 't': fn_list = strdup(optarg); break; - case 'l': fn_pos = strdup(optarg); break; - case 'f': fn_fa = strdup(optarg); break; - case 'T': d->c->theta = atof(optarg); break; - case 'N': d->c->n_hap = atoi(optarg); break; - case 'r': d->c->het_rate = atof(optarg); d->ido->r_snp = d->c->het_rate; break; - case 'M': d->c->cap_mapQ = atoi(optarg); break; - case 'd': d->max_depth = atoi(optarg); break; - case 'c': d->format |= BAM_PLF_CNS; break; - case 'i': d->format |= BAM_PLF_INDEL_ONLY; break; - case 'v': d->format |= BAM_PLF_VAR_ONLY; break; - case 'm': d->mask = strtol(optarg, 0, 0); break; - case 'g': d->format |= BAM_PLF_GLF; break; - case '2': d->format |= BAM_PLF_2ND; break; - case 'P': d->format |= BAM_PLF_READPOS; break; - case 'I': d->ido->q_indel = atoi(optarg); break; - case 'G': d->ido->r_indel = atof(optarg); break; - case 'S': is_SAM = 1; break; - case 'R': - if (strcmp(optarg, "random") == 0) d->format |= BAM_PLF_RANBASE; - else if (strcmp(optarg, "first") == 0) d->format |= BAM_PLF_1STBASE; - else if (strcmp(optarg, "all") == 0) d->format |= BAM_PLF_ALLBASE; - else fprintf(stderr, "[bam_pileup] unrecognized -R\n"); - break; - default: fprintf(stderr, "Unrecognizd option '-%c'.\n", c); return 1; - } - } - if (fn_list) is_SAM = 1; - if (optind == argc) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: samtools pileup [options] |\n\n"); - fprintf(stderr, "Option: -s simple (yet incomplete) pileup format\n"); - fprintf(stderr, " -S the input is in SAM\n"); - fprintf(stderr, " -A use the MAQ model for SNP calling\n"); - fprintf(stderr, " -2 output the 2nd best call and quality\n"); - fprintf(stderr, " -i only show lines/consensus with indels\n"); - fprintf(stderr, " -m INT filtering reads with bits in INT [%d]\n", d->mask); - fprintf(stderr, " -M INT cap mapping quality at INT [%d]\n", d->c->cap_mapQ); - fprintf(stderr, " -d INT limit maximum depth for indels [unlimited]\n"); - fprintf(stderr, " -t FILE list of reference sequences (force -S)\n"); - fprintf(stderr, " -l FILE list of sites at which pileup is output\n"); - fprintf(stderr, " -f FILE reference sequence in the FASTA format\n\n"); - fprintf(stderr, " -c output the SOAPsnp consensus sequence\n"); - fprintf(stderr, " -v print variants only (for -c)\n"); - fprintf(stderr, " -g output in the GLFv3 format (suppressing -c/-i/-s)\n"); - fprintf(stderr, " -T FLOAT theta in maq consensus calling model (for -c/-g) [%f]\n", d->c->theta); - fprintf(stderr, " -N INT number of haplotypes in the sample (for -c/-g) [%d]\n", d->c->n_hap); - fprintf(stderr, " -r FLOAT prior of a difference between two haplotypes (for -c/-g) [%f]\n", d->c->het_rate); - fprintf(stderr, " -G FLOAT prior of an indel between two haplotypes (for -c/-g) [%f]\n", d->ido->r_indel); - fprintf(stderr, " -I INT phred prob. of an indel in sequencing/prep. (for -c/-g) [%d]\n", d->ido->q_indel); - fprintf(stderr, "\n"); - free(fn_list); free(fn_fa); free(d); - return 1; - } - if (d->format & (BAM_PLF_RANBASE|BAM_PLF_1STBASE|BAM_PLF_ALLBASE)) d->format |= BAM_PLF_CNS; - if (fn_fa) d->fai = fai_load(fn_fa); - if (d->format & (BAM_PLF_CNS|BAM_PLF_GLF)) bam_maqcns_prepare(d->c); // consensus calling - if (d->format & BAM_PLF_GLF) { // for glf output - glf3_header_t *h; - h = glf3_header_init(); - d->fp_glf = bgzf_fdopen(fileno(stdout), "w"); - glf3_header_write(d->fp_glf, h); - glf3_header_destroy(h); - } - if (d->fai == 0 && (d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY))) - fprintf(stderr, "[bam_pileup] indels will not be called when -f is absent.\n"); - if (fn_fa && is_SAM && fn_list == 0) fn_list = samfaipath(fn_fa); - - { - samfile_t *fp; - fp = is_SAM? samopen(argv[optind], "r", fn_list) : samopen(argv[optind], "rb", 0); - if (fp == 0 || fp->header == 0) { - fprintf(stderr, "[bam_pileup] fail to read the header: non-exisiting file or wrong format.\n"); - return 1; - } - d->h = fp->header; - if (fn_pos) d->hash = load_pos(fn_pos, d->h); - sampileup(fp, d->mask, pileup_func, d); - samclose(fp); // d->h will be destroyed here - } - - // free - if (d->format & BAM_PLF_GLF) bgzf_close(d->fp_glf); - if (fn_pos) { // free the hash table - khint_t k; - for (k = kh_begin(d->hash); k < kh_end(d->hash); ++k) - if (kh_exist(d->hash, k)) free(kh_val(d->hash, k)); - kh_destroy(64, d->hash); - } - free(fn_pos); free(fn_list); free(fn_fa); - if (d->fai) fai_destroy(d->fai); - bam_maqcns_destroy(d->c); - free(d->ido); free(d->ref); free(d); - return 0; -} - -/*********** - * mpileup * - ***********/ - -typedef struct { - char *reg; - faidx_t *fai; -} mplp_conf_t; - -typedef struct { - bamFile fp; - bam_iter_t iter; -} mplp_aux_t; - -static int mplp_func(void *data, bam1_t *b) -{ - mplp_aux_t *ma = (mplp_aux_t*)data; - if (ma->iter) return bam_iter_read(ma->fp, ma->iter, b); - return bam_read1(ma->fp, b); -} - -static int mpileup(mplp_conf_t *conf, int n, char **fn) -{ - mplp_aux_t **data; - int i, tid, pos, *n_plp, beg0 = 0, end0 = 1u<<29, ref_len, ref_tid; - const bam_pileup1_t **plp; - bam_mplp_t iter; - bam_header_t *h = 0; - char *ref; - // allocate - data = calloc(n, sizeof(void*)); - plp = calloc(n, sizeof(void*)); - n_plp = calloc(n, sizeof(int*)); - // read the header and initialize data - for (i = 0; i < n; ++i) { - bam_header_t *h_tmp; - data[i] = calloc(1, sizeof(mplp_aux_t)); - data[i]->fp = bam_open(fn[i], "r"); - h_tmp = bam_header_read(data[i]->fp); - if (conf->reg) { - int beg, end; - bam_index_t *idx; - idx = bam_index_load(fn[i]); - if (idx == 0) { - fprintf(stderr, "[%s] fail to load index for %d-th input.\n", __func__, i+1); - exit(1); - } - if (bam_parse_region(h_tmp, conf->reg, &tid, &beg, &end) < 0) { - fprintf(stderr, "[%s] malformatted region or wrong seqname for %d-th input.\n", __func__, i+1); - exit(1); - } - if (i == 0) beg0 = beg, end0 = end; - data[i]->iter = bam_iter_query(idx, tid, beg, end); - bam_index_destroy(idx); - } - if (i == 0) h = h_tmp; - else { - // FIXME: to check consistency - bam_header_destroy(h_tmp); - } - } - // mpileup - ref_tid = -1; ref = 0; - iter = bam_mplp_init(n, mplp_func, (void**)data); - 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 (tid != ref_tid) { - free(ref); - if (conf->fai) ref = fai_fetch(conf->fai, h->target_name[tid], &ref_len); - ref_tid = tid; - } - printf("%s\t%d\t%c", h->target_name[tid], pos + 1, (ref && pos < ref_len)? ref[pos] : 'N'); - for (i = 0; i < n; ++i) { - int j; - printf("\t%d\t", n_plp[i]); - if (n_plp[i] == 0) printf("*\t*"); - else { - for (j = 0; j < n_plp[i]; ++j) - pileup_seq(plp[i] + j, pos, ref_len, ref); - putchar('\t'); - for (j = 0; j < n_plp[i]; ++j) { - const bam_pileup1_t *p = plp[i] + j; - int c = bam1_qual(p->b)[p->qpos] + 33; - if (c > 126) c = 126; - putchar(c); - } - } - } - putchar('\n'); - } - bam_mplp_destroy(iter); - 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(plp); free(ref); free(n_plp); - return 0; -} - -int bam_mpileup(int argc, char *argv[]) -{ - int c; - mplp_conf_t mplp; - memset(&mplp, 0, sizeof(mplp_conf_t)); - while ((c = getopt(argc, argv, "f:r:")) >= 0) { - switch (c) { - case 'f': - mplp.fai = fai_load(optarg); - if (mplp.fai == 0) return 1; - break; - case 'r': mplp.reg = strdup(optarg); - } - } - if (argc == 1) { - fprintf(stderr, "Usage: samtools mpileup [-r reg] [-f in.fa] in1.bam [in2.bam [...]]\n"); - return 1; - } - mpileup(&mplp, argc - optind, argv + optind); - free(mplp.reg); - if (mplp.fai) fai_destroy(mplp.fai); - return 0; -} diff --git a/samtools/bam_plcmd.c.pysam.c b/samtools/bam_plcmd.c.pysam.c new file mode 100644 index 0000000..93b729d --- /dev/null +++ b/samtools/bam_plcmd.c.pysam.c @@ -0,0 +1,982 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include +#include +#include "sam.h" +#include "faidx.h" +#include "bam_maqcns.h" +#include "khash.h" +#include "glf.h" +#include "kstring.h" + +typedef int *indel_list_t; +KHASH_MAP_INIT_INT64(64, indel_list_t) + +#define BAM_PLF_SIMPLE 0x01 +#define BAM_PLF_CNS 0x02 +#define BAM_PLF_INDEL_ONLY 0x04 +#define BAM_PLF_GLF 0x08 +#define BAM_PLF_VAR_ONLY 0x10 +#define BAM_PLF_2ND 0x20 +#define BAM_PLF_RANBASE 0x40 +#define BAM_PLF_1STBASE 0x80 +#define BAM_PLF_ALLBASE 0x100 +#define BAM_PLF_READPOS 0x200 +#define BAM_PLF_NOBAQ 0x400 + +typedef struct { + bam_header_t *h; + bam_maqcns_t *c; + bam_maqindel_opt_t *ido; + faidx_t *fai; + khash_t(64) *hash; + uint32_t format; + int tid, len, last_pos; + int mask; + int capQ_thres, min_baseQ; + int max_depth; // for indel calling, ignore reads with the depth too high. 0 for unlimited + char *ref; + glfFile fp_glf; // for glf output only +} pu_data_t; + +char **__bam_get_lines(const char *fn, int *_n); +void bam_init_header_hash(bam_header_t *header); +int32_t bam_get_tid(const bam_header_t *header, const char *seq_name); + +static khash_t(64) *load_pos(const char *fn, bam_header_t *h) +{ + char **list; + int i, j, n, *fields, max_fields; + khash_t(64) *hash; + bam_init_header_hash(h); + list = __bam_get_lines(fn, &n); + hash = kh_init(64); + max_fields = 0; fields = 0; + for (i = 0; i < n; ++i) { + char *str = list[i]; + int chr, n_fields, ret; + khint_t k; + uint64_t x; + n_fields = ksplit_core(str, 0, &max_fields, &fields); + if (n_fields < 2) continue; + chr = bam_get_tid(h, str + fields[0]); + if (chr < 0) { + fprintf(pysamerr, "[load_pos] unknown reference sequence name: %s\n", str + fields[0]); + continue; + } + x = (uint64_t)chr << 32 | (atoi(str + fields[1]) - 1); + k = kh_put(64, hash, x, &ret); + if (ret == 0) { + fprintf(pysamerr, "[load_pos] position %s:%s has been loaded.\n", str+fields[0], str+fields[1]); + continue; + } + kh_val(hash, k) = 0; + if (n_fields > 2) { + // count + for (j = 2; j < n_fields; ++j) { + char *s = str + fields[j]; + if ((*s != '+' && *s != '-') || !isdigit(s[1])) break; + } + if (j > 2) { // update kh_val() + int *q, y, z; + q = kh_val(hash, k) = (int*)calloc(j - 1, sizeof(int)); + q[0] = j - 2; z = j; y = 1; + for (j = 2; j < z; ++j) + q[y++] = atoi(str + fields[j]); + } + } + free(str); + } + free(list); free(fields); + return hash; +} + +static inline int printw(int c, FILE *fp) +{ + char buf[16]; + int l, x; + if (c == 0) return fputc('0', fp); + for (l = 0, x = c < 0? -c : c; x > 0; x /= 10) buf[l++] = x%10 + '0'; + if (c < 0) buf[l++] = '-'; + buf[l] = 0; + for (x = 0; x < l/2; ++x) { + int y = buf[x]; buf[x] = buf[l-1-x]; buf[l-1-x] = y; + } + fputs(buf, fp); + return 0; +} + +// an analogy to pileup_func() below +static int glt3_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pu, void *data) +{ + pu_data_t *d = (pu_data_t*)data; + bam_maqindel_ret_t *r = 0; + int rb, *proposed_indels = 0; + glf1_t *g; + glf3_t *g3; + + if (d->fai == 0) { + fprintf(pysamerr, "[glt3_func] reference sequence is required for generating GLT. Abort!\n"); + exit(1); + } + if (d->hash) { // only output a list of sites + khint_t k = kh_get(64, d->hash, (uint64_t)tid<<32|pos); + if (k == kh_end(d->hash)) return 0; + proposed_indels = kh_val(d->hash, k); + } + g3 = glf3_init1(); + if (d->fai && (int)tid != d->tid) { + if (d->ref) { // then write the end mark + g3->rtype = GLF3_RTYPE_END; + glf3_write1(d->fp_glf, g3); + } + glf3_ref_write(d->fp_glf, d->h->target_name[tid], d->h->target_len[tid]); // write reference + free(d->ref); + d->ref = fai_fetch(d->fai, d->h->target_name[tid], &d->len); + d->tid = tid; + d->last_pos = 0; + } + rb = (d->ref && (int)pos < d->len)? d->ref[pos] : 'N'; + g = bam_maqcns_glfgen(n, pu, bam_nt16_table[rb], d->c); + memcpy(g3, g, sizeof(glf1_t)); + g3->rtype = GLF3_RTYPE_SUB; + g3->offset = pos - d->last_pos; + d->last_pos = pos; + glf3_write1(d->fp_glf, g3); + if (pos < d->len) { + int m = (!d->max_depth || d->max_depth>n) ? n : d->max_depth; + if (proposed_indels) + 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); + } + if (r) { // then write indel line + int het = 3 * n, min; + min = het; + if (min > r->gl[0]) min = r->gl[0]; + if (min > r->gl[1]) min = r->gl[1]; + g3->ref_base = 0; + g3->rtype = GLF3_RTYPE_INDEL; + memset(g3->lk, 0, 10); + g3->lk[0] = r->gl[0] - min < 255? r->gl[0] - min : 255; + g3->lk[1] = r->gl[1] - min < 255? r->gl[1] - min : 255; + g3->lk[2] = het - min < 255? het - min : 255; + g3->offset = 0; + g3->indel_len[0] = r->indel1; + g3->indel_len[1] = r->indel2; + g3->min_lk = min < 255? min : 255; + g3->max_len = (abs(r->indel1) > abs(r->indel2)? abs(r->indel1) : abs(r->indel2)) + 1; + g3->indel_seq[0] = strdup(r->s[0]+1); + g3->indel_seq[1] = strdup(r->s[1]+1); + glf3_write1(d->fp_glf, g3); + bam_maqindel_ret_destroy(r); + } + free(g); + glf3_destroy1(g3); + return 0; +} + +static inline void pileup_seq(const bam_pileup1_t *p, int pos, int ref_len, const char *ref) +{ + int j; + if (p->is_head) { + putchar('^'); + putchar(p->b->core.qual > 93? 126 : p->b->core.qual + 33); + } + if (!p->is_del) { + int c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos)]; + if (ref) { + int rb = pos < ref_len? ref[pos] : 'N'; + if (c == '=' || bam_nt16_table[c] == bam_nt16_table[rb]) c = bam1_strand(p->b)? ',' : '.'; + else c = bam1_strand(p->b)? tolower(c) : toupper(c); + } else { + if (c == '=') c = bam1_strand(p->b)? ',' : '.'; + else c = bam1_strand(p->b)? tolower(c) : toupper(c); + } + putchar(c); + } else putchar(p->is_refskip? (bam1_strand(p->b)? '<' : '>') : '*'); + if (p->indel > 0) { + putchar('+'); printw(p->indel, stdout); + for (j = 1; j <= p->indel; ++j) { + int c = bam_nt16_rev_table[bam1_seqi(bam1_seq(p->b), p->qpos + j)]; + putchar(bam1_strand(p->b)? tolower(c) : toupper(c)); + } + } else if (p->indel < 0) { + printw(p->indel, stdout); + for (j = 1; j <= -p->indel; ++j) { + int c = (ref && (int)pos+j < ref_len)? ref[pos+j] : 'N'; + putchar(bam1_strand(p->b)? tolower(c) : toupper(c)); + } + } + if (p->is_tail) putchar('$'); +} + +static int pileup_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pu, void *data) +{ + pu_data_t *d = (pu_data_t*)data; + bam_maqindel_ret_t *r = 0; + int i, rb, rms_mapq = -1, *proposed_indels = 0; + uint64_t rms_aux; + uint32_t cns = 0; + + // if GLF is required, suppress -c completely + if (d->format & BAM_PLF_GLF) return glt3_func(tid, pos, n, pu, data); + // if d->hash is initialized, only output the sites in the hash table + if (d->hash) { + khint_t k = kh_get(64, d->hash, (uint64_t)tid<<32|pos); + if (k == kh_end(d->hash)) return 0; + proposed_indels = kh_val(d->hash, k); + } + // update d->ref if necessary + if (d->fai && (int)tid != d->tid) { + free(d->ref); + d->ref = faidx_fetch_seq(d->fai, d->h->target_name[tid], 0, 0x7fffffff, &d->len); + d->tid = tid; + } + rb = (d->ref && (int)pos < d->len)? d->ref[pos] : 'N'; + // when the indel-only mode is asked for, return if no reads mapped with indels + if (d->format & BAM_PLF_INDEL_ONLY) { + for (i = 0; i < n; ++i) + if (pu[i].indel != 0) break; + if (i == n) return 0; + } + // call the consensus and indel + if (d->format & BAM_PLF_CNS) { // call consensus + if (d->format & (BAM_PLF_RANBASE|BAM_PLF_1STBASE)) { // use a random base or the 1st base as the consensus call + const bam_pileup1_t *p = (d->format & BAM_PLF_1STBASE)? pu : pu + (int)(drand48() * n); + int q = bam1_qual(p->b)[p->qpos]; + int mapQ = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; + uint32_t b = bam1_seqi(bam1_seq(p->b), p->qpos); + cns = b<<28 | 0xf<<24 | mapQ<<16 | q<<8; + } else if (d->format & BAM_PLF_ALLBASE) { // collapse all bases + uint64_t rmsQ = 0; + uint32_t b = 0; + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pu + i; + int q = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; + b |= bam1_seqi(bam1_seq(p->b), p->qpos); + rmsQ += q * q; + } + rmsQ = (uint64_t)(sqrt((double)rmsQ / n) + .499); + cns = b<<28 | 0xf<<24 | rmsQ<<16 | 60<<8; + } else { + glf1_t *g = bam_maqcns_glfgen(n, pu, bam_nt16_table[rb], d->c); + cns = g->depth == 0? (0xfu<<28 | 0xf<<24) : glf2cns(g, (int)(d->c->q_r + .499)); + free(g); + } + } + if ((d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY)) && d->ref && pos < d->len) { // call indels + int m = (!d->max_depth || d->max_depth>n) ? n : d->max_depth; + 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)) { + if (!(bam_nt16_table[rb] != 15 && cns>>28 != 15 && cns>>28 != bam_nt16_table[rb])) { // not a SNP + if (!(r && (r->gt == 2 || strcmp(r->s[r->gt], "*")))) { // not an indel + if (r) bam_maqindel_ret_destroy(r); + return 0; + } + } + } + // print the first 3 columns + fputs(d->h->target_name[tid], stdout); putchar('\t'); + printw(pos+1, stdout); putchar('\t'); putchar(rb); putchar('\t'); + // print consensus information if required + if (d->format & BAM_PLF_CNS) { + putchar(bam_nt16_rev_table[cns>>28]); putchar('\t'); + printw(cns>>8&0xff, stdout); putchar('\t'); + printw(cns&0xff, stdout); putchar('\t'); + printw(cns>>16&0xff, stdout); putchar('\t'); + } + // print pileup sequences + printw(n, stdout); putchar('\t'); + for (i = 0; i < n; ++i) + pileup_seq(pu + i, pos, d->len, d->ref); + // finalize rms_mapq + if (d->format & BAM_PLF_CNS) { + for (i = rms_aux = 0; i < n; ++i) { + const bam_pileup1_t *p = pu + i; + int tmp = p->b->core.qual < d->c->cap_mapQ? p->b->core.qual : d->c->cap_mapQ; + rms_aux += tmp * tmp; + } + rms_aux = (uint64_t)(sqrt((double)rms_aux / n) + .499); + if (rms_mapq < 0) rms_mapq = rms_aux; + } + putchar('\t'); + // print quality + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pu + i; + int c = bam1_qual(p->b)[p->qpos] + 33; + if (c > 126) c = 126; + putchar(c); + } + if (d->format & BAM_PLF_2ND) { // print 2nd calls and qualities + const unsigned char *q; + putchar('\t'); + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pu + i; + q = bam_aux_get(p->b, "E2"); + putchar(q? q[p->qpos + 1] : 'N'); + } + putchar('\t'); + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pu + i; + q = bam_aux_get(p->b, "U2"); + putchar(q? q[p->qpos + 1] : '!'); + } + } + // print mapping quality if -s is flagged on the command line + if (d->format & BAM_PLF_SIMPLE) { + putchar('\t'); + for (i = 0; i < n; ++i) { + int c = pu[i].b->core.qual + 33; + if (c > 126) c = 126; + putchar(c); + } + } + // print read position + if (d->format & BAM_PLF_READPOS) { + putchar('\t'); + for (i = 0; i < n; ++i) { + int x = pu[i].qpos; + int l = pu[i].b->core.l_qseq; + printw(x < l/2? x+1 : -((l-1)-x+1), stdout); putchar(','); + } + } + putchar('\n'); + // print the indel line if r has been calculated. This only happens if: + // a) -c or -i are flagged, AND b) the reference sequence is available + if (r) { + printf("%s\t%d\t*\t", d->h->target_name[tid], pos + 1); + if (r->gt < 2) printf("%s/%s\t", r->s[r->gt], r->s[r->gt]); + else printf("%s/%s\t", r->s[0], r->s[1]); + printf("%d\t%d\t", r->q_cns, r->q_ref); + printf("%d\t%d\t", rms_mapq, n); + printf("%s\t%s\t", r->s[0], r->s[1]); + //printf("%d\t%d\t", r->gl[0], r->gl[1]); + printf("%d\t%d\t%d\t", r->cnt1, r->cnt2, r->cnt_anti); + printf("%d\t%d\n", r->cnt_ref, r->cnt_ambi); + bam_maqindel_ret_destroy(r); + } + return 0; +} + +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->c = bam_maqcns_init(); + d->c->errmod = BAM_ERRMOD_MAQ2; // change the default model + d->ido = bam_maqindel_opt_init(); + while ((c = getopt(argc, argv, "st:f:cT:N:r:l:d:im:gI:G:vM:S2aR:PAQ:C:B")) >= 0) { + switch (c) { + case 'Q': d->c->min_baseQ = atoi(optarg); break; + case 'C': d->capQ_thres = atoi(optarg); break; + case 'B': d->format |= BAM_PLF_NOBAQ; break; + case 'a': d->c->errmod = BAM_ERRMOD_SOAP; break; + case 'A': d->c->errmod = BAM_ERRMOD_MAQ; break; + case 's': d->format |= BAM_PLF_SIMPLE; break; + case 't': fn_list = strdup(optarg); break; + case 'l': fn_pos = strdup(optarg); break; + case 'f': fn_fa = strdup(optarg); break; + case 'T': d->c->theta = atof(optarg); break; + case 'N': d->c->n_hap = atoi(optarg); break; + case 'r': d->c->het_rate = atof(optarg); d->ido->r_snp = d->c->het_rate; break; + case 'M': d->c->cap_mapQ = atoi(optarg); break; + case 'd': d->max_depth = atoi(optarg); break; + case 'c': d->format |= BAM_PLF_CNS; break; + case 'i': d->format |= BAM_PLF_INDEL_ONLY; break; + case 'v': d->format |= BAM_PLF_VAR_ONLY; break; + case 'm': d->mask = strtol(optarg, 0, 0); break; + case 'g': d->format |= BAM_PLF_GLF; break; + case '2': d->format |= BAM_PLF_2ND; break; + case 'P': d->format |= BAM_PLF_READPOS; break; + case 'I': d->ido->q_indel = atoi(optarg); break; + case 'G': d->ido->r_indel = atof(optarg); break; + case 'S': is_SAM = 1; break; + case 'R': + if (strcmp(optarg, "random") == 0) d->format |= BAM_PLF_RANBASE; + else if (strcmp(optarg, "first") == 0) d->format |= BAM_PLF_1STBASE; + else if (strcmp(optarg, "all") == 0) d->format |= BAM_PLF_ALLBASE; + else fprintf(pysamerr, "[bam_pileup] unrecognized -R\n"); + break; + default: fprintf(pysamerr, "Unrecognizd option '-%c'.\n", c); return 1; + } + } + if (d->c->errmod != BAM_ERRMOD_MAQ2) d->c->theta += 0.02; + if (d->c->theta > 1.0) d->c->theta = 1.0; + if (fn_list) is_SAM = 1; + if (optind == argc) { + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: samtools pileup [options] |\n\n"); + fprintf(pysamerr, "Option: -s simple (yet incomplete) pileup format\n"); + fprintf(pysamerr, " -S the input is in SAM\n"); + fprintf(pysamerr, " -B disable BAQ computation\n"); + fprintf(pysamerr, " -A use the original MAQ model for SNP calling (DEPRECATED)\n"); + fprintf(pysamerr, " -2 output the 2nd best call and quality\n"); + fprintf(pysamerr, " -i only show lines/consensus with indels\n"); + fprintf(pysamerr, " -Q INT min base quality (possibly capped by BAQ) [%d]\n", d->c->min_baseQ); + fprintf(pysamerr, " -C INT coefficient for adjusting mapQ of poor mappings [%d]\n", d->capQ_thres); + fprintf(pysamerr, " -m INT filtering reads with bits in INT [0x%x]\n", d->mask); + fprintf(pysamerr, " -M INT cap mapping quality at INT [%d]\n", d->c->cap_mapQ); + fprintf(pysamerr, " -d INT limit maximum depth for indels [%d]\n", d->max_depth); + fprintf(pysamerr, " -t FILE list of reference sequences (force -S)\n"); + fprintf(pysamerr, " -l FILE list of sites at which pileup is output\n"); + fprintf(pysamerr, " -f FILE reference sequence in the FASTA format\n\n"); + fprintf(pysamerr, " -c compute the consensus sequence\n"); + fprintf(pysamerr, " -v print variants only (for -c)\n"); + fprintf(pysamerr, " -g output in the GLFv3 format (DEPRECATED)\n"); + fprintf(pysamerr, " -T FLOAT theta in maq consensus calling model (for -c) [%.4g]\n", d->c->theta); + fprintf(pysamerr, " -N INT number of haplotypes in the sample (for -c) [%d]\n", d->c->n_hap); + fprintf(pysamerr, " -r FLOAT prior of a difference between two haplotypes (for -c) [%.4g]\n", d->c->het_rate); + 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; + } + if (d->format & (BAM_PLF_RANBASE|BAM_PLF_1STBASE|BAM_PLF_ALLBASE)) d->format |= BAM_PLF_CNS; + if (fn_fa) d->fai = fai_load(fn_fa); + if (d->format & (BAM_PLF_CNS|BAM_PLF_GLF)) bam_maqcns_prepare(d->c); // consensus calling + if (d->format & BAM_PLF_GLF) { // for glf output + glf3_header_t *h; + h = glf3_header_init(); + d->fp_glf = bgzf_fdopen(fileno(stdout), "w"); + glf3_header_write(d->fp_glf, h); + glf3_header_destroy(h); + } + if (d->fai == 0 && (d->format & (BAM_PLF_CNS|BAM_PLF_INDEL_ONLY))) + fprintf(pysamerr, "[bam_pileup] indels will not be called when -f is absent.\n"); + if (fn_fa && is_SAM && fn_list == 0) fn_list = samfaipath(fn_fa); + + { + samfile_t *fp; + fp = is_SAM? samopen(argv[optind], "r", fn_list) : samopen(argv[optind], "rb", 0); + if (fp == 0 || fp->header == 0) { + fprintf(pysamerr, "[bam_pileup] fail to read the header: non-exisiting file or wrong format.\n"); + return 1; + } + d->h = fp->header; + if (fn_pos) d->hash = load_pos(fn_pos, d->h); + { // run pileup + extern int bam_prob_realn(bam1_t *b, const char *ref); + extern int bam_cap_mapQ(bam1_t *b, char *ref, int thres); + bam1_t *b; + int ret, tid, pos, n_plp; + bam_plp_t iter; + const bam_pileup1_t *plp; + b = bam_init1(); + iter = bam_plp_init(0, 0); + bam_plp_set_mask(iter, d->mask); + while ((ret = samread(fp, b)) >= 0) { + int skip = 0; + if ((int)b->core.tid < 0) break; + // update d->ref if necessary + if (d->fai && (int)b->core.tid != d->tid) { + free(d->ref); + d->ref = faidx_fetch_seq(d->fai, d->h->target_name[b->core.tid], 0, 0x7fffffff, &d->len); + d->tid = b->core.tid; + } + if (d->ref && (d->format&BAM_PLF_CNS) && !(d->format&BAM_PLF_NOBAQ)) bam_prob_realn(b, d->ref); + if (d->ref && (d->format&BAM_PLF_CNS) && d->capQ_thres > 10) { + int q = bam_cap_mapQ(b, d->ref, d->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 ((d->format&BAM_PLF_CNS) && (b->core.flag&1) && !(b->core.flag&2)) skip = 1; + if (skip) continue; + bam_plp_push(iter, b); + while ((plp = bam_plp_next(iter, &tid, &pos, &n_plp)) != 0) + pileup_func(tid, pos, n_plp, plp, d); + } + bam_plp_push(iter, 0); + while ((plp = bam_plp_next(iter, &tid, &pos, &n_plp)) != 0) + pileup_func(tid, pos, n_plp, plp, d); + bam_plp_destroy(iter); + bam_destroy1(b); + } + samclose(fp); // d->h will be destroyed here + } + + // free + if (d->format & BAM_PLF_GLF) bgzf_close(d->fp_glf); + if (fn_pos) { // free the hash table + khint_t k; + for (k = kh_begin(d->hash); k < kh_end(d->hash); ++k) + if (kh_exist(d->hash, k)) free(kh_val(d->hash, k)); + kh_destroy(64, d->hash); + } + free(fn_pos); free(fn_list); free(fn_fa); + if (d->fai) fai_destroy(d->fai); + bam_maqcns_destroy(d->c); + free(d->ido); free(d->ref); free(d); + return 0; +} + +/*********** + * mpileup * + ***********/ + +#include +#include "bam2bcf.h" +#include "sample.h" + +#define MPLP_GLF 0x10 +#define MPLP_NO_COMP 0x20 +#define MPLP_NO_ORPHAN 0x40 +#define MPLP_REALN 0x80 +#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, max_indel_depth; + int openQ, extQ, tandemQ, min_support; // for indels + double min_frac; // for indels + char *reg, *pl_list; + faidx_t *fai; + void *bed, *rghash; +} mplp_conf_t; + +typedef struct { + bamFile fp; + bam_iter_t iter; + bam_header_t *h; + int ref_id; + char *ref; + const mplp_conf_t *conf; +} mplp_aux_t; + +typedef struct { + int n; + int *n_plp, *m_plp; + bam_pileup1_t **plp; +} mplp_pileup_t; + +static int mplp_func(void *data, bam1_t *b) +{ + extern int bam_realn(bam1_t *b, const char *ref); + extern int bam_prob_realn_core(bam1_t *b, const char *ref, int); + extern int bam_cap_mapQ(bam1_t *b, char *ref, int thres); + mplp_aux_t *ma = (mplp_aux_t*)data; + int ret, skip = 0; + do { + 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->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.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; +} + +static void group_smpl(mplp_pileup_t *m, bam_sample_t *sm, kstring_t *buf, + int n, char *const*fn, int *n_plp, const bam_pileup1_t **plp) +{ + int i, j; + memset(m->n_plp, 0, m->n * sizeof(int)); + for (i = 0; i < n; ++i) { + for (j = 0; j < n_plp[i]; ++j) { + const bam_pileup1_t *p = plp[i] + j; + uint8_t *q; + int id = -1; + 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); + 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]); + } + m->plp[id][m->n_plp[id]++] = *p; + } + } +} + +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, max_indel_depth; + const bam_pileup1_t **plp; + bam_mplp_t iter; + bam_header_t *h = 0; + char *ref; + void *rghash = 0; + + bcf_callaux_t *bca = 0; + bcf_callret1_t *bcr = 0; + bcf_call_t bc; + bcf_t *bp = 0; + bcf_hdr_t *bh = 0; + + bam_sample_t *sm = 0; + kstring_t buf; + mplp_pileup_t gplp; + + memset(&gplp, 0, sizeof(mplp_pileup_t)); + memset(&buf, 0, sizeof(kstring_t)); + memset(&bc, 0, sizeof(bcf_call_t)); + data = calloc(n, sizeof(void*)); + plp = calloc(n, sizeof(void*)); + n_plp = calloc(n, sizeof(int*)); + sm = bam_smpl_init(); + + // read the header and initialize data + for (i = 0; i < n; ++i) { + bam_header_t *h_tmp; + data[i] = calloc(1, sizeof(mplp_aux_t)); + 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) { + int beg, end; + bam_index_t *idx; + idx = bam_index_load(fn[i]); + if (idx == 0) { + fprintf(pysamerr, "[%s] fail to load index for %d-th input.\n", __func__, i+1); + exit(1); + } + if (bam_parse_region(h_tmp, conf->reg, &tid, &beg, &end) < 0) { + fprintf(pysamerr, "[%s] malformatted region or wrong seqname for %d-th input.\n", __func__, i+1); + exit(1); + } + if (i == 0) beg0 = beg, end0 = end; + data[i]->iter = bam_iter_query(idx, tid, beg, end); + bam_index_destroy(idx); + } + if (i == 0) h = h_tmp; + else { + // FIXME: to check consistency + bam_header_destroy(h_tmp); + } + } + gplp.n = sm->n; + gplp.n_plp = calloc(sm->n, sizeof(int)); + gplp.m_plp = calloc(sm->n, sizeof(int)); + gplp.plp = calloc(sm->n, sizeof(void*)); + + fprintf(pysamerr, "[%s] %d samples in %d input files\n", __func__, sm->n, n); + // write the VCF header + if (conf->flag & MPLP_GLF) { + kstring_t s; + bh = calloc(1, sizeof(bcf_hdr_t)); + s.l = s.m = 0; s.s = 0; + bp = bcf_open("-", (conf->flag&MPLP_NO_COMP)? "wu" : "w"); + for (i = 0; i < h->n_targets; ++i) { + kputs(h->target_name[i], &s); + kputc('\0', &s); + } + bh->l_nm = s.l; + bh->name = malloc(s.l); + memcpy(bh->name, s.s, s.l); + s.l = 0; + for (i = 0; i < sm->n; ++i) { + kputs(sm->smpl[i], &s); kputc('\0', &s); + } + bh->l_smpl = s.l; + bh->sname = malloc(s.l); + memcpy(bh->sname, s.s, s.l); + 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); + bca = bcf_call_init(-1., conf->min_baseQ); + 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); + max_depth = conf->max_depth; + if (max_depth * sm->n > 1<<20) + 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-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 (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); + for (i = 0; i < n; ++i) data[i]->ref = ref, data[i]->ref_id = tid; + ref_tid = tid; + } + if (conf->flag & MPLP_GLF) { + 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]; + for (i = 0; i < gplp.n; ++i) + bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], ref16, bca, bcr + i); + bcf_call_combine(gplp.n, bcr, ref16, &bc); + bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0, + (conf->flag&MPLP_FMT_SP), 0, 0); + bcf_write(bp, bh, b); + bcf_destroy(b); + // call indels + 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) { + b = calloc(1, sizeof(bcf1_t)); + bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0, + (conf->flag&MPLP_FMT_SP), bca, ref); + bcf_write(bp, bh, b); + bcf_destroy(b); + } + } + } else { + printf("%s\t%d\t%c", h->target_name[tid], pos + 1, (ref && pos < ref_len)? ref[pos] : 'N'); + for (i = 0; i < n; ++i) { + int j; + printf("\t%d\t", n_plp[i]); + if (n_plp[i] == 0) printf("*\t*"); + else { + for (j = 0; j < n_plp[i]; ++j) + pileup_seq(plp[i] + j, pos, ref_len, ref); + putchar('\t'); + for (j = 0; j < n_plp[i]; ++j) { + const bam_pileup1_t *p = plp[i] + j; + int c = bam1_qual(p->b)[p->qpos] + 33; + if (c > 126) c = 126; + putchar(c); + } + } + } + putchar('\n'); + } + } + + bcf_close(bp); + bam_smpl_destroy(sm); free(buf.s); + 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); + bcf_hdr_destroy(bh); bcf_call_destroy(bca); free(bc.PL); free(bcr); + bam_mplp_destroy(iter); + 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(plp); free(ref); free(n_plp); + return 0; +} + +#define MAX_PATH_LEN 1024 +static int read_file_list(const char *file_list,int *n,char **argv[]) +{ + char buf[MAX_PATH_LEN]; + int len, nfiles; + char **files; + + FILE *fh = fopen(file_list,"r"); + if ( !fh ) + { + fprintf(pysamerr,"%s: %s\n", file_list,strerror(errno)); + return 1; + } + + // Speed is not an issue here, determine the number of files by reading the file twice + nfiles = 0; + while ( fgets(buf,MAX_PATH_LEN,fh) ) nfiles++; + + if ( fseek(fh, 0L, SEEK_SET) ) + { + fprintf(pysamerr,"%s: %s\n", file_list,strerror(errno)); + return 1; + } + + files = calloc(nfiles,sizeof(char*)); + nfiles = 0; + while ( fgets(buf,MAX_PATH_LEN,fh) ) + { + len = strlen(buf); + while ( len>0 && isspace(buf[len-1]) ) len--; + if ( !len ) continue; + + files[nfiles] = malloc(sizeof(char)*(len+1)); + strncpy(files[nfiles],buf,len); + files[nfiles][len] = 0; + nfiles++; + } + fclose(fh); + if ( !nfiles ) + { + fprintf(pysamerr,"No files read from %s\n", file_list); + return 1; + } + *argv = files; + *n = nfiles; + return 0; +} +#undef MAX_PATH_LEN + +int bam_mpileup(int argc, char *argv[]) +{ + int c; + const char *file_list = NULL; + char **fn = NULL; + 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_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, "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); + if (mplp.fai == 0) return 1; + break; + case 'd': mplp.max_depth = atoi(optarg); break; + case 'r': mplp.reg = 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; 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; + case 'Q': mplp.min_baseQ = atoi(optarg); break; + case 'b': file_list = optarg; break; + 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, "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 ( read_file_list(file_list,&nfiles,&fn) ) return 1; + mpileup(&mplp,nfiles,fn); + for (c=0; c -#include -#include "bgzf.h" -#include "bam.h" - -#define BUF_SIZE 0x10000 - -int bam_reheader(BGZF *in, const bam_header_t *h, int fd) -{ - BGZF *fp; - bam_header_t *old; - int len; - uint8_t *buf; - if (in->open_mode != 'r') return -1; - buf = malloc(BUF_SIZE); - old = bam_header_read(in); - fp = bgzf_fdopen(fd, "w"); - bam_header_write(fp, h); - if (in->block_offset < in->block_length) { - bgzf_write(fp, in->uncompressed_block + in->block_offset, in->block_length - in->block_offset); - bgzf_flush(fp); - } -#ifdef _USE_KNETFILE - while ((len = knet_read(in->x.fpr, buf, BUF_SIZE)) > 0) -#else - while (!feof(in->file) && (len = fread(buf, 1, BUF_SIZE, in->file)) > 0) -#endif - fwrite(buf, 1, len, fp->x.fpw); - free(buf); - fp->block_offset = in->block_offset = 0; - bgzf_close(fp); - return 0; -} - -int main_reheader(int argc, char *argv[]) -{ - bam_header_t *h; - BGZF *in; - if (argc != 3) { - fprintf(stderr, "Usage: samtools reheader \n"); - return 1; - } - { // read the header - tamFile fph = sam_open(argv[1]); - if (fph == 0) { - fprintf(stderr, "[%s] fail to read the header from %s.\n", __func__, argv[1]); - return 1; - } - h = sam_header_read(fph); - sam_close(fph); - } - in = strcmp(argv[2], "-")? bam_open(argv[2], "r") : bam_dopen(fileno(stdin), "r"); - if (in == 0) { - fprintf(stderr, "[%s] fail to open file %s.\n", __func__, argv[2]); - return 1; - } - bam_reheader(in, h, fileno(stdout)); - bgzf_close(in); - return 0; -} diff --git a/samtools/bam_rmdup.c b/samtools/bam_rmdup.c.pysam.c similarity index 86% rename from samtools/bam_rmdup.c rename to samtools/bam_rmdup.c.pysam.c index f0d2b5d..2d5a718 100644 --- a/samtools/bam_rmdup.c +++ b/samtools/bam_rmdup.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -110,7 +112,7 @@ void bam_rmdup_core(samfile_t *in, samfile_t *out) if (c->tid != last_tid) { clear_best(aux, 0); if (kh_size(del_set)) { // check - fprintf(stderr, "[bam_rmdup_core] %llu unmatched pairs\n", (long long)kh_size(del_set)); + fprintf(pysamerr, "[bam_rmdup_core] %llu unmatched pairs\n", (long long)kh_size(del_set)); clear_del_set(del_set); } if ((int)c->tid == -1) { // append unmapped reads @@ -119,7 +121,7 @@ void bam_rmdup_core(samfile_t *in, samfile_t *out) break; } last_tid = c->tid; - fprintf(stderr, "[bam_rmdup_core] processing reference %s...\n", in->header->target_name[c->tid]); + fprintf(pysamerr, "[bam_rmdup_core] processing reference %s...\n", in->header->target_name[c->tid]); } } if (!(c->flag&BAM_FPAIRED) || (c->flag&(BAM_FUNMAP|BAM_FMUNMAP)) || (c->mtid >= 0 && c->tid != c->mtid)) { @@ -141,7 +143,7 @@ void bam_rmdup_core(samfile_t *in, samfile_t *out) bam_copy1(p, b); // replaced as b } else kh_put(name, del_set, strdup(bam1_qname(b)), &ret); // b will be removed if (ret == 0) - fprintf(stderr, "[bam_rmdup_core] inconsistent BAM file for pair '%s'. Continue anyway.\n", bam1_qname(b)); + fprintf(pysamerr, "[bam_rmdup_core] inconsistent BAM file for pair '%s'. Continue anyway.\n", bam1_qname(b)); } else { // not found in best_hash kh_val(q->best_hash, k) = bam_dup1(b); stack_insert(&stack, kh_val(q->best_hash, k)); @@ -160,7 +162,7 @@ void bam_rmdup_core(samfile_t *in, samfile_t *out) if (kh_exist(aux, k)) { lib_aux_t *q = &kh_val(aux, k); dump_best(&stack, out); - fprintf(stderr, "[bam_rmdup_core] %lld / %lld = %.4lf in library '%s'\n", (long long)q->n_removed, + fprintf(pysamerr, "[bam_rmdup_core] %lld / %lld = %.4lf in library '%s'\n", (long long)q->n_removed, (long long)q->n_checked, (double)q->n_removed/q->n_checked, kh_key(aux, k)); kh_destroy(pos, q->best_hash); free((char*)kh_key(aux, k)); @@ -187,16 +189,16 @@ int bam_rmdup(int argc, char *argv[]) } } if (optind + 2 > argc) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: samtools rmdup [-sS] \n\n"); - fprintf(stderr, "Option: -s rmdup for SE reads\n"); - fprintf(stderr, " -S treat PE reads as SE in rmdup (force -s)\n\n"); + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: samtools rmdup [-sS] \n\n"); + fprintf(pysamerr, "Option: -s rmdup for SE reads\n"); + fprintf(pysamerr, " -S treat PE reads as SE in rmdup (force -s)\n\n"); return 1; } in = samopen(argv[optind], "rb", 0); out = samopen(argv[optind+1], "wb", in->header); if (in == 0 || out == 0) { - fprintf(stderr, "[bam_rmdup] fail to read/write input files\n"); + fprintf(pysamerr, "[bam_rmdup] fail to read/write input files\n"); return 1; } if (is_se) bam_rmdupse_core(in, out, force_se); diff --git a/samtools/bam_rmdupse.c b/samtools/bam_rmdupse.c.pysam.c similarity index 96% rename from samtools/bam_rmdupse.c rename to samtools/bam_rmdupse.c.pysam.c index e7dbdc7..f2cd8b7 100644 --- a/samtools/bam_rmdupse.c +++ b/samtools/bam_rmdupse.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include "sam.h" #include "khash.h" @@ -147,7 +149,7 @@ void bam_rmdupse_core(samfile_t *in, samfile_t *out, int force_se) for (k = kh_begin(aux); k != kh_end(aux); ++k) { if (kh_exist(aux, k)) { lib_aux_t *q = &kh_val(aux, k); - fprintf(stderr, "[bam_rmdupse_core] %lld / %lld = %.4lf in library '%s'\n", (long long)q->n_removed, + fprintf(pysamerr, "[bam_rmdupse_core] %lld / %lld = %.4lf in library '%s'\n", (long long)q->n_removed, (long long)q->n_checked, (double)q->n_removed/q->n_checked, kh_key(aux, k)); kh_destroy(best, q->left); kh_destroy(best, q->rght); free((char*)kh_key(aux, k)); diff --git a/samtools/bam_sort.c b/samtools/bam_sort.c.pysam.c similarity index 52% rename from samtools/bam_sort.c rename to samtools/bam_sort.c.pysam.c index 12b1b54..8737edc 100644 --- a/samtools/bam_sort.c +++ b/samtools/bam_sort.c.pysam.c @@ -1,6 +1,9 @@ +#include "pysam.h" + #include #include #include +#include #include #include #include @@ -51,6 +54,14 @@ static inline int heap_lt(const heap1_t a, const heap1_t b) KSORT_INIT(heap, heap1_t, heap_lt) +static void swap_header_targets(bam_header_t *h1, bam_header_t *h2) +{ + bam_header_t t; + t.n_targets = h1->n_targets, h1->n_targets = h2->n_targets, h2->n_targets = t.n_targets; + t.target_name = h1->target_name, h1->target_name = h2->target_name, h2->target_name = t.target_name; + t.target_len = h1->target_len, h1->target_len = h2->target_len, h2->target_len = t.target_len; +} + static void swap_header_text(bam_header_t *h1, bam_header_t *h2) { int tempi; @@ -59,6 +70,11 @@ static void swap_header_text(bam_header_t *h1, bam_header_t *h2) temps = h1->text, h1->text = h2->text, h2->text = temps; } +#define MERGE_RG 1 +#define MERGE_UNCOMP 2 +#define MERGE_LEVEL1 4 +#define MERGE_FORCE 8 + /*! @abstract Merge multiple sorted BAM. @param is_by_qname whether to sort by query name @@ -71,7 +87,8 @@ static void swap_header_text(bam_header_t *h1, bam_header_t *h2) @discussion Padding information may NOT correctly maintained. This function is NOT thread safe. */ -void bam_merge_core(int by_qname, const char *out, const char *headers, int n, char * const *fn, int add_RG) +int bam_merge_core(int by_qname, const char *out, const char *headers, int n, char * const *fn, + int flag, const char *reg) { bamFile fpout, *fp; heap1_t *heap; @@ -80,22 +97,25 @@ void bam_merge_core(int by_qname, const char *out, const char *headers, int n, c int i, j, *RG_len = 0; uint64_t idx = 0; char **RG = 0; + bam_iter_t *iter = 0; if (headers) { tamFile fpheaders = sam_open(headers); if (fpheaders == 0) { - fprintf(stderr, "[bam_merge_core] Cannot open file `%s'. Continue anyway.\n", headers); - } else { - hheaders = sam_header_read(fpheaders); - sam_close(fpheaders); + const char *message = strerror(errno); + fprintf(pysamerr, "[bam_merge_core] cannot open '%s': %s\n", headers, message); + return -1; } + hheaders = sam_header_read(fpheaders); + sam_close(fpheaders); } g_is_by_qname = by_qname; fp = (bamFile*)calloc(n, sizeof(bamFile)); heap = (heap1_t*)calloc(n, sizeof(heap1_t)); + iter = (bam_iter_t*)calloc(n, sizeof(bam_iter_t)); // prepare RG tag - if (add_RG) { + if (flag & MERGE_RG) { RG = (char**)calloc(n, sizeof(void*)); RG_len = (int*)calloc(n, sizeof(int)); for (i = 0; i != n; ++i) { @@ -111,114 +131,172 @@ void bam_merge_core(int by_qname, const char *out, const char *headers, int n, c } // read the first for (i = 0; i != n; ++i) { - heap1_t *h; bam_header_t *hin; fp[i] = bam_open(fn[i], "r"); if (fp[i] == 0) { int j; - fprintf(stderr, "[bam_merge_core] fail to open file %s\n", fn[i]); + fprintf(pysamerr, "[bam_merge_core] fail to open file %s\n", fn[i]); for (j = 0; j < i; ++j) bam_close(fp[j]); free(fp); free(heap); // FIXME: possible memory leak - return; + return -1; } hin = bam_header_read(fp[i]); - if (i == 0) { // the first SAM + if (i == 0) { // the first BAM hout = hin; - if (hheaders) { - // If the text headers to be swapped in include any @SQ headers, - // check that they are consistent with the existing binary list - // of reference information. - if (hheaders->n_targets > 0) { - if (hout->n_targets != hheaders->n_targets) - fprintf(stderr, "[bam_merge_core] number of @SQ headers in `%s' differs from number of target sequences", headers); - for (j = 0; j < hout->n_targets; ++j) - if (strcmp(hout->target_name[j], hheaders->target_name[j]) != 0) - fprintf(stderr, "[bam_merge_core] @SQ header '%s' in '%s' differs from target sequence", hheaders->target_name[j], headers); - } - swap_header_text(hout, hheaders); - bam_header_destroy(hheaders); - hheaders = NULL; - } } else { // validate multiple baf - if (hout->n_targets != hin->n_targets) { - fprintf(stderr, "[bam_merge_core] file '%s' has different number of target sequences. Abort!\n", fn[i]); - exit(1); - } - for (j = 0; j < hout->n_targets; ++j) { - if (strcmp(hout->target_name[j], hin->target_name[j])) { - fprintf(stderr, "[bam_merge_core] different target sequence name: '%s' != '%s' in file '%s'. Abort!\n", + int min_n_targets = hout->n_targets; + if (hin->n_targets < min_n_targets) min_n_targets = hin->n_targets; + + for (j = 0; j < min_n_targets; ++j) + if (strcmp(hout->target_name[j], hin->target_name[j]) != 0) { + fprintf(pysamerr, "[bam_merge_core] different target sequence name: '%s' != '%s' in file '%s'\n", hout->target_name[j], hin->target_name[j], fn[i]); - exit(1); + return -1; } + + // If this input file has additional target reference sequences, + // add them to the headers to be output + if (hin->n_targets > hout->n_targets) { + swap_header_targets(hout, hin); + // FIXME Possibly we should also create @SQ text headers + // for the newly added reference sequences } + bam_header_destroy(hin); } - h = heap + i; + } + + if (hheaders) { + // If the text headers to be swapped in include any @SQ headers, + // check that they are consistent with the existing binary list + // of reference information. + if (hheaders->n_targets > 0) { + if (hout->n_targets != hheaders->n_targets) { + fprintf(pysamerr, "[bam_merge_core] number of @SQ headers in '%s' differs from number of target sequences\n", headers); + if (!reg) return -1; + } + for (j = 0; j < hout->n_targets; ++j) + if (strcmp(hout->target_name[j], hheaders->target_name[j]) != 0) { + fprintf(pysamerr, "[bam_merge_core] @SQ header '%s' in '%s' differs from target sequence\n", hheaders->target_name[j], headers); + if (!reg) return -1; + } + } + + swap_header_text(hout, hheaders); + bam_header_destroy(hheaders); + } + + if (reg) { + int tid, beg, end; + if (bam_parse_region(hout, reg, &tid, &beg, &end) < 0) { + fprintf(pysamerr, "[%s] Malformated region string or undefined reference name\n", __func__); + return -1; + } + for (i = 0; i < n; ++i) { + bam_index_t *idx; + idx = bam_index_load(fn[i]); + iter[i] = bam_iter_query(idx, tid, beg, end); + bam_index_destroy(idx); + } + } + + for (i = 0; i < n; ++i) { + heap1_t *h = heap + i; h->i = i; h->b = (bam1_t*)calloc(1, sizeof(bam1_t)); - if (bam_read1(fp[i], h->b) >= 0) { - h->pos = ((uint64_t)h->b->core.tid<<32) | (uint32_t)h->b->core.pos<<1 | bam1_strand(h->b); + if (bam_iter_read(fp[i], iter[i], h->b) >= 0) { + 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; } - fpout = strcmp(out, "-")? bam_open(out, "w") : bam_dopen(fileno(stdout), "w"); - assert(fpout); + 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; + } bam_header_write(fpout, hout); bam_header_destroy(hout); ks_heapmake(heap, n, heap); while (heap->pos != HEAP_EMPTY) { bam1_t *b = heap->b; - if (add_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_read1(fp[heap->i], b)) >= 0) { - heap->pos = ((uint64_t)b->core.tid<<32) | (uint32_t)b->core.pos<<1 | bam1_strand(b); + if ((j = bam_iter_read(fp[heap->i], iter[heap->i], b)) >= 0) { + 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; free(heap->b->data); free(heap->b); heap->b = 0; - } else fprintf(stderr, "[bam_merge_core] '%s' is truncated. Continue anyway.\n", fn[heap->i]); + } else fprintf(pysamerr, "[bam_merge_core] '%s' is truncated. Continue anyway.\n", fn[heap->i]); ks_heapadjust(heap, 0, n, heap); } - if (add_RG) { + if (flag & MERGE_RG) { for (i = 0; i != n; ++i) free(RG[i]); free(RG); free(RG_len); } - for (i = 0; i != n; ++i) bam_close(fp[i]); + for (i = 0; i != n; ++i) { + bam_iter_destroy(iter[i]); + bam_close(fp[i]); + } bam_close(fpout); - free(fp); free(heap); + free(fp); free(heap); free(iter); + return 0; } + int bam_merge(int argc, char *argv[]) { - int c, is_by_qname = 0, add_RG = 0; - char *fn_headers = NULL; + int c, is_by_qname = 0, flag = 0, ret = 0; + char *fn_headers = NULL, *reg = 0; - while ((c = getopt(argc, argv, "h:nr")) >= 0) { + while ((c = getopt(argc, argv, "h:nru1R:f")) >= 0) { switch (c) { - case 'r': add_RG = 1; break; + 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; } } if (optind + 2 >= argc) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: samtools merge [-nr] [-h inh.sam] [...]\n\n"); - fprintf(stderr, "Options: -n sort by read names\n"); - fprintf(stderr, " -r attach RG tag (inferred from file names)\n"); - fprintf(stderr, " -h FILE copy the header in FILE to [in1.bam]\n\n"); - fprintf(stderr, "Note: Samtools' merge does not reconstruct the @RG dictionary in the header. Users\n"); - fprintf(stderr, " must provide the correct header with -h, or uses Picard which properly maintains\n"); - fprintf(stderr, " the header dictionary in merging.\n\n"); + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: samtools merge [-nr] [-h inh.sam] [...]\n\n"); + 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 [in1.bam]\n\n"); + fprintf(pysamerr, "Note: Samtools' merge does not reconstruct the @RG dictionary in the header. Users\n"); + fprintf(pysamerr, " must provide the correct header with -h, or uses Picard which properly maintains\n"); + fprintf(pysamerr, " the header dictionary in merging.\n\n"); return 1; } - bam_merge_core(is_by_qname, argv[optind], fn_headers, argc - optind - 1, argv + optind + 1, add_RG); + 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); - return 0; + return ret; } typedef bam1_t *bam1_p; @@ -227,23 +305,28 @@ 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(stderr, "[sort_blocks] fail to create file %s.\n", name); + fprintf(pysamerr, "[sort_blocks] fail to create file %s.\n", name); free(name); // FIXME: possible memory leak return; @@ -281,7 +364,7 @@ void bam_sort_core_ext(int is_by_qname, const char *fn, const char *prefix, size n = k = 0; mem = 0; fp = strcmp(fn, "-")? bam_open(fn, "r") : bam_dopen(fileno(stdin), "r"); if (fp == 0) { - fprintf(stderr, "[bam_sort_core] fail to open file %s\n", fn); + fprintf(pysamerr, "[bam_sort_core] fail to open file %s\n", fn); return; } header = bam_header_read(fp); @@ -299,11 +382,11 @@ void bam_sort_core_ext(int is_by_qname, const char *fn, const char *prefix, size } } if (ret != -1) - fprintf(stderr, "[bam_sort_core] truncated file. Continue anyway.\n"); + fprintf(pysamerr, "[bam_sort_core] truncated file. Continue anyway.\n"); if (n == 0) sort_blocks(-1, k, buf, prefix, header, is_stdout); else { // then merge char **fns, *fnout; - fprintf(stderr, "[bam_sort_core] merging from %d files...\n", n+1); + fprintf(pysamerr, "[bam_sort_core] merging from %d files...\n", n+1); sort_blocks(n++, k, buf, prefix, header, 0); fnout = (char*)calloc(strlen(prefix) + 20, 1); if (is_stdout) sprintf(fnout, "-"); @@ -313,7 +396,7 @@ void bam_sort_core_ext(int is_by_qname, const char *fn, const char *prefix, size fns[i] = (char*)calloc(strlen(prefix) + 20, 1); sprintf(fns[i], "%s.%.4d.bam", prefix, i); } - bam_merge_core(is_by_qname, fnout, 0, n, fns, 0); + bam_merge_core(is_by_qname, fnout, 0, n, fns, 0, 0); free(fnout); for (i = 0; i < n; ++i) { unlink(fns[i]); @@ -349,7 +432,7 @@ int bam_sort(int argc, char *argv[]) } } if (optind + 2 > argc) { - fprintf(stderr, "Usage: samtools sort [-on] [-m ] \n"); + fprintf(pysamerr, "Usage: samtools sort [-on] [-m ] \n"); return 1; } bam_sort_core_ext(is_by_qname, argv[optind], argv[optind+1], max_mem, is_stdout); diff --git a/samtools/bam_stat.c b/samtools/bam_stat.c deleted file mode 100644 index ea9deee..0000000 --- a/samtools/bam_stat.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#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; -} bam_flagstat_t; - -#define flagstat_loop(s, c) do { \ - ++(s)->n_reads; \ - 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; \ - if (!((c)->flag & BAM_FUNMAP) && !((c)->flag & BAM_FMUNMAP)) { \ - ++(s)->n_pair_map; \ - if ((c)->mtid != (c)->tid) { \ - ++(s)->n_diffchr; \ - if ((c)->qual >= 5) ++(s)->n_diffhigh; \ - } \ - } \ - } \ - if (!((c)->flag & BAM_FUNMAP)) ++(s)->n_mapped; \ - if ((c)->flag & BAM_FQCFAIL) ++(s)->n_qcfail; \ - if ((c)->flag & BAM_FDUP) ++(s)->n_dup; \ - } while (0) - -bam_flagstat_t *bam_flagstat_core(bamFile fp) -{ - bam_flagstat_t *s; - bam1_t *b; - bam1_core_t *c; - int ret; - s = (bam_flagstat_t*)calloc(1, sizeof(bam_flagstat_t)); - b = bam_init1(); - c = &b->core; - while ((ret = bam_read1(fp, b)) >= 0) - flagstat_loop(s, c); - bam_destroy1(b); - if (ret != -1) - fprintf(stderr, "[bam_flagstat_core] Truncated file? Continue anyway.\n"); - return s; -} -int bam_flagstat(int argc, char *argv[]) -{ - bamFile fp; - bam_header_t *header; - bam_flagstat_t *s; - if (argc == optind) { - fprintf(stderr, "Usage: samtools flagstat \n"); - return 1; - } - fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r"); - 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); - free(s); - bam_header_destroy(header); - bam_close(fp); - return 0; -} diff --git a/samtools/bam_stat.c.pysam.c b/samtools/bam_stat.c.pysam.c new file mode 100644 index 0000000..4751782 --- /dev/null +++ b/samtools/bam_stat.c.pysam.c @@ -0,0 +1,79 @@ +#include "pysam.h" + +#include +#include +#include "bam.h" + +typedef struct { + 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 { \ + int w = ((c)->flag & BAM_FQCFAIL)? 1 : 0; \ + ++(s)->n_reads[w]; \ + if ((c)->flag & BAM_FPAIRED) { \ + ++(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[w]; \ + if ((c)->mtid != (c)->tid) { \ + ++(s)->n_diffchr[w]; \ + if ((c)->qual >= 5) ++(s)->n_diffhigh[w]; \ + } \ + } \ + } \ + 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) +{ + bam_flagstat_t *s; + bam1_t *b; + bam1_core_t *c; + int ret; + s = (bam_flagstat_t*)calloc(1, sizeof(bam_flagstat_t)); + b = bam_init1(); + c = &b->core; + while ((ret = bam_read1(fp, b)) >= 0) + flagstat_loop(s, c); + bam_destroy1(b); + if (ret != -1) + fprintf(pysamerr, "[bam_flagstat_core] Truncated file? Continue anyway.\n"); + return s; +} +int bam_flagstat(int argc, char *argv[]) +{ + bamFile fp; + bam_header_t *header; + bam_flagstat_t *s; + if (argc == optind) { + fprintf(pysamerr, "Usage: samtools flagstat \n"); + return 1; + } + fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r"); + assert(fp); + header = bam_header_read(fp); + s = bam_flagstat_core(fp); + 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); + return 0; +} diff --git a/samtools/bam_tview.c b/samtools/bam_tview.c.pysam.c similarity index 97% rename from samtools/bam_tview.c rename to samtools/bam_tview.c.pysam.c index 7b326fc..d4abf67 100644 --- a/samtools/bam_tview.c +++ b/samtools/bam_tview.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #undef _HAVE_CURSES #if _CURSES_LIB == 0 @@ -109,7 +111,7 @@ int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void if (tv->is_dot && toupper(c) == toupper(rb)) c = bam1_strand(p->b)? ',' : '.'; } } - } else c = '*'; + } else c = p->is_refskip? (bam1_strand(p->b)? '<' : '>') : '*'; } else { // padding if (j > p->indel) c = '*'; else { // insertion @@ -183,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(); @@ -292,7 +294,7 @@ static void tv_win_goto(tview_t *tv, int *tid, int *pos) } else if (c == KEY_ENTER || c == '\012' || c == '\015') { int _tid = -1, _beg, _end; if (str[0] == '=') { - _beg = strtol(str+1, &p, 10); + _beg = strtol(str+1, &p, 10) - 1; if (_beg > 0) { *pos = _beg; return; @@ -404,7 +406,7 @@ int bam_tview_main(int argc, char *argv[]) { tview_t *tv; if (argc == 1) { - fprintf(stderr, "Usage: bamtk tview [ref.fasta]\n"); + fprintf(pysamerr, "Usage: bamtk tview [ref.fasta]\n"); return 1; } tv = tv_init(argv[1], (argc == 2)? 0 : argv[2]); @@ -418,7 +420,7 @@ int bam_tview_main(int argc, char *argv[]) #warning "No curses library is available; tview is disabled." int bam_tview_main(int argc, char *argv[]) { - fprintf(stderr, "[bam_tview_main] The ncurses library is unavailable; tview is not compiled.\n"); + fprintf(pysamerr, "[bam_tview_main] The ncurses library is unavailable; tview is not compiled.\n"); return 1; } #endif // #ifdef _HAVE_CURSES diff --git a/samtools/bcftools/bcf.c.pysam.c b/samtools/bcftools/bcf.c.pysam.c new file mode 100644 index 0000000..e1c823d --- /dev/null +++ b/samtools/bcftools/bcf.c.pysam.c @@ -0,0 +1,330 @@ +#include "pysam.h" + +#include +#include +#include +#include "kstring.h" +#include "bcf.h" + +bcf_t *bcf_open(const char *fn, const char *mode) +{ + bcf_t *b; + b = calloc(1, sizeof(bcf_t)); + if (strchr(mode, 'w')) { + b->fp = strcmp(fn, "-")? bgzf_open(fn, mode) : bgzf_fdopen(fileno(stdout), mode); + } else { + b->fp = strcmp(fn, "-")? bgzf_open(fn, mode) : bgzf_fdopen(fileno(stdin), mode); + } +#ifndef BCF_LITE + b->fp->owned_file = 1; +#endif + return b; +} + +int bcf_close(bcf_t *b) +{ + int ret; + if (b == 0) return 0; + ret = bgzf_close(b->fp); + free(b); + return ret; +} + +int bcf_hdr_write(bcf_t *b, const bcf_hdr_t *h) +{ + if (b == 0 || h == 0) return -1; + bgzf_write(b->fp, "BCF\4", 4); + bgzf_write(b->fp, &h->l_nm, 4); + bgzf_write(b->fp, h->name, h->l_nm); + bgzf_write(b->fp, &h->l_smpl, 4); + bgzf_write(b->fp, h->sname, h->l_smpl); + bgzf_write(b->fp, &h->l_txt, 4); + bgzf_write(b->fp, h->txt, h->l_txt); + bgzf_flush(b->fp); + return 16 + h->l_nm + h->l_smpl + h->l_txt; +} + +bcf_hdr_t *bcf_hdr_read(bcf_t *b) +{ + uint8_t magic[4]; + bcf_hdr_t *h; + if (b == 0) return 0; + h = calloc(1, sizeof(bcf_hdr_t)); + bgzf_read(b->fp, magic, 4); + bgzf_read(b->fp, &h->l_nm, 4); + h->name = malloc(h->l_nm); + bgzf_read(b->fp, h->name, h->l_nm); + bgzf_read(b->fp, &h->l_smpl, 4); + h->sname = malloc(h->l_smpl); + bgzf_read(b->fp, h->sname, h->l_smpl); + bgzf_read(b->fp, &h->l_txt, 4); + h->txt = malloc(h->l_txt); + bgzf_read(b->fp, h->txt, h->l_txt); + bcf_hdr_sync(h); + return h; +} + +void bcf_hdr_destroy(bcf_hdr_t *h) +{ + if (h == 0) return; + free(h->name); free(h->sname); free(h->txt); free(h->ns); free(h->sns); + free(h); +} + +static inline char **cnt_null(int l, char *str, int *_n) +{ + int n = 0; + char *p, **list; + *_n = 0; + if (l == 0 || str == 0) return 0; + for (p = str; p != str + l; ++p) + if (*p == 0) ++n; + *_n = n; + list = calloc(n, sizeof(void*)); + list[0] = str; + for (p = str, n = 1; p < str + l - 1; ++p) + if (*p == 0) list[n++] = p + 1; + return list; +} + +int bcf_hdr_sync(bcf_hdr_t *b) +{ + if (b == 0) return -1; + if (b->ns) free(b->ns); + if (b->sns) free(b->sns); + if (b->l_nm) b->ns = cnt_null(b->l_nm, b->name, &b->n_ref); + else b->ns = 0, b->n_ref = 0; + b->sns = cnt_null(b->l_smpl, b->sname, &b->n_smpl); + return 0; +} + +int bcf_sync(bcf1_t *b) +{ + char *p, *tmp[5]; + int i, n, n_smpl = b->n_smpl; + 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) { + if (n == 5) { + ++n; + break; + } else tmp[n++] = p + 1; + } + } + if (n != 5) { + 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]; + // set n_alleles + if (*b->alt == 0) b->n_alleles = 1; + else { + for (p = b->alt, n = 1; *p; ++p) + if (*p == ',') ++n; + b->n_alleles = n + 1; + } + // set n_gi and gi[i].fmt + for (p = b->fmt, n = 1; *p; ++p) + if (*p == ':') ++n; + if (n > b->m_gi) { + int old_m = b->m_gi; + b->m_gi = n; + kroundup32(b->m_gi); + b->gi = realloc(b->gi, b->m_gi * sizeof(bcf_ginfo_t)); + memset(b->gi + old_m, 0, (b->m_gi - old_m) * sizeof(bcf_ginfo_t)); + } + b->n_gi = n; + for (p = kstrtok(b->fmt, ":", &aux), n = 0; p; p = kstrtok(0, 0, &aux)) + b->gi[n++].fmt = bcf_str2int(p, aux.p - p); + // set gi[i].len + for (i = 0; i < b->n_gi; ++i) { + if (b->gi[i].fmt == bcf_str2int("PL", 2)) { + 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].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; + } + b->gi[i].data = realloc(b->gi[i].data, n_smpl * b->gi[i].len); + } + return 0; +} + +int bcf_write(bcf_t *bp, const bcf_hdr_t *h, const bcf1_t *b) +{ + int i, l = 0; + if (b == 0) return -1; + bgzf_write(bp->fp, &b->tid, 4); + bgzf_write(bp->fp, &b->pos, 4); + bgzf_write(bp->fp, &b->qual, 4); + bgzf_write(bp->fp, &b->l_str, 4); + bgzf_write(bp->fp, b->str, b->l_str); + l = 12 + b->l_str; + for (i = 0; i < b->n_gi; ++i) { + bgzf_write(bp->fp, b->gi[i].data, b->gi[i].len * h->n_smpl); + l += b->gi[i].len * h->n_smpl; + } + return l; +} + +int bcf_read(bcf_t *bp, const bcf_hdr_t *h, bcf1_t *b) +{ + int i, l = 0; + if (b == 0) return -1; + if (bgzf_read(bp->fp, &b->tid, 4) == 0) return -1; + b->n_smpl = h->n_smpl; + bgzf_read(bp->fp, &b->pos, 4); + bgzf_read(bp->fp, &b->qual, 4); + bgzf_read(bp->fp, &b->l_str, 4); + if (b->l_str > b->m_str) { + b->m_str = b->l_str; + kroundup32(b->m_str); + b->str = realloc(b->str, b->m_str); + } + bgzf_read(bp->fp, b->str, b->l_str); + l = 12 + b->l_str; + if (bcf_sync(b) < 0) return -2; + for (i = 0; i < b->n_gi; ++i) { + bgzf_read(bp->fp, b->gi[i].data, b->gi[i].len * h->n_smpl); + l += b->gi[i].len * h->n_smpl; + } + return l; +} + +int bcf_destroy(bcf1_t *b) +{ + int i; + if (b == 0) return -1; + free(b->str); + for (i = 0; i < b->m_gi; ++i) + free(b->gi[i].data); + free(b->gi); + free(b); + return 0; +} + +static inline void fmt_str(const char *p, kstring_t *s) +{ + if (*p == 0) kputc('.', s); + else kputs(p, s); +} + +void bcf_fmt_core(const bcf_hdr_t *h, bcf1_t *b, kstring_t *s) +{ + int i, j, x; + s->l = 0; + if (h->n_ref) kputs(h->ns[b->tid], s); + else kputw(b->tid, s); + kputc('\t', s); + kputw(b->pos + 1, s); kputc('\t', s); + fmt_str(b->str, s); kputc('\t', s); + fmt_str(b->ref, s); kputc('\t', s); + fmt_str(b->alt, s); kputc('\t', s); + ksprintf(s, "%.3g", b->qual); kputc('\t', s); + fmt_str(b->flt, s); kputc('\t', s); + fmt_str(b->info, s); + if (b->fmt[0]) { + kputc('\t', s); + fmt_str(b->fmt, s); + } + x = b->n_alleles * (b->n_alleles + 1) / 2; + if (b->n_gi == 0) return; + for (j = 0; j < h->n_smpl; ++j) { + kputc('\t', s); + for (i = 0; i < b->n_gi; ++i) { + if (i) kputc(':', s); + if (b->gi[i].fmt == bcf_str2int("PL", 2)) { + uint8_t *d = (uint8_t*)b->gi[i].data + j * x; + int k; + for (k = 0; k < x; ++k) { + if (k > 0) kputc(',', s); + kputw(d[k], 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)) { + 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) { + kputsn("./.", 3, s); + } else { + kputc('0' + (y>>3&7), s); + kputc("/|"[y>>6&1], s); + kputc('0' + (y&7), s); + } + } else if (b->gi[i].fmt == bcf_str2int("GL", 2)) { + float *d = (float*)b->gi[i].data + j * x; + int k; + //printf("- %lx\n", d); + for (k = 0; k < x; ++k) { + if (k > 0) kputc(',', s); + ksprintf(s, "%.2f", d[k]); + } + } else kputc('.', s); // custom fields + } + } +} + +char *bcf_fmt(const bcf_hdr_t *h, bcf1_t *b) +{ + kstring_t s; + s.l = s.m = 0; s.s = 0; + bcf_fmt_core(h, b, &s); + return s.s; +} + +int bcf_append_info(bcf1_t *b, const char *info, int l) +{ + int shift = b->fmt - b->str; + int l_fmt = b->l_str - shift; + char *ori = b->str; + if (b->l_str + l > b->m_str) { // enlarge if necessary + b->m_str = b->l_str + l; + kroundup32(b->m_str); + b->str = realloc(b->str, b->m_str); + } + memmove(b->str + shift + l, b->str + shift, l_fmt); // move the FORMAT field + memcpy(b->str + shift - 1, info, l); // append to the INFO field + b->str[shift + l - 1] = '\0'; + b->fmt = b->str + shift + l; + b->l_str += l; + if (ori != b->str) bcf_sync(b); // synchronize when realloc changes the pointer + return 0; +} + +int bcf_cpy(bcf1_t *r, const bcf1_t *b) +{ + char *t1 = r->str; + bcf_ginfo_t *t2 = r->gi; + int i, t3 = r->m_str, t4 = r->m_gi; + *r = *b; + r->str = t1; r->gi = t2; r->m_str = t3; r->m_gi = t4; + if (r->m_str < b->m_str) { + r->m_str = b->m_str; + r->str = realloc(r->str, r->m_str); + } + memcpy(r->str, b->str, r->m_str); + bcf_sync(r); // calling bcf_sync() is simple but inefficient + for (i = 0; i < r->n_gi; ++i) + memcpy(r->gi[i].data, b->gi[i].data, r->n_smpl * r->gi[i].len); + return 0; +} + +int bcf_is_indel(const bcf1_t *b) +{ + char *p; + if (strlen(b->ref) > 1) return 1; + for (p = b->alt; *p; ++p) + if (*p != ',' && p[1] != ',' && p[1] != '\0') + return 1; + return 0; +} diff --git a/samtools/bcftools/bcf.h b/samtools/bcftools/bcf.h new file mode 100644 index 0000000..ba6dbe9 --- /dev/null +++ b/samtools/bcftools/bcf.h @@ -0,0 +1,184 @@ +/* The MIT License + + Copyright (c) 2010 Broad Institute + + 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 */ + +#ifndef BCF_H +#define BCF_H + +#include +#include + +#ifndef BCF_LITE +#include "bgzf.h" +typedef BGZF *bcfFile; +#else +typedef gzFile bcfFile; +#define bgzf_open(fn, mode) gzopen(fn, mode) +#define bgzf_fdopen(fd, mode) gzdopen(fd, mode) +#define bgzf_close(fp) gzclose(fp) +#define bgzf_read(fp, buf, len) gzread(fp, buf, len) +#define bgzf_write(fp, buf, len) +#define bgzf_flush(fp) +#endif + +/* + A member in the structs below is said to "primary" if its content + cannot be inferred from other members in any of structs below; a + member is said to be "derived" if its content can be derived from + other members. For example, bcf1_t::str is primary as this comes from + the input data, while bcf1_t::info is derived as it can always be + correctly set if we know bcf1_t::str. Derived members are for quick + access to the content and must be synchronized with the primary data. + */ + +typedef struct { + uint32_t fmt; // format of the block, set by bcf_str2int(). + int len; // length of data for each individual + void *data; // concatenated data + // derived info: fmt, len (<-bcf1_t::fmt) +} bcf_ginfo_t; + +typedef struct { + int32_t tid, pos; // refID and 0-based position + int32_t l_str, m_str; // length and the allocated size of ->str + float qual; // SNP quality + char *str; // concatenated string of variable length strings in VCF (from col.2 to col.7) + char *ref, *alt, *flt, *info, *fmt; // they all point to ->str; no memory allocation + int n_gi, m_gi; // number and the allocated size of geno fields + bcf_ginfo_t *gi; // array of geno fields + int n_alleles, n_smpl; // number of alleles and samples + // derived info: ref, alt, flt, info, fmt (<-str), n_gi (<-fmt), n_alleles (<-alt), n_smpl (<-bcf_hdr_t::n_smpl) +} bcf1_t; + +typedef struct { + int32_t n_ref, n_smpl; // number of reference sequences and samples + int32_t l_nm; // length of concatenated sequence names; 0 padded + int32_t l_smpl; // length of concatenated sample names; 0 padded + int32_t l_txt; // length of header text (lines started with ##) + char *name, *sname, *txt; // concatenated sequence names, sample names and header text + char **ns, **sns; // array of sequence and sample names; point to name and sname, respectively + // derived info: n_ref (<-name), n_smpl (<-sname), ns (<-name), sns (<-sname) +} bcf_hdr_t; + +typedef struct { + int is_vcf; // if the file in operation is a VCF + void *v; // auxillary data structure for VCF + bcfFile fp; // file handler for BCF +} bcf_t; + +struct __bcf_idx_t; +typedef struct __bcf_idx_t bcf_idx_t; + +#ifdef __cplusplus +extern "C" { +#endif + + // open a BCF file; for BCF file only + bcf_t *bcf_open(const char *fn, const char *mode); + // close file + int bcf_close(bcf_t *b); + // read one record from BCF; return -1 on end-of-file, and <-1 for errors + int bcf_read(bcf_t *bp, const bcf_hdr_t *h, bcf1_t *b); + // call this function if b->str is changed + int bcf_sync(bcf1_t *b); + // write a BCF record + int bcf_write(bcf_t *bp, const bcf_hdr_t *h, const bcf1_t *b); + // read the BCF header; BCF only + bcf_hdr_t *bcf_hdr_read(bcf_t *b); + // write the BCF header + int bcf_hdr_write(bcf_t *b, const bcf_hdr_t *h); + // set bcf_hdr_t::ns and bcf_hdr_t::sns + int bcf_hdr_sync(bcf_hdr_t *b); + // destroy the header + void bcf_hdr_destroy(bcf_hdr_t *h); + // destroy a record + int bcf_destroy(bcf1_t *b); + // BCF->VCF conversion + char *bcf_fmt(const bcf_hdr_t *h, bcf1_t *b); + // append more info + int bcf_append_info(bcf1_t *b, const char *info, int l); + // copy + int bcf_cpy(bcf1_t *r, const bcf1_t *b); + + // open a VCF or BCF file if "b" is set in "mode" + bcf_t *vcf_open(const char *fn, const char *mode); + // close a VCF/BCF file + 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 + int vcf_hdr_write(bcf_t *bp, const bcf_hdr_t *h); + // write a VCF record + int vcf_write(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b); + + // keep the first n alleles and discard the rest + int bcf_shrink_alt(bcf1_t *b, int n); + // convert GL to PL + 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(); + + // indexing related functions + int bcf_idx_build(const char *fn); + uint64_t bcf_idx_query(const bcf_idx_t *idx, int tid, int beg); + int bcf_parse_region(void *str2id, const char *str, int *tid, int *begin, int *end); + bcf_idx_t *bcf_idx_load(const char *fn); + void bcf_idx_destroy(bcf_idx_t *idx); + +#ifdef __cplusplus +} +#endif + +static inline uint32_t bcf_str2int(const char *str, int l) +{ + int i; + uint32_t x = 0; + for (i = 0; i < l && i < 4; ++i) { + if (str[i] == 0) return x; + x = x<<8 | str[i]; + } + return x; +} + +#endif diff --git a/samtools/bcftools/bcf2qcall.c.pysam.c b/samtools/bcftools/bcf2qcall.c.pysam.c new file mode 100644 index 0000000..6dc7e0c --- /dev/null +++ b/samtools/bcftools/bcf2qcall.c.pysam.c @@ -0,0 +1,93 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include "bcf.h" + +static int8_t nt4_table[256] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 /*'-'*/, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 3, 4, 4, 4, -1, 4, 4, 4, 4, 4, 4, 4, + 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 3, 4, 4, 4, -1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 +}; + +static int read_I16(bcf1_t *b, int anno[16]) +{ + char *p; + int i; + if ((p = strstr(b->info, "I16=")) == 0) return -1; + p += 4; + for (i = 0; i < 16; ++i) { + anno[i] = strtol(p, &p, 10); + if (anno[i] == 0 && (errno == EINVAL || errno == ERANGE)) return -2; + ++p; + } + return 0; +} + +int bcf_2qcall(bcf_hdr_t *h, bcf1_t *b) +{ + int a[4], k, g[10], l, map[4], k1, j, i, i0, anno[16], dp, mq, d_rest; + char *s; + if (b->ref[1] != 0 || b->n_alleles > 4) return -1; // ref is not a single base + for (i = 0; i < b->n_gi; ++i) + if (b->gi[i].fmt == bcf_str2int("PL", 2)) break; + if (i == b->n_gi) return -1; // no PL + if (read_I16(b, anno) != 0) return -1; // no I16; FIXME: can be improved + d_rest = dp = anno[0] + anno[1] + anno[2] + anno[3]; + if (dp == 0) return -1; // depth is zero + mq = (int)(sqrt((double)(anno[9] + anno[11]) / dp) + .499); + i0 = i; + a[0] = nt4_table[(int)b->ref[0]]; + if (a[0] > 3) return -1; // ref is not A/C/G/T + a[1] = a[2] = a[3] = -2; // -1 has a special meaning + if (b->alt[0] == 0) return -1; // no alternate allele + map[0] = map[1] = map[2] = map[3] = -2; + map[a[0]] = 0; + for (k = 0, s = b->alt, k1 = -1; k < 3 && *s; ++k, s += 2) { + if (s[1] != ',' && s[1] != 0) return -1; // ALT is not single base + a[k+1] = nt4_table[(int)*s]; + if (a[k+1] >= 0) map[a[k+1]] = k+1; + else k1 = k+1; + if (s[1] == 0) break; + } + for (k = 0; k < 4; ++k) + if (map[k] < 0) map[k] = k1; + for (i = 0; i < h->n_smpl; ++i) { + int d; + uint8_t *p = b->gi[i0].data + i * b->gi[i0].len; + for (j = 0; j < b->gi[i0].len; ++j) + if (p[j]) break; + d = (int)((double)d_rest / (h->n_smpl - i) + .499); + if (d == 0) d = 1; + if (j == b->gi[i0].len) d = 0; + d_rest -= d; + 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; // swap + g[j++] = p[y * (y+1) / 2 + x]; + } + } + printf("%s\t%d\t%c", h->ns[b->tid], b->pos+1, *b->ref); + printf("\t%d\t%d\t0", d, mq); + for (j = 0; j < 10; ++j) + printf("\t%d", g[j]); + printf("\t%s\n", h->sns[i]); + } + return 0; +} diff --git a/samtools/bcftools/bcfutils.c.pysam.c b/samtools/bcftools/bcfutils.c.pysam.c new file mode 100644 index 0000000..c48ab03 --- /dev/null +++ b/samtools/bcftools/bcfutils.c.pysam.c @@ -0,0 +1,312 @@ +#include "pysam.h" + +#include +#include +#include "bcf.h" +#include "kstring.h" +#include "khash.h" +KHASH_MAP_INIT_STR(str2id, int) + +void *bcf_build_refhash(bcf_hdr_t *h) +{ + khash_t(str2id) *hash; + int i, ret; + hash = kh_init(str2id); + for (i = 0; i < h->n_ref; ++i) { + khint_t k; + k = kh_put(str2id, hash, h->ns[i], &ret); // FIXME: check ret + kh_val(hash, k) = i; + } + return hash; +} + +void *bcf_str2id_init() +{ + return kh_init(str2id); +} + +void bcf_str2id_destroy(void *_hash) +{ + khash_t(str2id) *hash = (khash_t(str2id)*)_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; + khint_t k; + if (!hash) return -1; + k = kh_get(str2id, hash, str); + return k == kh_end(hash)? -1 : kh_val(hash, k); +} + +int bcf_str2id_add(void *_hash, const char *str) +{ + khint_t k; + int ret; + khash_t(str2id) *hash = (khash_t(str2id)*)_hash; + if (!hash) return -1; + k = kh_put(str2id, hash, str, &ret); + if (ret == 0) return kh_val(hash, k); + kh_val(hash, k) = kh_size(hash) - 1; + return kh_val(hash, k); +} + +int bcf_shrink_alt(bcf1_t *b, int n) +{ + char *p; + 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; + *p = '\0'; + } else p = b->alt, *p = '\0'; + ++p; + memmove(p, b->flt, b->str + b->l_str - b->flt); + b->l_str -= b->flt - p; + // update PL + for (i = 0; i < b->n_gi; ++i) { + bcf_ginfo_t *g = b->gi + i; + if (g->fmt == bcf_str2int("PL", 2)) { + int l, x = b->n_alleles * (b->n_alleles + 1) / 2; + uint8_t *d = (uint8_t*)g->data; + 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[j]; + } + } // FIXME: to add GL + } + b->n_alleles = n; + bcf_sync(b); + return 0; +} + +int bcf_gl2pl(bcf1_t *b) +{ + char *p; + int i, n_smpl = b->n_smpl; + bcf_ginfo_t *g; + float *d0; + uint8_t *d1; + if (strstr(b->fmt, "PL")) return -1; + if ((p = strstr(b->fmt, "GL")) == 0) return -1; + *p = 'P'; + for (i = 0; i < b->n_gi; ++i) + if (b->gi[i].fmt == bcf_str2int("GL", 2)) + break; + g = b->gi + i; + g->fmt = bcf_str2int("PL", 2); + g->len /= 4; // 4 == sizeof(float) + d0 = (float*)g->data; d1 = (uint8_t*)g->data; + for (i = 0; i < n_smpl * g->len; ++i) { + int x = (int)(-10. * d0[i] + .499); + if (x > 255) x = 255; + if (x < 0) x = 0; + d1[i] = x; + } + 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; +} diff --git a/samtools/bcftools/call1.c.pysam.c b/samtools/bcftools/call1.c.pysam.c new file mode 100644 index 0000000..378c3d5 --- /dev/null +++ b/samtools/bcftools/call1.c.pysam.c @@ -0,0 +1,529 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include +#include "bcf.h" +#include "prob1.h" +#include "kstring.h" +#include "time.h" + +#include "kseq.h" +KSTREAM_INIT(gzFile, gzread, 16384) + +#define VC_NO_GENO 2 +#define VC_BCFOUT 4 +#define VC_CALL 8 +#define VC_VARONLY 16 +#define VC_VCFIN 32 +#define VC_UNCOMP 64 +#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_ANNO_MAX 16384 +#define VC_FIX_PL 32768 +#define VC_EM 0x10000 + +typedef struct { + 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; + +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]; + int mq, depth, is_tested, d[4]; +} anno16_t; + +static double ttest(int n1, int n2, int a[4]) +{ + extern double kf_betai(double a, double b, double x); + double t, v, u1, u2; + if (n1 == 0 || n2 == 0 || n1 + n2 < 3) return 1.0; + u1 = (double)a[0] / n1; u2 = (double)a[2] / n2; + if (u1 <= u2) return 1.; + t = (u1 - u2) / sqrt(((a[1] - n1 * u1 * u1) + (a[3] - n2 * u2 * u2)) / (n1 + n2 - 2) * (1./n1 + 1./n2)); + v = n1 + n2 - 2; +// printf("%d,%d,%d,%d,%lf,%lf,%lf\n", a[0], a[1], a[2], a[3], t, u1, u2); + return t < 0.? 1. : .5 * kf_betai(.5*v, .5, v/(v+t*t)); +} + +static int test16_core(int anno[16], anno16_t *a) +{ + extern double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two); + double left, right; + int i; + a->p[0] = a->p[1] = a->p[2] = a->p[3] = 1.; + memcpy(a->d, anno, 4 * sizeof(int)); + a->depth = anno[0] + anno[1] + anno[2] + anno[3]; + a->is_tested = (anno[0] + anno[1] > 0 && anno[2] + anno[3] > 0); + if (a->depth == 0) return -1; + a->mq = (int)(sqrt((anno[9] + anno[11]) / a->depth) + .499); + kt_fisher_exact(anno[0], anno[1], anno[2], anno[3], &left, &right, &a->p[0]); + for (i = 1; i < 4; ++i) + a->p[i] = ttest(anno[0] + anno[1], anno[2] + anno[3], anno+4*i); + return 0; +} + +static int test16(bcf1_t *b, anno16_t *a) +{ + char *p; + int i, anno[16]; + a->p[0] = a->p[1] = a->p[2] = a->p[3] = 1.; + a->d[0] = a->d[1] = a->d[2] = a->d[3] = 0.; + a->mq = a->depth = a->is_tested = 0; + if ((p = strstr(b->info, "I16=")) == 0) return -1; + p += 4; + for (i = 0; i < 16; ++i) { + errno = 0; anno[i] = strtol(p, &p, 10); + if (anno[i] == 0 && (errno == EINVAL || errno == ERANGE)) return -2; + ++p; + } + return test16_core(anno, a); +} + +static void rm_info(bcf1_t *b, const char *key) +{ + char *p, *q; + if ((p = strstr(b->info, key)) == 0) return; + for (q = p; *q && *q != ';'; ++q); + if (p > b->info && *(p-1) == ';') --p; + memmove(p, q, b->l_str - (q - b->str)); + b->l_str -= q - p; + bcf_sync(b); +} + +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 has_I16, is_var; + double fq, r; + anno16_t a; + + 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); + { // 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 == 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? 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)) + bcf_shrink_alt(b, pr->rank0 < 2? 2 : pr->rank0+1); + if (is_var && (flag&VC_CALL_GT)) { // call individual genotype + int i, x, old_n_gi = b->n_gi; + s.m = b->m_str; s.l = b->l_str - 1; s.s = b->str; + kputs(":GT:GQ", &s); kputc('\0', &s); + 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_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; + } + } + return is_var; +} + +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=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##INFO=\n", &str); + if (!strstr(str.s, "##FORMAT=\n", &str); + if (!strstr(str.s, "##FORMAT=\n", &str); + if (!strstr(str.s, "##FORMAT=\n", &str); + if (!strstr(str.s, "##FORMAT=\n", &str); + if (!strstr(str.s, "##FORMAT=\n", &str); + if (!strstr(str.s, "##FORMAT=\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, *seeds = 0; + uint64_t n_processed = 0; + viewconf_t vc; + bcf_p1aux_t *p1 = 0; + bcf_hdr_t *hin, *hout; + int tid, begin, end; + char moder[4], modew[4]; + + 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.; 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 '1': vc.n1 = atoi(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 '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; + else if (strcmp(optarg, "flat") == 0) vc.prior_type = MC_PTYPE_FLAT; + else vc.prior_file = strdup(optarg); + break; + } + } + if (argc == optind) { + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: bcftools view [options] [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)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"); + if (!(vc.flag & VC_VCFIN)) strcat(moder, "b"); + strcpy(modew, "w"); + if (vc.flag & VC_BCFOUT) strcat(modew, "b"); + if (vc.flag & VC_UNCOMP) strcat(modew, "u"); + bp = vcf_open(argv[optind], moder); + 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)) { + 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(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 && 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 (optind + 1 < argc && !(vc.flag&VC_VCFIN)) { + 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]); + if (idx) { + uint64_t off; + off = bcf_idx_query(idx, tid, begin); + if (off == 0) { + fprintf(pysamerr, "[%s] no records in the query region.\n", __func__); + return 1; // FIXME: a lot of memory leaks... + } + bgzf_seek(bp->fp, off, SEEK_SET); + bcf_idx_destroy(idx); + } + } + } + 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; + if (b->ref[0] == 0 || b->ref[1] != 0) continue; + x = toupper(b->ref[0]); + if (x != 'A' && x != 'C' && x != 'G' && x != 'T') continue; + } + 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); + if (b->tid != tid || b->pos >= end) break; + if (!(l > begin && end > b->pos)) continue; + } + ++n_processed; + if (vc.flag & VC_QCALL) { // output QCALL format; STOP here + 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; + 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; + 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_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=%.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'; + 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); + if (hin != hout) bcf_hdr_destroy(hout); + bcf_hdr_destroy(hin); + bcf_destroy(b); bcf_destroy(blast); + vcf_close(bp); vcf_close(bout); + 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 index 0000000..914dc05 --- /dev/null +++ b/samtools/bcftools/em.c.pysam.c @@ -0,0 +1,308 @@ +#include "pysam.h" + +#include +#include +#include +#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; +} diff --git a/samtools/bcftools/fet.c.pysam.c b/samtools/bcftools/fet.c.pysam.c new file mode 100644 index 0000000..cbd3585 --- /dev/null +++ b/samtools/bcftools/fet.c.pysam.c @@ -0,0 +1,114 @@ +#include "pysam.h" + +#include +#include + +/* This program is implemented with ideas from this web page: + * + * http://www.langsrud.com/fisher.htm + */ + +// log\binom{n}{k} +static double lbinom(int n, int k) +{ + if (k == 0 || n == k) return 0; + return lgamma(n+1) - lgamma(k+1) - lgamma(n-k+1); +} + +// n11 n12 | n1_ +// n21 n22 | n2_ +//-----------+---- +// n_1 n_2 | n + +// hypergeometric distribution +static double hypergeo(int n11, int n1_, int n_1, int n) +{ + return exp(lbinom(n1_, n11) + lbinom(n-n1_, n_1-n11) - lbinom(n, n_1)); +} + +typedef struct { + int n11, n1_, n_1, n; + double p; +} hgacc_t; + +// incremental version of hypergenometric distribution +static double hypergeo_acc(int n11, int n1_, int n_1, int n, hgacc_t *aux) +{ + if (n1_ || n_1 || n) { + aux->n11 = n11; aux->n1_ = n1_; aux->n_1 = n_1; aux->n = n; + } else { // then only n11 changed; the rest fixed + if (n11%11 && n11 + aux->n - aux->n1_ - aux->n_1) { + if (n11 == aux->n11 + 1) { // incremental + aux->p *= (double)(aux->n1_ - aux->n11) / n11 + * (aux->n_1 - aux->n11) / (n11 + aux->n - aux->n1_ - aux->n_1); + aux->n11 = n11; + return aux->p; + } + if (n11 == aux->n11 - 1) { // incremental + aux->p *= (double)aux->n11 / (aux->n1_ - n11) + * (aux->n11 + aux->n - aux->n1_ - aux->n_1) / (aux->n_1 - n11); + aux->n11 = n11; + return aux->p; + } + } + aux->n11 = n11; + } + aux->p = hypergeo(aux->n11, aux->n1_, aux->n_1, aux->n); + return aux->p; +} + +double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two) +{ + int i, j, max, min; + double p, q, left, right; + hgacc_t aux; + int n1_, n_1, n; + + 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; + 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 + // left tail + p = hypergeo_acc(min, 0, 0, 0, &aux); + for (left = 0., i = min + 1; p < 0.99999999 * q; ++i) // loop until underflow + left += p, p = hypergeo_acc(i, 0, 0, 0, &aux); + --i; + if (p < 1.00000001 * q) left += p; + else --i; + // right tail + 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 + *two = left + right; + if (*two > 1.) *two = 1.; + // adjust left and right + if (abs(i - n11) < abs(j - n11)) right = 1. - left + q; + else left = 1.0 - right + q; + *_left = left; *_right = right; + return q; +} + +#ifdef FET_MAIN +#include + +int main(int argc, char *argv[]) +{ + char id[1024]; + int n11, n12, n21, n22; + double left, right, twotail, prob; + + while (scanf("%s%d%d%d%d", id, &n11, &n12, &n21, &n22) == 5) { + prob = kt_fisher_exact(n11, n12, n21, n22, &left, &right, &twotail); + printf("%s\t%d\t%d\t%d\t%d\t%.6g\t%.6g\t%.6g\t%.6g\n", id, n11, n12, n21, n22, + prob, left, right, twotail); + } + return 0; +} +#endif diff --git a/samtools/bcftools/index.c.pysam.c b/samtools/bcftools/index.c.pysam.c new file mode 100644 index 0000000..8258854 --- /dev/null +++ b/samtools/bcftools/index.c.pysam.c @@ -0,0 +1,337 @@ +#include "pysam.h" + +#include +#include +#include +#include "bam_endian.h" +#include "kstring.h" +#include "bcf.h" +#ifdef _USE_KNETFILE +#include "knetfile.h" +#endif + +#define TAD_LIDX_SHIFT 13 + +typedef struct { + int32_t n, m; + uint64_t *offset; +} bcf_lidx_t; + +struct __bcf_idx_t { + int32_t n; + bcf_lidx_t *index2; +}; + +/************ + * indexing * + ************/ + +static inline void insert_offset2(bcf_lidx_t *index2, int _beg, int _end, uint64_t offset) +{ + int i, beg, end; + beg = _beg >> TAD_LIDX_SHIFT; + end = (_end - 1) >> TAD_LIDX_SHIFT; + if (index2->m < end + 1) { + int old_m = index2->m; + index2->m = end + 1; + kroundup32(index2->m); + index2->offset = (uint64_t*)realloc(index2->offset, index2->m * 8); + memset(index2->offset + old_m, 0, 8 * (index2->m - old_m)); + } + if (beg == end) { + if (index2->offset[beg] == 0) index2->offset[beg] = offset; + } else { + for (i = beg; i <= end; ++i) + if (index2->offset[i] == 0) index2->offset[i] = offset; + } + if (index2->n < end + 1) index2->n = end + 1; +} + +bcf_idx_t *bcf_idx_core(bcf_t *bp, bcf_hdr_t *h) +{ + bcf_idx_t *idx; + int32_t last_coor, last_tid; + uint64_t last_off; + kstring_t *str; + BGZF *fp = bp->fp; + bcf1_t *b; + int ret; + + b = calloc(1, sizeof(bcf1_t)); + str = calloc(1, sizeof(kstring_t)); + idx = (bcf_idx_t*)calloc(1, sizeof(bcf_idx_t)); + idx->n = h->n_ref; + idx->index2 = calloc(h->n_ref, sizeof(bcf_lidx_t)); + + last_tid = 0xffffffffu; + last_off = bgzf_tell(fp); last_coor = 0xffffffffu; + while ((ret = bcf_read(bp, h, b)) > 0) { + int end, tmp; + if (last_tid != b->tid) { // change of chromosomes + last_tid = b->tid; + } else if (last_coor > b->pos) { + fprintf(pysamerr, "[bcf_idx_core] the input is out of order\n"); + free(str->s); free(str); free(idx); bcf_destroy(b); + return 0; + } + tmp = strlen(b->ref); + end = b->pos + (tmp > 0? tmp : 1); + insert_offset2(&idx->index2[b->tid], b->pos, end, last_off); + last_off = bgzf_tell(fp); + last_coor = b->pos; + } + free(str->s); free(str); bcf_destroy(b); + return idx; +} + +void bcf_idx_destroy(bcf_idx_t *idx) +{ + int i; + if (idx == 0) return; + for (i = 0; i < idx->n; ++i) free(idx->index2[i].offset); + free(idx->index2); + free(idx); +} + +/****************** + * index file I/O * + ******************/ + +void bcf_idx_save(const bcf_idx_t *idx, BGZF *fp) +{ + int32_t i, ti_is_be; + ti_is_be = bam_is_big_endian(); + bgzf_write(fp, "BCI\4", 4); + if (ti_is_be) { + uint32_t x = idx->n; + bgzf_write(fp, bam_swap_endian_4p(&x), 4); + } else bgzf_write(fp, &idx->n, 4); + for (i = 0; i < idx->n; ++i) { + bcf_lidx_t *index2 = idx->index2 + i; + // write linear index (index2) + if (ti_is_be) { + int x = index2->n; + bgzf_write(fp, bam_swap_endian_4p(&x), 4); + } else bgzf_write(fp, &index2->n, 4); + if (ti_is_be) { // big endian + int x; + for (x = 0; (int)x < index2->n; ++x) + bam_swap_endian_8p(&index2->offset[x]); + bgzf_write(fp, index2->offset, 8 * index2->n); + for (x = 0; (int)x < index2->n; ++x) + bam_swap_endian_8p(&index2->offset[x]); + } else bgzf_write(fp, index2->offset, 8 * index2->n); + } +} + +static bcf_idx_t *bcf_idx_load_core(BGZF *fp) +{ + int i, ti_is_be; + char magic[4]; + bcf_idx_t *idx; + ti_is_be = bam_is_big_endian(); + if (fp == 0) { + fprintf(pysamerr, "[%s] fail to load index.\n", __func__); + return 0; + } + bgzf_read(fp, magic, 4); + if (strncmp(magic, "BCI\4", 4)) { + fprintf(pysamerr, "[%s] wrong magic number.\n", __func__); + return 0; + } + idx = (bcf_idx_t*)calloc(1, sizeof(bcf_idx_t)); + bgzf_read(fp, &idx->n, 4); + if (ti_is_be) bam_swap_endian_4p(&idx->n); + idx->index2 = (bcf_lidx_t*)calloc(idx->n, sizeof(bcf_lidx_t)); + for (i = 0; i < idx->n; ++i) { + bcf_lidx_t *index2 = idx->index2 + i; + int j; + bgzf_read(fp, &index2->n, 4); + if (ti_is_be) bam_swap_endian_4p(&index2->n); + index2->m = index2->n; + index2->offset = (uint64_t*)calloc(index2->m, 8); + bgzf_read(fp, index2->offset, index2->n * 8); + if (ti_is_be) + for (j = 0; j < index2->n; ++j) bam_swap_endian_8p(&index2->offset[j]); + } + return idx; +} + +bcf_idx_t *bcf_idx_load_local(const char *fnidx) +{ + BGZF *fp; + fp = bgzf_open(fnidx, "r"); + if (fp) { + bcf_idx_t *idx = bcf_idx_load_core(fp); + bgzf_close(fp); + return idx; + } else return 0; +} + +#ifdef _USE_KNETFILE +static void download_from_remote(const char *url) +{ + const int buf_size = 1 * 1024 * 1024; + char *fn; + FILE *fp; + uint8_t *buf; + knetFile *fp_remote; + int l; + if (strstr(url, "ftp://") != url && strstr(url, "http://") != url) return; + l = strlen(url); + for (fn = (char*)url + l - 1; fn >= url; --fn) + if (*fn == '/') break; + ++fn; // fn now points to the file name + fp_remote = knet_open(url, "r"); + if (fp_remote == 0) { + fprintf(pysamerr, "[download_from_remote] fail to open remote file.\n"); + return; + } + if ((fp = fopen(fn, "w")) == 0) { + fprintf(pysamerr, "[download_from_remote] fail to create file in the working directory.\n"); + knet_close(fp_remote); + return; + } + buf = (uint8_t*)calloc(buf_size, 1); + while ((l = knet_read(fp_remote, buf, buf_size)) != 0) + fwrite(buf, 1, l, fp); + free(buf); + fclose(fp); + knet_close(fp_remote); +} +#else +static void download_from_remote(const char *url) +{ + return; +} +#endif + +static char *get_local_version(const char *fn) +{ + struct stat sbuf; + char *fnidx = (char*)calloc(strlen(fn) + 5, 1); + strcat(strcpy(fnidx, fn), ".bci"); + if ((strstr(fnidx, "ftp://") == fnidx || strstr(fnidx, "http://") == fnidx)) { + char *p, *url; + int l = strlen(fnidx); + for (p = fnidx + l - 1; p >= fnidx; --p) + if (*p == '/') break; + url = fnidx; fnidx = strdup(p + 1); + if (stat(fnidx, &sbuf) == 0) { + free(url); + return fnidx; + } + fprintf(pysamerr, "[%s] downloading the index file...\n", __func__); + download_from_remote(url); + free(url); + } + if (stat(fnidx, &sbuf) == 0) return fnidx; + free(fnidx); return 0; +} + +bcf_idx_t *bcf_idx_load(const char *fn) +{ + bcf_idx_t *idx; + char *fname = get_local_version(fn); + if (fname == 0) return 0; + idx = bcf_idx_load_local(fname); + free(fname); + return idx; +} + +int bcf_idx_build2(const char *fn, const char *_fnidx) +{ + char *fnidx; + BGZF *fpidx; + bcf_t *bp; + bcf_idx_t *idx; + bcf_hdr_t *h; + if ((bp = bcf_open(fn, "r")) == 0) { + fprintf(pysamerr, "[bcf_idx_build2] fail to open the BAM file.\n"); + return -1; + } + h = bcf_hdr_read(bp); + idx = bcf_idx_core(bp, h); + bcf_close(bp); + if (_fnidx == 0) { + fnidx = (char*)calloc(strlen(fn) + 5, 1); + strcpy(fnidx, fn); strcat(fnidx, ".bci"); + } else fnidx = strdup(_fnidx); + fpidx = bgzf_open(fnidx, "w"); + if (fpidx == 0) { + fprintf(pysamerr, "[bcf_idx_build2] fail to create the index file.\n"); + free(fnidx); + return -1; + } + bcf_idx_save(idx, fpidx); + bcf_idx_destroy(idx); + bgzf_close(fpidx); + free(fnidx); + return 0; +} + +int bcf_idx_build(const char *fn) +{ + return bcf_idx_build2(fn, 0); +} + +/******************************************** + * parse a region in the format chr:beg-end * + ********************************************/ + +int bcf_parse_region(void *str2id, const char *str, int *tid, int *begin, int *end) +{ + char *s, *p; + int i, l, k; + l = strlen(str); + p = s = (char*)malloc(l+1); + /* squeeze out "," */ + for (i = k = 0; i != l; ++i) + if (str[i] != ',' && !isspace(str[i])) s[k++] = str[i]; + s[k] = 0; + for (i = 0; i != k; ++i) if (s[i] == ':') break; + s[i] = 0; + if ((*tid = bcf_str2id(str2id, s)) < 0) { + free(s); + return -1; + } + if (i == k) { /* dump the whole sequence */ + *begin = 0; *end = 1<<29; free(s); + return 0; + } + for (p = s + i + 1; i != k; ++i) if (s[i] == '-') break; + *begin = atoi(p); + if (i < k) { + p = s + i + 1; + *end = atoi(p); + } else *end = 1<<29; + if (*begin > 0) --*begin; + free(s); + if (*begin > *end) return -1; + return 0; +} + +/******************************* + * retrieve a specified region * + *******************************/ + +uint64_t bcf_idx_query(const bcf_idx_t *idx, int tid, int beg) +{ + uint64_t min_off, *offset; + int i; + if (beg < 0) beg = 0; + offset = idx->index2[tid].offset; + for (i = beg>>TAD_LIDX_SHIFT; i < idx->index2[tid].n && offset[i] == 0; ++i); + min_off = (i == idx->index2[tid].n)? offset[idx->index2[tid].n-1] : offset[i]; + return min_off; +} + +int bcf_main_index(int argc, char *argv[]) +{ + if (argc == 1) { + fprintf(pysamerr, "Usage: bcftools index \n"); + return 1; + } + bcf_idx_build(argv[1]); + return 0; +} diff --git a/samtools/bcftools/kfunc.c.pysam.c b/samtools/bcftools/kfunc.c.pysam.c new file mode 100644 index 0000000..4de836e --- /dev/null +++ b/samtools/bcftools/kfunc.c.pysam.c @@ -0,0 +1,164 @@ +#include "pysam.h" + +#include + + +/* Log gamma function + * \log{\Gamma(z)} + * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245 + */ +double kf_lgamma(double z) +{ + double x = 0; + x += 0.1659470187408462e-06 / (z+7); + x += 0.9934937113930748e-05 / (z+6); + x -= 0.1385710331296526 / (z+5); + x += 12.50734324009056 / (z+4); + x -= 176.6150291498386 / (z+3); + x += 771.3234287757674 / (z+2); + x -= 1259.139216722289 / (z+1); + x += 676.5203681218835 / z; + x += 0.9999999999995183; + return log(x) - 5.58106146679532777 - z + (z-0.5) * log(z+6.5); +} + +/* complementary error function + * \frac{2}{\sqrt{\pi}} \int_x^{\infty} e^{-t^2} dt + * AS66, 2nd algorithm, http://lib.stat.cmu.edu/apstat/66 + */ +double kf_erfc(double x) +{ + const double p0 = 220.2068679123761; + const double p1 = 221.2135961699311; + const double p2 = 112.0792914978709; + const double p3 = 33.912866078383; + const double p4 = 6.37396220353165; + const double p5 = .7003830644436881; + const double p6 = .03526249659989109; + const double q0 = 440.4137358247522; + const double q1 = 793.8265125199484; + const double q2 = 637.3336333788311; + const double q3 = 296.5642487796737; + const double q4 = 86.78073220294608; + const double q5 = 16.06417757920695; + const double q6 = 1.755667163182642; + const double q7 = .08838834764831844; + double expntl, z, p; + z = fabs(x) * M_SQRT2; + if (z > 37.) return x > 0.? 0. : 2.; + expntl = exp(z * z * - .5); + if (z < 10. / M_SQRT2) // for small z + p = expntl * ((((((p6 * z + p5) * z + p4) * z + p3) * z + p2) * z + p1) * z + p0) + / (((((((q7 * z + q6) * z + q5) * z + q4) * z + q3) * z + q2) * z + q1) * z + q0); + else p = expntl / 2.506628274631001 / (z + 1. / (z + 2. / (z + 3. / (z + 4. / (z + .65))))); + return x > 0.? 2. * p : 2. * (1. - p); +} + +/* The following computes regularized incomplete gamma functions. + * Formulas are taken from Wiki, with additional input from Numerical + * Recipes in C (for modified Lentz's algorithm) and AS245 + * (http://lib.stat.cmu.edu/apstat/245). + * + * A good online calculator is available at: + * + * http://www.danielsoper.com/statcalc/calc23.aspx + * + * It calculates upper incomplete gamma function, which equals + * kf_gammaq(s,z)*tgamma(s). + */ + +#define KF_GAMMA_EPS 1e-14 +#define KF_TINY 1e-290 + +// regularized lower incomplete gamma function, by series expansion +static double _kf_gammap(double s, double z) +{ + double sum, x; + int k; + for (k = 1, sum = x = 1.; k < 100; ++k) { + sum += (x *= z / (s + k)); + if (x / sum < KF_GAMMA_EPS) break; + } + return exp(s * log(z) - z - kf_lgamma(s + 1.) + log(sum)); +} +// regularized upper incomplete gamma function, by continued fraction +static double _kf_gammaq(double s, double z) +{ + int j; + double C, D, f; + f = 1. + z - s; C = f; D = 0.; + // Modified Lentz's algorithm for computing continued fraction + // See Numerical Recipes in C, 2nd edition, section 5.2 + for (j = 1; j < 100; ++j) { + double a = j * (s - j), b = (j<<1) + 1 + z - s, d; + D = b + a * D; + if (D < KF_TINY) D = KF_TINY; + C = b + a / C; + if (C < KF_TINY) C = KF_TINY; + D = 1. / D; + d = C * D; + f *= d; + if (fabs(d - 1.) < KF_GAMMA_EPS) break; + } + return exp(s * log(z) - z - kf_lgamma(s) - log(f)); +} + +double kf_gammap(double s, double z) +{ + return z <= 1. || z < s? _kf_gammap(s, z) : 1. - _kf_gammaq(s, z); +} + +double kf_gammaq(double s, double z) +{ + return z <= 1. || z < s? 1. - _kf_gammap(s, z) : _kf_gammaq(s, z); +} + +/* Regularized incomplete beta function. The method is taken from + * Numerical Recipe in C, 2nd edition, section 6.4. The following web + * page calculates the incomplete beta function, which equals + * kf_betai(a,b,x) * gamma(a) * gamma(b) / gamma(a+b): + * + * http://www.danielsoper.com/statcalc/calc36.aspx + */ +static double kf_betai_aux(double a, double b, double x) +{ + double C, D, f; + int j; + if (x == 0.) return 0.; + if (x == 1.) return 1.; + f = 1.; C = f; D = 0.; + // Modified Lentz's algorithm for computing continued fraction + for (j = 1; j < 200; ++j) { + double aa, d; + int m = j>>1; + aa = (j&1)? -(a + m) * (a + b + m) * x / ((a + 2*m) * (a + 2*m + 1)) + : m * (b - m) * x / ((a + 2*m - 1) * (a + 2*m)); + D = 1. + aa * D; + if (D < KF_TINY) D = KF_TINY; + C = 1. + aa / C; + if (C < KF_TINY) C = KF_TINY; + D = 1. / D; + d = C * D; + f *= d; + if (fabs(d - 1.) < KF_GAMMA_EPS) break; + } + return exp(kf_lgamma(a+b) - kf_lgamma(a) - kf_lgamma(b) + a * log(x) + b * log(1.-x)) / a / f; +} +double kf_betai(double a, double b, double x) +{ + return x < (a + 1.) / (a + b + 2.)? kf_betai_aux(a, b, x) : 1. - kf_betai_aux(b, a, 1. - x); +} + +#ifdef KF_MAIN +#include +int main(int argc, char *argv[]) +{ + double x = 5.5, y = 3; + double a, b; + printf("erfc(%lg): %lg, %lg\n", x, erfc(x), kf_erfc(x)); + printf("upper-gamma(%lg,%lg): %lg\n", x, y, kf_gammaq(y, x)*tgamma(y)); + a = 2; b = 2; x = 0.5; + printf("incomplete-beta(%lg,%lg,%lg): %lg\n", a, b, x, kf_betai(a, b, x) / exp(kf_lgamma(a+b) - kf_lgamma(a) - kf_lgamma(b))); + return 0; +} +#endif diff --git a/samtools/bcftools/kmin.c.pysam.c b/samtools/bcftools/kmin.c.pysam.c new file mode 100644 index 0000000..ee7b512 --- /dev/null +++ b/samtools/bcftools/kmin.c.pysam.c @@ -0,0 +1,211 @@ +#include "pysam.h" + +/* The MIT License + + Copyright (c) 2008, 2010 by Attractive Chaos + + 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 +#include +#include +#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, afb and fb 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 index 0000000..6feba45 --- /dev/null +++ b/samtools/bcftools/kmin.h @@ -0,0 +1,46 @@ +/* + Copyright (c) 2008, 2010 by Attractive Chaos + + 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/prob1.c.pysam.c b/samtools/bcftools/prob1.c.pysam.c new file mode 100644 index 0000000..ac33184 --- /dev/null +++ b/samtools/bcftools/prob1.c.pysam.c @@ -0,0 +1,538 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include +#include +#include "prob1.h" + +#include "kseq.h" +KSTREAM_INIT(gzFile, gzread, 16384) + +#define MC_MAX_EM_ITER 16 +#define MC_EM_EPS 1e-5 +#define MC_DEF_INDEL 0.15 + +unsigned char seq_nt4_table[256] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 /*'-'*/, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 +}; + +struct __bcf_p1aux_t { + 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; +}; + +void bcf_p1_indel_prior(bcf_p1aux_t *ma, double x) +{ + int i; + for (i = 0; i < ma->M; ++i) + ma->phi_indel[i] = ma->phi[i] * x; + ma->phi_indel[ma->M] = 1. - ma->phi[ma->M] * x; +} + +static void init_prior(int type, double theta, int M, double *phi) +{ + int i; + if (type == MC_PTYPE_COND2) { + for (i = 0; i <= M; ++i) + phi[i] = 2. * (i + 1) / (M + 1) / (M + 2); + } else if (type == MC_PTYPE_FLAT) { + for (i = 0; i <= M; ++i) + phi[i] = 1. / (M + 1); + } else { + double sum; + for (i = 0, sum = 0.; i < M; ++i) + sum += (phi[i] = theta / (M - i)); + phi[M] = 1. - sum; + } +} + +void bcf_p1_init_prior(bcf_p1aux_t *ma, int type, double theta) +{ + init_prior(type, theta, ma->M, ma->phi); + bcf_p1_indel_prior(ma, MC_DEF_INDEL); +} + +void bcf_p1_init_subprior(bcf_p1aux_t *ma, int type, double theta) +{ + if (ma->n1 <= 0 || ma->n1 >= ma->M) return; + init_prior(type, theta, 2*ma->n1, ma->phi1); + init_prior(type, theta, 2*(ma->n - ma->n1), ma->phi2); +} + +int bcf_p1_read_prior(bcf_p1aux_t *ma, const char *fn) +{ + gzFile fp; + kstring_t s; + kstream_t *ks; + long double sum; + int dret, k; + memset(&s, 0, sizeof(kstring_t)); + fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r"); + ks = ks_init(fp); + memset(ma->phi, 0, sizeof(double) * (ma->M + 1)); + while (ks_getuntil(ks, '\n', &s, &dret) >= 0) { + if (strstr(s.s, "[afs] ") == s.s) { + char *p = s.s + 6; + for (k = 0; k <= ma->M; ++k) { + int x; + double y; + x = strtol(p, &p, 10); + if (x != k && (errno == EINVAL || errno == ERANGE)) return -1; + ++p; + y = strtod(p, &p); + if (y == 0. && (errno == EINVAL || errno == ERANGE)) return -1; + ma->phi[ma->M - k] += y; + } + } + } + ks_destroy(ks); + gzclose(fp); + free(s.s); + for (sum = 0., k = 0; k <= ma->M; ++k) sum += ma->phi[k]; + fprintf(pysamerr, "[prior]"); + for (k = 0; k <= ma->M; ++k) ma->phi[k] /= sum; + for (k = 0; k <= ma->M; ++k) fprintf(pysamerr, " %d:%.3lg", k, ma->phi[ma->M - k]); + fputc('\n', pysamerr); + for (sum = 0., k = 1; k < ma->M; ++k) sum += ma->phi[ma->M - k] * (2.* k * (ma->M - k) / ma->M / (ma->M - 1)); + fprintf(pysamerr, "[%s] heterozygosity=%lf, ", __func__, (double)sum); + for (sum = 0., k = 1; k <= ma->M; ++k) sum += k * ma->phi[ma->M - k] / ma->M; + fprintf(pysamerr, "theta=%lf\n", (double)sum); + bcf_p1_indel_prior(ma, MC_DEF_INDEL); + return 0; +} + +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(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(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; +} + +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_destroy(bcf_p1aux_t *ma) +{ + if (ma) { + 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); + free(ma); + } +} + +static int cal_pdg(const bcf1_t *b, bcf_p1aux_t *ma) +{ + 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[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 + for (j = i; j > 0 && p[j] < p[j-1]; --j) + tmp = p[j], p[j] = p[j-1], p[j-1] = tmp; + for (i = b->n_alleles - 1; i >= 0; --i) + if ((p[i]&0xf) == 0) break; + return i; +} + +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, 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) { + g[i] /= sum; + if (g[i] > max) max = g[i], max_i = i; + } + max = 1. - max; + if (max < 1e-308) max = 1e-308; + q = (int)(-4.343 * log(max) + .499); + if (q > 99) q = 99; + return q<<2|max_i; +} + +#define TINY 1e-20 + +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; + memset(z[0], 0, sizeof(double) * (ma->M + 1)); + memset(z[1], 0, sizeof(double) * (ma->M + 1)); + z[0][0] = 1.; + last_min = last_max = 0; + ma->t = 0.; + 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; + } + } + 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 && 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)); + memset(ma->z2, 0, sizeof(double) * (2 * (ma->n - ma->n1) + 1)); + ma->t1 = ma->t2 = 0.; + mc_cal_y_core(ma, ma->n1); + ma->t2 = ma->t; + memcpy(ma->z2, ma->z, sizeof(double) * (2 * (ma->n - ma->n1) + 1)); + mc_cal_y_core(ma, 0); + // rescale z + x = expl(ma->t - (ma->t1 + ma->t2)); + for (k = 0; k <= ma->M; ++k) ma->z[k] *= x; + } else mc_cal_y_core(ma, 0); +} + +#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, 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; + } +} + +static double mc_cal_afs(bcf_p1aux_t *ma, double *p_ref_folded, double *p_var_folded) +{ + int k; + 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]; + } + return sum / ma->M; +} + +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)) { + ma->PL = (uint8_t*)b->gi[i].data; + ma->PL_len = b->gi[i].len; + 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_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]; + rst->f_flat = 0.; + for (k = 0; k <= ma->M; ++k) { + double p = ma->z[k] / sum; + rst->f_flat += k * p; + } + rst->f_flat /= ma->M; + { // estimate equal-tail credible interval (95% level) + int l, h; + double p; + for (i = 0, p = 0.; i < ma->M; ++i) + if (p + ma->afs1[i] > 0.025) break; + else p += ma->afs1[i]; + l = i; + for (i = ma->M-1, p = 0.; i >= 0; --i) + if (p + ma->afs1[i] > 0.025) break; + else p += ma->afs1[i]; + h = i; + rst->cil = (double)(ma->M - h) / ma->M; rst->cih = (double)(ma->M - l) / ma->M; + } + 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; + fprintf(pysamerr, "[afs]"); + for (k = 0; k <= ma->M; ++k) + fprintf(pysamerr, " %d:%.3lf", k, ma->afs[ma->M - k]); + fprintf(pysamerr, "\n"); + memset(ma->afs, 0, sizeof(double) * (ma->M + 1)); +} diff --git a/samtools/bcftools/prob1.h b/samtools/bcftools/prob1.h new file mode 100644 index 0000000..571f42f --- /dev/null +++ b/samtools/bcftools/prob1.h @@ -0,0 +1,41 @@ +#ifndef BCF_PROB1_H +#define BCF_PROB1_H + +#include "bcf.h" + +struct __bcf_p1aux_t; +typedef struct __bcf_p1aux_t bcf_p1aux_t; + +typedef struct { + 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 cmp[3], p_chi2; // used by contrast2() +} bcf_p1rst_t; + +#define MC_PTYPE_FULL 1 +#define MC_PTYPE_COND2 2 +#define MC_PTYPE_FLAT 3 + +#ifdef __cplusplus +extern "C" { +#endif + + 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(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); + 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 + +#endif diff --git a/samtools/bcftools/vcf.c.pysam.c b/samtools/bcftools/vcf.c.pysam.c new file mode 100644 index 0000000..a30de82 --- /dev/null +++ b/samtools/bcftools/vcf.c.pysam.c @@ -0,0 +1,246 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include "bcf.h" +#include "kstring.h" +#include "kseq.h" +KSTREAM_INIT(gzFile, gzread, 4096) + +typedef struct { + gzFile fp; + FILE *fpout; + kstream_t *ks; + void *refhash; + kstring_t line; + int max_ref; +} vcf_t; + +bcf_hdr_t *vcf_hdr_read(bcf_t *bp) +{ + kstring_t meta, smpl; + int dret; + vcf_t *v; + bcf_hdr_t *h; + if (!bp->is_vcf) return bcf_hdr_read(bp); + h = calloc(1, sizeof(bcf_hdr_t)); + v = (vcf_t*)bp->v; + v->line.l = 0; + memset(&meta, 0, sizeof(kstring_t)); + memset(&smpl, 0, sizeof(kstring_t)); + while (ks_getuntil(v->ks, '\n', &v->line, &dret) >= 0) { + if (v->line.l < 2) continue; + if (v->line.s[0] != '#') return 0; // no sample line + if (v->line.s[0] == '#' && v->line.s[1] == '#') { + kputsn(v->line.s, v->line.l, &meta); kputc('\n', &meta); + } else if (v->line.s[0] == '#') { + int k; + ks_tokaux_t aux; + char *p; + for (p = kstrtok(v->line.s, "\t\n", &aux), k = 0; p; p = kstrtok(0, 0, &aux), ++k) { + if (k >= 9) { + kputsn(p, aux.p - p, &smpl); + kputc('\0', &smpl); + } + } + break; + } + } + kputc('\0', &meta); + h->name = 0; + h->sname = smpl.s; h->l_smpl = smpl.l; + h->txt = meta.s; h->l_txt = meta.l; + bcf_hdr_sync(h); + return h; +} + +bcf_t *vcf_open(const char *fn, const char *mode) +{ + bcf_t *bp; + vcf_t *v; + if (strchr(mode, 'b')) return bcf_open(fn, mode); + bp = calloc(1, sizeof(bcf_t)); + v = calloc(1, sizeof(vcf_t)); + bp->is_vcf = 1; + bp->v = v; + v->refhash = bcf_str2id_init(); + if (strchr(mode, 'r')) { + v->fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r"); + v->ks = ks_init(v->fp); + } else if (strchr(mode, 'w')) + v->fpout = strcmp(fn, "-")? fopen(fn, "w") : stdout; + 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; + if (bp == 0) return -1; + if (!bp->is_vcf) return bcf_close(bp); + v = (vcf_t*)bp->v; + if (v->fp) { + ks_destroy(v->ks); + gzclose(v->fp); + } + if (v->fpout) fclose(v->fpout); + free(v->line.s); + bcf_str2id_thorough_destroy(v->refhash); + free(v); + free(bp); + return 0; +} + +int vcf_hdr_write(bcf_t *bp, const bcf_hdr_t *h) +{ + vcf_t *v = (vcf_t*)bp->v; + 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.1\n"); + fwrite(h->txt, 1, h->l_txt - 1, v->fpout); + } + 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]); + fputc('\n', v->fpout); + return 0; +} + +int vcf_write(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b) +{ + vcf_t *v = (vcf_t*)bp->v; + extern void bcf_fmt_core(const bcf_hdr_t *h, bcf1_t *b, kstring_t *s); + if (!bp->is_vcf) return bcf_write(bp, h, b); + bcf_fmt_core(h, b, &v->line); + fwrite(v->line.s, 1, v->line.l, v->fpout); + fputc('\n', v->fpout); + return v->line.l + 1; +} + +int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b) +{ + int dret, k, i, sync = 0; + vcf_t *v = (vcf_t*)bp->v; + char *p, *q; + kstring_t str, rn; + ks_tokaux_t aux, a2; + if (!bp->is_vcf) return bcf_read(bp, h, b); + v->line.l = 0; + str.l = 0; str.m = b->m_str; str.s = b->str; + rn.l = rn.m = h->l_nm; rn.s = h->name; + if (ks_getuntil(v->ks, '\n', &v->line, &dret) < 0) return -1; + b->n_smpl = h->n_smpl; + for (p = kstrtok(v->line.s, "\t", &aux), k = 0; p; p = kstrtok(0, 0, &aux), ++k) { + *(char*)aux.p = 0; + if (k == 0) { // ref + int tid = bcf_str2id(v->refhash, p); + if (tid < 0) { + tid = bcf_str2id_add(v->refhash, strdup(p)); + kputs(p, &rn); kputc('\0', &rn); + sync = 1; + } + b->tid = tid; + } else if (k == 1) { // pos + b->pos = atoi(p) - 1; + } else if (k == 5) { // qual + b->qual = (p[0] >= '0' && p[0] <= '9')? atof(p) : 0; + } else if (k <= 8) { // variable length strings + kputs(p, &str); kputc('\0', &str); + b->l_str = str.l; b->m_str = str.m; b->str = str.s; + if (k == 8) bcf_sync(b); + } else { // k > 9 + if (strncmp(p, "./.", 3) == 0) { + 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)) { + ((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)) { + int y = b->n_alleles * (b->n_alleles + 1) / 2; + memset((uint8_t*)b->gi[i].data + (k - 9) * y, 0, y); + } else if (b->gi[i].fmt == bcf_str2int("GL", 2)) { + int y = b->n_alleles * (b->n_alleles + 1) / 2; + memset((float*)b->gi[i].data + (k - 9) * y, 0, y * 4); + } + } + goto endblock; + } + 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)) { + 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; + ((uint16_t*)b->gi[i].data)[k-9] = x; + } else if (b->gi[i].fmt == bcf_str2int("PL", 2)) { + int x, y, j; + uint8_t *data = (uint8_t*)b->gi[i].data; + y = b->n_alleles * (b->n_alleles + 1) / 2; + for (j = 0; j < y; ++j) { + x = strtol(q, &q, 10); + if (x > 255) x = 255; + data[(k-9) * y + j] = x; + ++q; + } + } else if (b->gi[i].fmt == bcf_str2int("GL", 2)) { + int j, y; + float x, *data = (float*)b->gi[i].data; + 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 > 0? -x/10. : x; + ++q; + } + } + } + endblock: i = i; + } + } + h->l_nm = rn.l; h->name = rn.s; + if (sync) bcf_hdr_sync(h); + return v->line.l + 1; +} diff --git a/samtools/bedidx.c.pysam.c b/samtools/bedidx.c.pysam.c new file mode 100644 index 0000000..c3ab06f --- /dev/null +++ b/samtools/bedidx.c.pysam.c @@ -0,0 +1,158 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include + +#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); +} diff --git a/samtools/bgzf.c b/samtools/bgzf.c.pysam.c similarity index 89% rename from samtools/bgzf.c rename to samtools/bgzf.c.pysam.c index a6923da..067b89d 100644 --- a/samtools/bgzf.c +++ b/samtools/bgzf.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* The MIT License Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology @@ -111,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; @@ -148,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; @@ -156,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 @@ -177,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; @@ -194,14 +224,21 @@ 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); + { // 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; @@ -214,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; } @@ -254,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; @@ -263,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"); @@ -330,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; @@ -337,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; @@ -431,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; @@ -454,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 @@ -494,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; @@ -504,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; @@ -552,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; @@ -560,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; diff --git a/samtools/bgzf.h b/samtools/bgzf.h index 099ae9a..7295f37 100644 --- a/samtools/bgzf.h +++ b/samtools/bgzf.h @@ -26,7 +26,6 @@ #include #include -#include #include #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 index 0000000..13cf2d2 --- /dev/null +++ b/samtools/cut_target.c.pysam.c @@ -0,0 +1,195 @@ +#include "pysam.h" + +#include +#include +#include +#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] \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; +} diff --git a/samtools/errmod.c.pysam.c b/samtools/errmod.c.pysam.c new file mode 100644 index 0000000..bf62418 --- /dev/null +++ b/samtools/errmod.c.pysam.c @@ -0,0 +1,132 @@ +#include "pysam.h" + +#include +#include "errmod.h" +#include "ksort.h" +KSORT_INIT_GENERIC(uint16_t) + +typedef struct __errmod_coef_t { + double *fk, *beta, *lhet; +} errmod_coef_t; + +typedef struct { + double fsum[16], bsum[16]; + uint32_t c[16]; +} call_aux_t; + +static errmod_coef_t *cal_coef(double depcorr, double eta) +{ + int k, n, q; + long double sum, sum1; + double *lC; + errmod_coef_t *ec; + + ec = calloc(1, sizeof(errmod_coef_t)); + // initialize ->fk + ec->fk = (double*)calloc(256, sizeof(double)); + ec->fk[0] = 1.0; + for (n = 1; n != 256; ++n) + ec->fk[n] = pow(1. - depcorr, n) * (1.0 - eta) + eta; + // initialize ->coef + ec->beta = (double*)calloc(256 * 256 * 64, sizeof(double)); + lC = (double*)calloc(256 * 256, sizeof(double)); + for (n = 1; n != 256; ++n) { + double lgn = lgamma(n+1); + for (k = 1; k <= n; ++k) + lC[n<<8|k] = lgn - lgamma(k+1) - lgamma(n-k+1); + } + for (q = 1; q != 64; ++q) { + double e = pow(10.0, -q/10.0); + double le = log(e); + double le1 = log(1.0 - e); + for (n = 1; n <= 255; ++n) { + double *beta = ec->beta + (q<<16|n<<8); + sum1 = sum = 0.0; + for (k = n; k >= 0; --k, sum1 = sum) { + sum = sum1 + expl(lC[n<<8|k] + k*le + (n-k)*le1); + beta[k] = -10. / M_LN10 * logl(sum1 / sum); + } + } + } + // initialize ->lhet + ec->lhet = (double*)calloc(256 * 256, sizeof(double)); + for (n = 0; n < 256; ++n) + for (k = 0; k < 256; ++k) + ec->lhet[n<<8|k] = lC[n<<8|k] - M_LN2 * n; + free(lC); + return ec; +} + +errmod_t *errmod_init(float depcorr) +{ + errmod_t *em; + em = (errmod_t*)calloc(1, sizeof(errmod_t)); + em->depcorr = depcorr; + em->coef = cal_coef(depcorr, 0.03); + return em; +} + +void errmod_destroy(errmod_t *em) +{ + if (em == 0) return; + free(em->coef->lhet); free(em->coef->fk); free(em->coef->beta); + free(em->coef); free(em); +} +// qual:6, strand:1, base:4 +int errmod_cal(const errmod_t *em, int n, int m, uint16_t *bases, float *q) +{ + call_aux_t aux; + int i, j, k, w[32]; + + if (m > m) return -1; + memset(q, 0, m * m * sizeof(float)); + if (n == 0) return 0; + // calculate aux.esum and aux.fsum + if (n > 255) { // then sample 255 bases + ks_shuffle(uint16_t, n, bases); + n = 255; + } + ks_introsort(uint16_t, n, bases); + memset(w, 0, 32 * sizeof(int)); + memset(&aux, 0, sizeof(call_aux_t)); + for (j = n - 1; j >= 0; --j) { // calculate esum and fsum + uint16_t b = bases[j]; + int q = b>>5 < 4? 4 : b>>5; + if (q > 63) q = 63; + k = b&0x1f; + aux.fsum[k&0xf] += em->coef->fk[w[k]]; + aux.bsum[k&0xf] += em->coef->fk[w[k]] * em->coef->beta[q<<16|n<<8|aux.c[k&0xf]]; + ++aux.c[k&0xf]; + ++w[k]; + } + // generate likelihood + for (j = 0; j != m; ++j) { + float tmp1, tmp3; + int tmp2, bar_e; + // homozygous + for (k = 0, tmp1 = tmp3 = 0.0, tmp2 = 0; k != m; ++k) { + if (k == j) continue; + tmp1 += aux.bsum[k]; tmp2 += aux.c[k]; tmp3 += aux.fsum[k]; + } + if (tmp2) { + bar_e = (int)(tmp1 / tmp3 + 0.499); + if (bar_e > 63) bar_e = 63; + q[j*m+j] = tmp1; + } + // heterozygous + for (k = j + 1; k < m; ++k) { + int cjk = aux.c[j] + aux.c[k]; + for (i = 0, tmp2 = 0, tmp1 = tmp3 = 0.0; i < m; ++i) { + if (i == j || i == k) continue; + tmp1 += aux.bsum[i]; tmp2 += aux.c[i]; tmp3 += aux.fsum[i]; + } + if (tmp2) { + bar_e = (int)(tmp1 / tmp3 + 0.499); + if (bar_e > 63) bar_e = 63; + q[j*m+k] = q[k*m+j] = -4.343 * em->coef->lhet[cjk<<8|aux.c[k]] + tmp1; + } else q[j*m+k] = q[k*m+j] = -4.343 * em->coef->lhet[cjk<<8|aux.c[k]]; // all the bases are either j or k + } + for (k = 0; k != m; ++k) if (q[j*m+k] < 0.0) q[j*m+k] = 0.0; + } + return 0; +} diff --git a/samtools/errmod.h b/samtools/errmod.h new file mode 100644 index 0000000..32c07b6 --- /dev/null +++ b/samtools/errmod.h @@ -0,0 +1,24 @@ +#ifndef ERRMOD_H +#define ERRMOD_H + +#include + +struct __errmod_coef_t; + +typedef struct { + double depcorr; + struct __errmod_coef_t *coef; +} errmod_t; + +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 diff --git a/samtools/faidx.c b/samtools/faidx.c.pysam.c similarity index 89% rename from samtools/faidx.c rename to samtools/faidx.c.pysam.c index dbd8b3e..526a9c0 100644 --- a/samtools/faidx.c +++ b/samtools/faidx.c.pysam.c @@ -1,7 +1,10 @@ +#include "pysam.h" + #include #include #include #include +#include #include "faidx.h" #include "khash.h" @@ -93,7 +96,7 @@ faidx_t *fai_build_core(RAZF *rz) } name[l_name] = '\0'; if (ret == 0) { - fprintf(stderr, "[fai_build_core] the last entry has no sequence\n"); + fprintf(pysamerr, "[fai_build_core] the last entry has no sequence\n"); free(name); fai_destroy(idx); return 0; } @@ -102,7 +105,7 @@ faidx_t *fai_build_core(RAZF *rz) offset = razf_tell(rz); } else { if (state == 3) { - fprintf(stderr, "[fai_build_core] inlined empty line is not allowed in sequence '%s'.\n", name); + fprintf(pysamerr, "[fai_build_core] inlined empty line is not allowed in sequence '%s'.\n", name); free(name); fai_destroy(idx); return 0; } @@ -113,13 +116,13 @@ faidx_t *fai_build_core(RAZF *rz) if (isgraph(c)) ++l2; } while ((ret = razf_read(rz, &c, 1)) && c != '\n'); if (state == 3 && l2) { - fprintf(stderr, "[fai_build_core] different line length in sequence '%s'.\n", name); + fprintf(pysamerr, "[fai_build_core] different line length in sequence '%s'.\n", name); free(name); fai_destroy(idx); return 0; } ++l1; len += l2; if (l2 >= 0x10000) { - fprintf(stderr, "[fai_build_core] line length exceeds 65535 in sequence '%s'.\n", name); + fprintf(pysamerr, "[fai_build_core] line length exceeds 65535 in sequence '%s'.\n", name); free(name); fai_destroy(idx); return 0; } @@ -197,7 +200,7 @@ int fai_build(const char *fn) sprintf(str, "%s.fai", fn); rz = razf_open(fn, "r"); if (rz == 0) { - fprintf(stderr, "[fai_build] fail to open the FASTA file %s\n",fn); + fprintf(pysamerr, "[fai_build] fail to open the FASTA file %s\n",fn); free(str); return -1; } @@ -205,7 +208,7 @@ int fai_build(const char *fn) razf_close(rz); fp = fopen(str, "wb"); if (fp == 0) { - fprintf(stderr, "[fai_build] fail to write FASTA index %s\n",str); + fprintf(pysamerr, "[fai_build] fail to write FASTA index %s\n",str); fai_destroy(fai); free(str); return -1; } @@ -238,11 +241,11 @@ FILE *download_and_open(const char *fn) // If failed, download from remote and open fp_remote = knet_open(url, "rb"); if (fp_remote == 0) { - fprintf(stderr, "[download_from_remote] fail to open remote file %s\n",url); + fprintf(pysamerr, "[download_from_remote] fail to open remote file %s\n",url); return NULL; } if ((fp = fopen(fn, "wb")) == 0) { - fprintf(stderr, "[download_from_remote] fail to create file in the working directory %s\n",fn); + fprintf(pysamerr, "[download_from_remote] fail to create file in the working directory %s\n",fn); knet_close(fp_remote); return NULL; } @@ -271,7 +274,7 @@ faidx_t *fai_load(const char *fn) fp = download_and_open(str); if ( !fp ) { - fprintf(stderr, "[fai_load] failed to open remote FASTA index %s\n", str); + fprintf(pysamerr, "[fai_load] failed to open remote FASTA index %s\n", str); free(str); return 0; } @@ -280,11 +283,11 @@ faidx_t *fai_load(const char *fn) #endif fp = fopen(str, "rb"); if (fp == 0) { - fprintf(stderr, "[fai_load] build FASTA index.\n"); + fprintf(pysamerr, "[fai_load] build FASTA index.\n"); fai_build(fn); fp = fopen(str, "rb"); if (fp == 0) { - fprintf(stderr, "[fai_load] fail to open FASTA index.\n"); + fprintf(pysamerr, "[fai_load] fail to open FASTA index.\n"); free(str); return 0; } @@ -296,7 +299,7 @@ faidx_t *fai_load(const char *fn) fai->rz = razf_open(fn, "rb"); free(str); if (fai->rz == 0) { - fprintf(stderr, "[fai_load] fail to open FASTA file.\n"); + fprintf(pysamerr, "[fai_load] fail to open FASTA file.\n"); return 0; } return fai; @@ -357,7 +360,7 @@ char *fai_fetch(const faidx_t *fai, const char *str, int *len) int faidx_main(int argc, char *argv[]) { if (argc == 1) { - fprintf(stderr, "Usage: faidx [ [...]]\n"); + fprintf(pysamerr, "Usage: faidx [ [...]]\n"); return 1; } else { if (argc == 2) fai_build(argv[1]); diff --git a/samtools/glf.c b/samtools/glf.c.pysam.c similarity index 95% rename from samtools/glf.c rename to samtools/glf.c.pysam.c index 8d5346a..099d4ac 100644 --- a/samtools/glf.c +++ b/samtools/glf.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include "glf.h" @@ -38,7 +40,7 @@ glf3_header_t *glf3_header_read(glfFile fp) h = glf3_header_init(); bgzf_read(fp, magic, 4); if (strncmp(magic, "GLF\3", 4)) { - fprintf(stderr, "[glf3_header_read] invalid magic.\n"); + fprintf(pysamerr, "[glf3_header_read] invalid magic.\n"); glf3_header_destroy(h); return 0; } @@ -74,7 +76,7 @@ char *glf3_ref_read(glfFile fp, int *len) if (bgzf_read(fp, &n, 4) != 4) return 0; if (glf3_is_BE) n = bam_swap_endian_4(n); if (n < 0) { - fprintf(stderr, "[glf3_ref_read] invalid reference name length: %d.\n", n); + fprintf(pysamerr, "[glf3_ref_read] invalid reference name length: %d.\n", n); return 0; } str = (char*)calloc(n + 1, 1); // not necesarily n+1 in fact @@ -215,12 +217,12 @@ int glf3_view_main(int argc, char *argv[]) { glfFile fp; if (argc == 1) { - fprintf(stderr, "Usage: glfview \n"); + fprintf(pysamerr, "Usage: glfview \n"); return 1; } fp = (strcmp(argv[1], "-") == 0)? bgzf_fdopen(fileno(stdin), "r") : bgzf_open(argv[1], "r"); if (fp == 0) { - fprintf(stderr, "Fail to open file '%s'\n", argv[1]); + fprintf(pysamerr, "Fail to open file '%s'\n", argv[1]); return 1; } glf3_view(fp); diff --git a/samtools/kaln.c b/samtools/kaln.c.pysam.c similarity index 70% rename from samtools/kaln.c rename to samtools/kaln.c.pysam.c index 9fa40d0..953a214 100644 --- a/samtools/kaln.c +++ b/samtools/kaln.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* The MIT License Copyright (c) 2003-2006, 2008, 2009, by Heng Li @@ -27,6 +29,7 @@ #include #include #include +#include #include "kaln.h" #define FROM_M 0 @@ -72,8 +75,18 @@ int aln_sm_blast[] = { -2, -2, -2, -2, -2 }; -ka_param_t ka_param_blast = { 5, 2, 2, aln_sm_blast, 5, 50 }; -ka_param_t ka_param_aa2aa = { 10, 2, 2, aln_sm_blosum62, 22, 50 }; +int aln_sm_qual[] = { + 0, -23, -23, -23, 0, + -23, 0, -23, -23, 0, + -23, -23, 0, -23, 0, + -23, -23, -23, 0, 0, + 0, 0, 0, 0, 0 +}; + +ka_param_t ka_param_blast = { 5, 2, 5, 2, aln_sm_blast, 5, 50 }; +ka_param_t ka_param_aa2aa = { 10, 2, 10, 2, aln_sm_blosum62, 22, 50 }; + +ka_param2_t ka_param2_qual = { 37, 11, 37, 11, 37, 11, 0, 0, aln_sm_qual, 5, 50 }; static uint32_t *ka_path2cigar32(const path_t *path, int path_len, int *n_cigar) { @@ -141,13 +154,13 @@ static uint32_t *ka_path2cigar32(const path_t *path, int path_len, int *n_cigar) } #define set_end_I(II, cur, p) \ { \ - if (gap_end >= 0) { \ - if ((p)->M - gap_open > (p)->I) { \ + if (gap_end_ext >= 0) { \ + if ((p)->M - gap_end_open > (p)->I) { \ (cur)->It = FROM_M; \ - (II) = (p)->M - gap_open - gap_end; \ + (II) = (p)->M - gap_end_open - gap_end_ext; \ } else { \ (cur)->It = FROM_I; \ - (II) = (p)->I - gap_end; \ + (II) = (p)->I - gap_end_ext; \ } \ } else set_I(II, cur, p); \ } @@ -163,19 +176,19 @@ static uint32_t *ka_path2cigar32(const path_t *path, int path_len, int *n_cigar) } #define set_end_D(DD, cur, p) \ { \ - if (gap_end >= 0) { \ - if ((p)->M - gap_open > (p)->D) { \ + if (gap_end_ext >= 0) { \ + if ((p)->M - gap_end_open > (p)->D) { \ (cur)->Dt = FROM_M; \ - (DD) = (p)->M - gap_open - gap_end; \ + (DD) = (p)->M - gap_end_open - gap_end_ext; \ } else { \ (cur)->Dt = FROM_D; \ - (DD) = (p)->D - gap_end; \ + (DD) = (p)->D - gap_end_ext; \ } \ } else set_D(DD, cur, p); \ } typedef struct { - uint8_t Mt:3, It:2, Dt:2; + uint8_t Mt:3, It:2, Dt:3; } dpcell_t; typedef struct { @@ -195,18 +208,19 @@ uint32_t *ka_global_core(uint8_t *seq1, int len1, uint8_t *seq2, int len2, const uint8_t type, ctype; uint32_t *cigar = 0; - int gap_open, gap_ext, gap_end, b; + int gap_open, gap_ext, gap_end_open, gap_end_ext, b; int *score_matrix, N_MATRIX_ROW; /* initialize some align-related parameters. just for compatibility */ gap_open = ap->gap_open; gap_ext = ap->gap_ext; - gap_end = ap->gap_end; + gap_end_open = ap->gap_end_open; + gap_end_ext = ap->gap_end_ext; b = ap->band_width; score_matrix = ap->matrix; N_MATRIX_ROW = ap->row; - *n_cigar = 0; + if (n_cigar) *n_cigar = 0; if (len1 == 0 || len2 == 0) return 0; /* calculate b1 and b2 */ @@ -368,3 +382,107 @@ uint32_t *ka_global_core(uint8_t *seq1, int len1, uint8_t *seq2, int len2, const return cigar; } + +typedef struct { + int M, I, D; +} score_aux_t; + +#define MINUS_INF -0x40000000 + +// matrix: len2 rows and len1 columns +int ka_global_score(const uint8_t *_seq1, int len1, const uint8_t *_seq2, int len2, const ka_param2_t *ap) +{ + +#define __score_aux(_p, _q0, _sc, _io, _ie, _do, _de) { \ + int t1, t2; \ + score_aux_t *_q; \ + _q = _q0; \ + _p->M = _q->M >= _q->I? _q->M : _q->I; \ + _p->M = _p->M >= _q->D? _p->M : _q->D; \ + _p->M += (_sc); \ + ++_q; t1 = _q->M - _io - _ie; t2 = _q->I - _ie; _p->I = t1 >= t2? t1 : t2; \ + _q = _p-1; t1 = _q->M - _do - _de; t2 = _q->D - _de; _p->D = t1 >= t2? t1 : t2; \ + } + + int i, j, bw, scmat_size = ap->row, *scmat = ap->matrix, ret; + const uint8_t *seq1, *seq2; + score_aux_t *curr, *last, *swap; + bw = abs(len1 - len2) + ap->band_width; + i = len1 > len2? len1 : len2; + if (bw > i + 1) bw = i + 1; + seq1 = _seq1 - 1; seq2 = _seq2 - 1; + curr = calloc(len1 + 2, sizeof(score_aux_t)); + last = calloc(len1 + 2, sizeof(score_aux_t)); + { // the zero-th row + int x, end = len1; + score_aux_t *p; + j = 0; + x = j + bw; end = len1 < x? len1 : x; // band end + p = curr; + p->M = 0; p->I = p->D = MINUS_INF; + for (i = 1, p = &curr[1]; i <= end; ++i, ++p) + p->M = p->I = MINUS_INF, p->D = -(ap->edo + ap->ede * i); + p->M = p->I = p->D = MINUS_INF; + swap = curr; curr = last; last = swap; + } + for (j = 1; j < len2; ++j) { + int x, beg = 0, end = len1, *scrow, col_end; + score_aux_t *p; + x = j - bw; beg = 0 > x? 0 : x; // band start + x = j + bw; end = len1 < x? len1 : x; // band end + if (beg == 0) { // from zero-th column + p = curr; + p->M = p->D = MINUS_INF; p->I = -(ap->eio + ap->eie * j); + ++beg; // then beg = 1 + } + scrow = scmat + seq2[j] * scmat_size; + if (end == len1) col_end = 1, --end; + else col_end = 0; + for (i = beg, p = &curr[beg]; i <= end; ++i, ++p) + __score_aux(p, &last[i-1], scrow[(int)seq1[i]], ap->iio, ap->iie, ap->ido, ap->ide); + if (col_end) { + __score_aux(p, &last[i-1], scrow[(int)seq1[i]], ap->eio, ap->eie, ap->ido, ap->ide); + ++p; + } + p->M = p->I = p->D = MINUS_INF; +// for (i = 0; i <= len1; ++i) printf("(%d,%d,%d) ", curr[i].M, curr[i].I, curr[i].D); putchar('\n'); + swap = curr; curr = last; last = swap; + } + { // the last row + int x, beg = 0, *scrow; + score_aux_t *p; + j = len2; + x = j - bw; beg = 0 > x? 0 : x; // band start + if (beg == 0) { // from zero-th column + p = curr; + p->M = p->D = MINUS_INF; p->I = -(ap->eio + ap->eie * j); + ++beg; // then beg = 1 + } + scrow = scmat + seq2[j] * scmat_size; + for (i = beg, p = &curr[beg]; i < len1; ++i, ++p) + __score_aux(p, &last[i-1], scrow[(int)seq1[i]], ap->iio, ap->iie, ap->edo, ap->ede); + __score_aux(p, &last[i-1], scrow[(int)seq1[i]], ap->eio, ap->eie, ap->edo, ap->ede); +// for (i = 0; i <= len1; ++i) printf("(%d,%d,%d) ", curr[i].M, curr[i].I, curr[i].D); putchar('\n'); + } + ret = curr[len1].M >= curr[len1].I? curr[len1].M : curr[len1].I; + ret = ret >= curr[len1].D? ret : curr[len1].D; + free(curr); free(last); + return ret; +} + +#ifdef _MAIN +int main(int argc, char *argv[]) +{ +// int len1 = 35, len2 = 35; +// uint8_t *seq1 = (uint8_t*)"\0\0\3\3\2\0\0\0\1\0\2\1\2\1\3\2\3\3\3\0\2\3\2\1\1\3\3\3\2\3\3\1\0\0\1"; +// uint8_t *seq2 = (uint8_t*)"\0\0\3\3\2\0\0\0\1\0\2\1\2\1\3\2\3\3\3\0\2\3\2\1\1\3\3\3\2\3\3\1\0\1\0"; + int len1 = 4, len2 = 4; + uint8_t *seq1 = (uint8_t*)"\1\0\0\1"; + uint8_t *seq2 = (uint8_t*)"\1\0\1\0"; + int sc; +// ka_global_core(seq1, 2, seq2, 1, &ka_param_qual, &sc, 0); + sc = ka_global_score(seq1, len1, seq2, len2, &ka_param2_qual); + printf("%d\n", sc); + return 0; +} +#endif diff --git a/samtools/kaln.h b/samtools/kaln.h index b04d8cc..1ece132 100644 --- a/samtools/kaln.h +++ b/samtools/kaln.h @@ -33,23 +33,35 @@ typedef struct { int gap_open; int gap_ext; - int gap_end; + int gap_end_open; + int gap_end_ext; int *matrix; int row; int band_width; } ka_param_t; +typedef struct { + int iio, iie, ido, ide; + int eio, eie, edo, ede; + int *matrix; + int row; + int band_width; +} ka_param2_t; + #ifdef __cplusplus extern "C" { #endif - uint32_t *ka_global_core(uint8_t *seq1, int len1, uint8_t *seq2, int len2, const ka_param_t *ap, int *_score, int *n_cigar); - + uint32_t *ka_global_core(uint8_t *seq1, int len1, uint8_t *seq2, int len2, const ka_param_t *ap, + int *_score, int *n_cigar); + int ka_global_score(const uint8_t *_seq1, int len1, const uint8_t *_seq2, int len2, const ka_param2_t *ap); #ifdef __cplusplus } #endif -extern ka_param_t ka_param_blast; /* = { 5, 2, 2, aln_sm_blast, 5, 50 }; */ +extern ka_param_t ka_param_blast; /* = { 5, 2, 5, 2, aln_sm_blast, 5, 50 }; */ +extern ka_param_t ka_param_qual; // only use this for global alignment!!! +extern ka_param2_t ka_param2_qual; // only use this for global alignment!!! #endif diff --git a/samtools/khash.h b/samtools/khash.h index 1d583ef..a7e8056 100644 --- a/samtools/khash.h +++ b/samtools/khash.h @@ -1,6 +1,6 @@ /* The MIT License - Copyright (c) 2008 Genome Research Ltd (GRL). + Copyright (c) 2008, 2009, 2011 by Attractive Chaos 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 */ - /* 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 #include #include +#include + +/* 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 diff --git a/samtools/knetfile.c b/samtools/knetfile.c.pysam.c similarity index 94% rename from samtools/knetfile.c rename to samtools/knetfile.c.pysam.c index e1be4d6..25bbafe 100644 --- a/samtools/knetfile.c +++ b/samtools/knetfile.c.pysam.c @@ -1,6 +1,9 @@ +#include "pysam.h" + /* The MIT License - Copyright (c) 2008 Genome Research Ltd (GRL). + Copyright (c) 2008 by Genome Research Ltd (GRL). + 2010 by Attractive Chaos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -23,11 +26,9 @@ SOFTWARE. */ -/* Contact: Heng Li */ - /* 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 #include @@ -73,9 +74,9 @@ static int socket_wait(int fd, int is_read) if (ret == -1) perror("select"); #else if (ret == 0) - fprintf(stderr, "select time-out\n"); + fprintf(pysamerr, "select time-out\n"); else if (ret == SOCKET_ERROR) - fprintf(stderr, "select: %d\n", WSAGetLastError()); + fprintf(pysamerr, "select: %d\n", WSAGetLastError()); #endif return ret; } @@ -90,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; @@ -149,7 +150,7 @@ static SOCKET socket_connect(const char *host, const char *port) { #define __err_connect(func) \ do { \ - fprintf(stderr, "%s: %d\n", func, WSAGetLastError()); \ + fprintf(pysamerr, "%s: %d\n", func, WSAGetLastError()); \ return -1; \ } while (0) @@ -213,7 +214,7 @@ static int kftp_get_response(knetFile *ftp) char *p; if (socket_wait(ftp->ctrl_fd, 1) <= 0) return 0; while (netread(ftp->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O - //fputc(c, stderr); + //fputc(c, pysamerr); if (n >= ftp->max_response) { ftp->max_response = ftp->max_response? ftp->max_response<<1 : 256; ftp->response = realloc(ftp->response, ftp->max_response); @@ -257,7 +258,7 @@ static int kftp_pasv_connect(knetFile *ftp) { char host[80], port[10]; if (ftp->pasv_port == 0) { - fprintf(stderr, "[kftp_pasv_connect] kftp_pasv_prep() is not called before hand.\n"); + fprintf(pysamerr, "[kftp_pasv_connect] kftp_pasv_prep() is not called before hand.\n"); return -1; } sprintf(host, "%d.%d.%d.%d", ftp->pasv_ip[0], ftp->pasv_ip[1], ftp->pasv_ip[2], ftp->pasv_ip[3]); @@ -329,7 +330,7 @@ int kftp_connect_file(knetFile *fp) #ifndef _WIN32 if ( sscanf(fp->response,"%*d %lld", &file_size) != 1 ) { - fprintf(stderr,"[kftp_connect_file] %s\n", fp->response); + fprintf(pysamerr,"[kftp_connect_file] %s\n", fp->response); return -1; } #else @@ -354,7 +355,7 @@ int kftp_connect_file(knetFile *fp) kftp_pasv_connect(fp); ret = kftp_get_response(fp); if (ret != 150) { - fprintf(stderr, "[kftp_connect_file] %s\n", fp->response); + fprintf(pysamerr, "[kftp_connect_file] %s\n", fp->response); netclose(fp->fd); fp->fd = -1; return -1; @@ -435,7 +436,7 @@ int khttp_connect_file(knetFile *fp) } } else if (ret != 206 && ret != 200) { free(buf); - fprintf(stderr, "[khttp_connect_file] fail to open file (HTTP code: %d).\n", ret); + fprintf(pysamerr, "[khttp_connect_file] fail to open file (HTTP code: %d).\n", ret); netclose(fp->fd); fp->fd = -1; return -1; @@ -453,7 +454,7 @@ knetFile *knet_open(const char *fn, const char *mode) { knetFile *fp = 0; if (mode[0] != 'r') { - fprintf(stderr, "[kftp_open] only mode \"r\" is supported.\n"); + fprintf(pysamerr, "[kftp_open] only mode \"r\" is supported.\n"); return 0; } if (strstr(fn, "ftp://") == fn) { @@ -517,7 +518,10 @@ off_t knet_read(knetFile *fp, void *buf, off_t len) if (fp->type == KNF_TYPE_LOCAL) { // on Windows, the following block is necessary; not on UNIX off_t rest = len, curr; while (rest) { - curr = read(fp->fd, buf + l, rest); + do { + curr = read(fp->fd, buf + l, rest); + } while (curr < 0 && EINTR == errno); + if (curr < 0) return -1; if (curr == 0) break; l += curr; rest -= curr; } @@ -535,7 +539,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) off_t offset = lseek(fp->fd, off, whence); if (offset == -1) { // Be silent, it is OK for knet_seek to fail when the file is streamed - // fprintf(stderr,"[knet_seek] %s\n", strerror(errno)); + // fprintf(pysamerr,"[knet_seek] %s\n", strerror(errno)); return -1; } fp->offset = offset; @@ -555,7 +559,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) else if (fp->type == KNF_TYPE_HTTP) { if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future? - fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n"); + fprintf(pysamerr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n"); errno = ESPIPE; return -1; } @@ -567,7 +571,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) return 0; } errno = EINVAL; - fprintf(stderr,"[knet_seek] %s\n", strerror(errno)); + fprintf(pysamerr,"[knet_seek] %s\n", strerror(errno)); return -1; } diff --git a/samtools/kprobaln.c.pysam.c b/samtools/kprobaln.c.pysam.c new file mode 100644 index 0000000..b87dcf0 --- /dev/null +++ b/samtools/kprobaln.c.pysam.c @@ -0,0 +1,280 @@ +#include "pysam.h" + +/* The MIT License + + Copyright (c) 2003-2006, 2008-2010, by Heng Li + + 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. +*/ + +#include +#include +#include +#include +#include +#include "kprobaln.h" + +/***************************************** + * Probabilistic banded glocal alignment * + *****************************************/ + +#define EI .25 +#define EM .33333333333 + +static float g_qual2prob[256]; + +#define set_u(u, b, i, k) { int x=(i)-(b); x=x>0?x:0; (u)=((k)-x+1)*3; } + +kpa_par_t kpa_par_def = { 0.001, 0.1, 10 }; +kpa_par_t kpa_par_alt = { 0.0001, 0.01, 10 }; + +/* + The topology of the profile HMM: + + /\ /\ /\ /\ + I[1] I[k-1] I[k] I[L] + ^ \ \ ^ \ ^ \ \ ^ + | \ \ | \ | \ \ | + M[0] M[1] -> ... -> M[k-1] -> M[k] -> ... -> M[L] M[L+1] + \ \/ \/ \/ / + \ /\ /\ /\ / + -> D[k-1] -> D[k] -> + + M[0] points to every {M,I}[k] and every {M,I}[k] points M[L+1]. + + On input, _ref is the reference sequence and _query is the query + sequence. Both are sequences of 0/1/2/3/4 where 4 stands for an + ambiguous residue. iqual is the base quality. c sets the gap open + probability, gap extension probability and band width. + + On output, state and q are arrays of length l_query. The higher 30 + bits give the reference position the query base is matched to and the + lower two bits can be 0 (an alignment match) or 1 (an + insertion). q[i] gives the phred scaled posterior probability of + state[i] being wrong. + */ +int kpa_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_query, const uint8_t *iqual, + const kpa_par_t *c, int *state, uint8_t *q) +{ + double **f, **b = 0, *s, m[9], sI, sM, bI, bM, pb; + float *qual, *_qual; + const uint8_t *ref, *query; + int bw, bw2, i, k, is_diff = 0, is_backward = 1, Pr; + + /*** initialization ***/ + is_backward = state && q? 1 : 0; + ref = _ref - 1; query = _query - 1; // change to 1-based coordinate + bw = l_ref > l_query? l_ref : l_query; + if (bw > c->bw) bw = c->bw; + if (bw < abs(l_ref - l_query)) bw = abs(l_ref - l_query); + bw2 = bw * 2 + 1; + // allocate the forward and backward matrices f[][] and b[][] and the scaling array s[] + f = calloc(l_query+1, sizeof(void*)); + if (is_backward) b = calloc(l_query+1, sizeof(void*)); + for (i = 0; i <= l_query; ++i) { + f[i] = calloc(bw2 * 3 + 6, sizeof(double)); // FIXME: this is over-allocated for very short seqs + if (is_backward) b[i] = calloc(bw2 * 3 + 6, sizeof(double)); + } + s = calloc(l_query+2, sizeof(double)); // s[] is the scaling factor to avoid underflow + // initialize qual + _qual = calloc(l_query, sizeof(float)); + if (g_qual2prob[0] == 0) + for (i = 0; i < 256; ++i) + g_qual2prob[i] = pow(10, -i/10.); + for (i = 0; i < l_query; ++i) _qual[i] = g_qual2prob[iqual? iqual[i] : 30]; + qual = _qual - 1; + // initialize transition probability + sM = sI = 1. / (2 * l_query + 2); // the value here seems not to affect results; FIXME: need proof + m[0*3+0] = (1 - c->d - c->d) * (1 - sM); m[0*3+1] = m[0*3+2] = c->d * (1 - sM); + m[1*3+0] = (1 - c->e) * (1 - sI); m[1*3+1] = c->e * (1 - sI); m[1*3+2] = 0.; + m[2*3+0] = 1 - c->e; m[2*3+1] = 0.; m[2*3+2] = c->e; + bM = (1 - c->d) / l_ref; bI = c->d / l_ref; // (bM+bI)*l_ref==1 + /*** forward ***/ + // f[0] + set_u(k, bw, 0, 0); + f[0][k] = s[0] = 1.; + { // f[1] + double *fi = f[1], sum; + int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1, _beg, _end; + for (k = beg, sum = 0.; k <= end; ++k) { + int u; + double e = (ref[k] > 3 || query[1] > 3)? 1. : ref[k] == query[1]? 1. - qual[1] : qual[1] * EM; + set_u(u, bw, 1, k); + fi[u+0] = e * bM; fi[u+1] = EI * bI; + sum += fi[u] + fi[u+1]; + } + // rescale + s[1] = sum; + set_u(_beg, bw, 1, beg); set_u(_end, bw, 1, end); _end += 2; + for (k = _beg; k <= _end; ++k) fi[k] /= sum; + } + // f[2..l_query] + for (i = 2; i <= l_query; ++i) { + double *fi = f[i], *fi1 = f[i-1], sum, qli = qual[i]; + int beg = 1, end = l_ref, x, _beg, _end; + uint8_t qyi = query[i]; + x = i - bw; beg = beg > x? beg : x; // band start + x = i + bw; end = end < x? end : x; // band end + for (k = beg, sum = 0.; k <= end; ++k) { + int u, v11, v01, v10; + double e; + e = (ref[k] > 3 || qyi > 3)? 1. : ref[k] == qyi? 1. - qli : qli * EM; + set_u(u, bw, i, k); set_u(v11, bw, i-1, k-1); set_u(v10, bw, i-1, k); set_u(v01, bw, i, k-1); + fi[u+0] = e * (m[0] * fi1[v11+0] + m[3] * fi1[v11+1] + m[6] * fi1[v11+2]); + fi[u+1] = EI * (m[1] * fi1[v10+0] + m[4] * fi1[v10+1]); + fi[u+2] = m[2] * fi[v01+0] + m[8] * fi[v01+2]; + sum += fi[u] + fi[u+1] + fi[u+2]; +// fprintf(pysamerr, "F (%d,%d;%d): %lg,%lg,%lg\n", i, k, u, fi[u], fi[u+1], fi[u+2]); // DEBUG + } + // rescale + s[i] = sum; + set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2; + for (k = _beg, sum = 1./sum; k <= _end; ++k) fi[k] *= sum; + } + { // f[l_query+1] + double sum; + for (k = 1, sum = 0.; k <= l_ref; ++k) { + int u; + set_u(u, bw, l_query, k); + if (u < 3 || u >= bw2*3+3) continue; + sum += f[l_query][u+0] * sM + f[l_query][u+1] * sI; + } + s[l_query+1] = sum; // the last scaling factor + } + { // compute likelihood + double p = 1., Pr1 = 0.; + for (i = 0; i <= l_query + 1; ++i) { + p *= s[i]; + if (p < 1e-100) Pr += -4.343 * log(p), p = 1.; + } + Pr1 += -4.343 * log(p * l_ref * l_query); + Pr = (int)(Pr1 + .499); + if (!is_backward) { // skip backward and MAP + for (i = 0; i <= l_query; ++i) free(f[i]); + free(f); free(s); free(_qual); + return Pr; + } + } + /*** backward ***/ + // b[l_query] (b[l_query+1][0]=1 and thus \tilde{b}[][]=1/s[l_query+1]; this is where s[l_query+1] comes from) + for (k = 1; k <= l_ref; ++k) { + int u; + double *bi = b[l_query]; + set_u(u, bw, l_query, k); + if (u < 3 || u >= bw2*3+3) continue; + bi[u+0] = sM / s[l_query] / s[l_query+1]; bi[u+1] = sI / s[l_query] / s[l_query+1]; + } + // b[l_query-1..1] + for (i = l_query - 1; i >= 1; --i) { + int beg = 1, end = l_ref, x, _beg, _end; + double *bi = b[i], *bi1 = b[i+1], y = (i > 1), qli1 = qual[i+1]; + uint8_t qyi1 = query[i+1]; + x = i - bw; beg = beg > x? beg : x; + x = i + bw; end = end < x? end : x; + for (k = end; k >= beg; --k) { + int u, v11, v01, v10; + double e; + set_u(u, bw, i, k); set_u(v11, bw, i+1, k+1); set_u(v10, bw, i+1, k); set_u(v01, bw, i, k+1); + e = (k >= l_ref? 0 : (ref[k+1] > 3 || qyi1 > 3)? 1. : ref[k+1] == qyi1? 1. - qli1 : qli1 * EM) * bi1[v11]; + bi[u+0] = e * m[0] + EI * m[1] * bi1[v10+1] + m[2] * bi[v01+2]; // bi1[v11] has been foled into e. + bi[u+1] = e * m[3] + EI * m[4] * bi1[v10+1]; + bi[u+2] = (e * m[6] + m[8] * bi[v01+2]) * y; +// fprintf(pysamerr, "B (%d,%d;%d): %lg,%lg,%lg\n", i, k, u, bi[u], bi[u+1], bi[u+2]); // DEBUG + } + // rescale + set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2; + for (k = _beg, y = 1./s[i]; k <= _end; ++k) bi[k] *= y; + } + { // b[0] + int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1; + double sum = 0.; + for (k = end; k >= beg; --k) { + int u; + double e = (ref[k] > 3 || query[1] > 3)? 1. : ref[k] == query[1]? 1. - qual[1] : qual[1] * EM; + set_u(u, bw, 1, k); + if (u < 3 || u >= bw2*3+3) continue; + sum += e * b[1][u+0] * bM + EI * b[1][u+1] * bI; + } + set_u(k, bw, 0, 0); + pb = b[0][k] = sum / s[0]; // if everything works as is expected, pb == 1.0 + } + is_diff = fabs(pb - 1.) > 1e-7? 1 : 0; + /*** MAP ***/ + for (i = 1; i <= l_query; ++i) { + double sum = 0., *fi = f[i], *bi = b[i], max = 0.; + int beg = 1, end = l_ref, x, max_k = -1; + x = i - bw; beg = beg > x? beg : x; + x = i + bw; end = end < x? end : x; + for (k = beg; k <= end; ++k) { + int u; + double z; + set_u(u, bw, i, k); + z = fi[u+0] * bi[u+0]; if (z > max) max = z, max_k = (k-1)<<2 | 0; sum += z; + z = fi[u+1] * bi[u+1]; if (z > max) max = z, max_k = (k-1)<<2 | 1; sum += z; + } + max /= sum; sum *= s[i]; // if everything works as is expected, sum == 1.0 + if (state) state[i-1] = max_k; + if (q) k = (int)(-4.343 * log(1. - max) + .499), q[i-1] = k > 100? 99 : k; +#ifdef _MAIN + fprintf(pysamerr, "(%.10lg,%.10lg) (%d,%d:%c,%c:%d) %lg\n", pb, sum, i-1, max_k>>2, + "ACGT"[query[i]], "ACGT"[ref[(max_k>>2)+1]], max_k&3, max); // DEBUG +#endif + } + /*** free ***/ + for (i = 0; i <= l_query; ++i) { + free(f[i]); free(b[i]); + } + free(f); free(b); free(s); free(_qual); + return Pr; +} + +#ifdef _MAIN +#include +int main(int argc, char *argv[]) +{ + uint8_t conv[256], *iqual, *ref, *query; + int c, l_ref, l_query, i, q = 30, b = 10, P; + while ((c = getopt(argc, argv, "b:q:")) >= 0) { + switch (c) { + case 'b': b = atoi(optarg); break; + case 'q': q = atoi(optarg); break; + } + } + if (optind + 2 > argc) { + fprintf(pysamerr, "Usage: %s [-q %d] [-b %d] \n", argv[0], q, b); // example: acttc attc + return 1; + } + memset(conv, 4, 256); + conv['a'] = conv['A'] = 0; conv['c'] = conv['C'] = 1; + conv['g'] = conv['G'] = 2; conv['t'] = conv['T'] = 3; + ref = (uint8_t*)argv[optind]; query = (uint8_t*)argv[optind+1]; + l_ref = strlen((char*)ref); l_query = strlen((char*)query); + for (i = 0; i < l_ref; ++i) ref[i] = conv[ref[i]]; + for (i = 0; i < l_query; ++i) query[i] = conv[query[i]]; + iqual = malloc(l_query); + memset(iqual, q, l_query); + kpa_par_def.bw = b; + P = kpa_glocal(ref, l_ref, query, l_query, iqual, &kpa_par_alt, 0, 0); + fprintf(pysamerr, "%d\n", P); + free(iqual); + return 0; +} +#endif diff --git a/samtools/kprobaln.h b/samtools/kprobaln.h new file mode 100644 index 0000000..0357dcc --- /dev/null +++ b/samtools/kprobaln.h @@ -0,0 +1,49 @@ +/* The MIT License + + Copyright (c) 2003-2006, 2008, 2009 by Heng Li + + 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 LH3_KPROBALN_H_ +#define LH3_KPROBALN_H_ + +#include + +typedef struct { + float d, e; + int bw; +} kpa_par_t; + +#ifdef __cplusplus +extern "C" { +#endif + + int kpa_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_query, const uint8_t *iqual, + const kpa_par_t *c, int *state, uint8_t *q); + +#ifdef __cplusplus +} +#endif + +extern kpa_par_t kpa_par_def, kpa_par_alt; + +#endif diff --git a/samtools/ksort.h b/samtools/ksort.h index 16a03fd..fa850ab 100644 --- a/samtools/ksort.h +++ b/samtools/ksort.h @@ -250,6 +250,15 @@ typedef struct { if (hh <= k) low = ll; \ if (hh >= k) high = hh - 1; \ } \ + } \ + void ks_shuffle_##name(size_t n, type_t a[]) \ + { \ + int i, j; \ + for (i = n; i > 1; --i) { \ + type_t tmp; \ + j = (int)(drand48() * i); \ + tmp = a[j]; a[j] = a[i-1]; a[i-1] = tmp; \ + } \ } #define ks_mergesort(name, n, a, t) ks_mergesort_##name(n, a, t) @@ -259,6 +268,7 @@ typedef struct { #define ks_heapmake(name, n, a) ks_heapmake_##name(n, a) #define ks_heapadjust(name, i, n, a) ks_heapadjust_##name(i, n, a) #define ks_ksmall(name, n, a, k) ks_ksmall_##name(n, a, k) +#define ks_shuffle(name, n, a) ks_shuffle_##name(n, a) #define ks_lt_generic(a, b) ((a) < (b)) #define ks_lt_str(a, b) (strcmp((a), (b)) < 0) diff --git a/samtools/kstring.c b/samtools/kstring.c.pysam.c similarity index 61% rename from samtools/kstring.c rename to samtools/kstring.c.pysam.c index e0203fa..c02bce0 100644 --- a/samtools/kstring.c +++ b/samtools/kstring.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -24,6 +26,32 @@ int ksprintf(kstring_t *s, const char *fmt, ...) return l; } +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->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; + } + aux->p = p; // end of token + if (*p == 0) aux->finished = 1; // no more tokens + return (char*)start; +} + // s MUST BE a null terminated string; l = strlen(s) int ksplit_core(char *s, int delimiter, int *_max, int **_offsets) { @@ -66,11 +94,13 @@ int ksplit_core(char *s, int delimiter, int *_max, int **_offsets) * Boyer-Moore search * **********************/ +typedef unsigned char ubyte_t; + // reference: http://www-igm.univ-mlv.fr/~lecroq/string/node14.html -int *ksBM_prep(const uint8_t *pat, int m) +static int *ksBM_prep(const ubyte_t *pat, int m) { int i, *suff, *prep, *bmGs, *bmBc; - prep = calloc(m + 256, 1); + prep = calloc(m + 256, sizeof(int)); bmGs = prep; bmBc = prep + m; { // preBmBc() for (i = 0; i < 256; ++i) bmBc[i] = m; @@ -107,39 +137,49 @@ int *ksBM_prep(const uint8_t *pat, int m) return prep; } -int *ksBM_search(const uint8_t *str, int n, const uint8_t *pat, int m, int *_prep, int *n_matches) +void *kmemmem(const void *_str, int n, const void *_pat, int m, int **_prep) { - int i, j, *prep, *bmGs, *bmBc; - int *matches = 0, mm = 0, nm = 0; - prep = _prep? _prep : ksBM_prep(pat, m); + int i, j, *prep = 0, *bmGs, *bmBc; + const ubyte_t *str, *pat; + str = (const ubyte_t*)_str; pat = (const ubyte_t*)_pat; + prep = (_prep == 0 || *_prep == 0)? ksBM_prep(pat, m) : *_prep; + if (_prep && *_prep == 0) *_prep = prep; bmGs = prep; bmBc = prep + m; j = 0; while (j <= n - m) { for (i = m - 1; i >= 0 && pat[i] == str[i+j]; --i); - if (i < 0) { - if (nm == mm) { - mm = mm? mm<<1 : 1; - matches = realloc(matches, mm * sizeof(int)); - } - matches[nm++] = j; - j += bmGs[0]; - } else { + if (i >= 0) { int max = bmBc[str[i+j]] - m + 1 + i; if (max < bmGs[i]) max = bmGs[i]; j += max; - } + } else return (void*)(str + j); } - *n_matches = nm; if (_prep == 0) free(prep); - return matches; + return 0; +} + +char *kstrstr(const char *str, const char *pat, int **_prep) +{ + return (char*)kmemmem(str, strlen(str), pat, strlen(pat), _prep); +} + +char *kstrnstr(const char *str, const char *pat, int n, int **_prep) +{ + return (char*)kmemmem(str, n, pat, strlen(pat), _prep); } +/*********************** + * The main() function * + ***********************/ + #ifdef KSTRING_MAIN #include int main() { kstring_t *s; int *fields, n, i; + ks_tokaux_t aux; + char *p; s = (kstring_t*)calloc(1, sizeof(kstring_t)); // test ksprintf() ksprintf(s, " abcdefg: %d ", 100); @@ -148,17 +188,26 @@ int main() fields = ksplit(s, 0, &n); for (i = 0; i < n; ++i) printf("field[%d] = '%s'\n", i, s->s + fields[i]); - free(s); + // test kstrtok() + s->l = 0; + for (p = kstrtok("ab:cde:fg/hij::k", ":/", &aux); p; p = kstrtok(0, 0, &aux)) { + kputsn(p, aux.p - p, s); + kputc('\n', s); + } + printf("%s", s->s); + // free + free(s->s); free(s); free(fields); { - static char *str = "abcdefgcdg"; + static char *str = "abcdefgcdgcagtcakcdcd"; static char *pat = "cd"; - int n, *matches; - matches = ksBM_search(str, strlen(str), pat, strlen(pat), 0, &n); - printf("%d: \n", n); - for (i = 0; i < n; ++i) - printf("- %d\n", matches[i]); - free(matches); + char *ret, *s = str; + int *prep = 0; + while ((ret = kstrstr(s, pat, &prep)) != 0) { + printf("match: %s\n", ret); + s = ret + prep[0]; + } + free(prep); } return 0; } diff --git a/samtools/kstring.h b/samtools/kstring.h index 925117a..ec5775b 100644 --- a/samtools/kstring.h +++ b/samtools/kstring.h @@ -17,17 +17,32 @@ typedef struct __kstring_t { } kstring_t; #endif -int ksprintf(kstring_t *s, const char *fmt, ...); -int ksplit_core(char *s, int delimiter, int *_max, int **_offsets); +typedef struct { + uint64_t tab[4]; + int sep, finished; + const char *p; // end of the current token +} ks_tokaux_t; -// calculate the auxiliary array, allocated by calloc() -int *ksBM_prep(const uint8_t *pat, int m); +#ifdef __cplusplus +extern "C" { +#endif + + int ksprintf(kstring_t *s, const char *fmt, ...); + int ksplit_core(char *s, int delimiter, int *_max, int **_offsets); + char *kstrstr(const char *str, const char *pat, int **_prep); + char *kstrnstr(const char *str, const char *pat, int n, int **_prep); + void *kmemmem(const void *_str, int n, const void *_pat, int m, int **_prep); -/* Search pat in str and returned the list of matches. The size of the - * list is returned as n_matches. _prep is the array returned by - * ksBM_prep(). If it is a NULL pointer, ksBM_prep() will be called. */ -int *ksBM_search(const uint8_t *str, int n, const uint8_t *pat, int m, int *_prep, int *n_matches); + /* kstrtok() is similar to strtok_r() except that str is not + * modified and both str and sep can be NULL. For efficiency, it is + * actually recommended to set both to NULL in the subsequent calls + * if sep is not changed. */ + char *kstrtok(const char *str, const char *sep, ks_tokaux_t *aux); +#ifdef __cplusplus +} +#endif + static inline int kputsn(const char *p, int l, kstring_t *s) { if (s->l + l + 1 >= s->m) { @@ -35,7 +50,7 @@ static inline int kputsn(const char *p, int l, kstring_t *s) kroundup32(s->m); s->s = (char*)realloc(s->s, s->m); } - strncpy(s->s + s->l, p, l); + memcpy(s->s + s->l, p, l); s->l += l; s->s[s->l] = 0; return l; diff --git a/samtools/misc/md5.c.pysam.c b/samtools/misc/md5.c.pysam.c new file mode 100644 index 0000000..7710844 --- /dev/null +++ b/samtools/misc/md5.c.pysam.c @@ -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 +#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<>(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 +#include +#include +#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 index 0000000..44121e4 --- /dev/null +++ b/samtools/misc/md5.h @@ -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 + +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 index 0000000..624cc99 --- /dev/null +++ b/samtools/msvc_compat.h @@ -0,0 +1,60 @@ +// Windows-specific code, include with: +// #ifdef _MSC_VER +// #include +// #endif + +//#define _CRT_SECURE_NO_WARNINGS +#ifndef MSVC_COMPAT_H +#define MSVC_COMPAT_H + +#define inline __inline +#define __func__ __FUNCTION__ + +#include +#define isnan _isnan +static int isinf(double x) { + int y = _finite(x); + if(y == 0) { + return 0; + } else { + return 1; + } +} +#define alloca _alloca +#define atoll _atoi64 + +#define ftello ftell + +typedef int bool; + +static int R_OK = 4; + +#ifndef lgamma +/* Log gamma function + * \log{\Gamma(z)} + * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245 + */ +static double lgamma(double z) +{ + double x = 0; + x += 0.1659470187408462e-06 / (z+7); + x += 0.9934937113930748e-05 / (z+6); + x -= 0.1385710331296526 / (z+5); + x += 12.50734324009056 / (z+4); + x -= 176.6150291498386 / (z+3); + x += 771.3234287757674 / (z+2); + x -= 1259.139216722289 / (z+1); + x += 676.5203681218835 / z; + x += 0.9999999999995183; + return log(x) - 5.58106146679532777 - z + (z-0.5) * log(z+6.5); +} +#endif + +#ifndef M_LN10 +#define M_LN10 2.30258509299404568402 +#endif +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif + +#endif diff --git a/samtools/phase.c.pysam.c b/samtools/phase.c.pysam.c new file mode 100644 index 0000000..d142538 --- /dev/null +++ b/samtools/phase.c.pysam.c @@ -0,0 +1,689 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include +#include +#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<>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<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<>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] \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; +} diff --git a/samtools/pysam.h b/samtools/pysam.h new file mode 100644 index 0000000..008cbbd --- /dev/null +++ b/samtools/pysam.h @@ -0,0 +1,5 @@ +#ifndef PYSAM_H +#define PYSAM_H +#include "stdio.h" +extern FILE * pysamerr; +#endif diff --git a/samtools/razf.c b/samtools/razf.c.pysam.c similarity index 97% rename from samtools/razf.c rename to samtools/razf.c.pysam.c index e7499f9..4021637 100644 --- a/samtools/razf.c +++ b/samtools/razf.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* * RAZF : Random Access compressed(Z) File * Version: 1.0 @@ -147,7 +149,7 @@ static void load_zindex(RAZF *rz, int fd){ #ifdef _RZ_READONLY static RAZF* razf_open_w(int fd) { - fprintf(stderr, "[razf_open_w] Writing is not available with zlib ver < 1.2.2.1\n"); + fprintf(pysamerr, "[razf_open_w] Writing is not available with zlib ver < 1.2.2.1\n"); return 0; } #else @@ -399,7 +401,7 @@ static RAZF* razf_open_r(int fd, int _load_index){ rz->block_off = 0; if(ext_len < 7 || memcmp(rz->inbuf + ext_off, c, 4) != 0) return rz; if(((((unsigned char*)rz->inbuf)[ext_off + 5] << 8) | ((unsigned char*)rz->inbuf)[ext_off + 6]) != RZ_BLOCK_SIZE){ - fprintf(stderr, " -- WARNING: RZ_BLOCK_SIZE is not %d, treat source as gz file. in %s -- %s:%d --\n", RZ_BLOCK_SIZE, __FUNCTION__, __FILE__, __LINE__); + fprintf(pysamerr, " -- WARNING: RZ_BLOCK_SIZE is not %d, treat source as gz file. in %s -- %s:%d --\n", RZ_BLOCK_SIZE, __FUNCTION__, __FILE__, __LINE__); return rz; } rz->load_index = _load_index; @@ -466,14 +468,14 @@ static RAZF* razf_open_r(int fd, int _load_index){ #ifdef _USE_KNETFILE RAZF* razf_dopen(int fd, const char *mode){ - if (strstr(mode, "r")) fprintf(stderr,"[razf_dopen] implement me\n"); + if (strstr(mode, "r")) fprintf(pysamerr,"[razf_dopen] implement me\n"); else if(strstr(mode, "w")) return razf_open_w(fd); return NULL; } RAZF* razf_dopen2(int fd, const char *mode) { - fprintf(stderr,"[razf_dopen2] implement me\n"); + fprintf(pysamerr,"[razf_dopen2] implement me\n"); return NULL; } #else @@ -498,7 +500,7 @@ static inline RAZF* _razf_open(const char *filename, const char *mode, int _load #ifdef _USE_KNETFILE knetFile *fd = knet_open(filename, "r"); if (fd == 0) { - fprintf(stderr, "[_razf_open] fail to open %s\n", filename); + fprintf(pysamerr, "[_razf_open] fail to open %s\n", filename); return NULL; } #else @@ -602,7 +604,7 @@ static int _razf_read(RAZF* rz, void *data, int size){ ret = inflate(rz->stream, Z_BLOCK); rz->in += tin - rz->stream->avail_in; if(ret == Z_NEED_DICT || ret == Z_MEM_ERROR || ret == Z_DATA_ERROR){ - fprintf(stderr, "[_razf_read] inflate error: %d %s (at %s:%d)\n", ret, rz->stream->msg ? rz->stream->msg : "", __FILE__, __LINE__); + fprintf(pysamerr, "[_razf_read] inflate error: %d %s (at %s:%d)\n", ret, rz->stream->msg ? rz->stream->msg : "", __FILE__, __LINE__); rz->z_err = 1; break; } @@ -780,7 +782,7 @@ uint64_t razf_tell2(RAZF *rz) idx = rz->out / RZ_BLOCK_SIZE - 1; seek_pos = (idx < 0)? rz->header_size:(rz->index->cell_offsets[idx] + rz->index->bin_offsets[idx / RZ_BIN_SIZE]); if (seek_pos != rz->block_pos || rz->out%RZ_BLOCK_SIZE != rz->block_off) - fprintf(stderr, "[razf_tell2] inconsistent block offset: (%lld, %lld) != (%lld, %lld)\n", + fprintf(pysamerr, "[razf_tell2] inconsistent block offset: (%lld, %lld) != (%lld, %lld)\n", (long long)seek_pos, (long long)rz->out%RZ_BLOCK_SIZE, (long long)rz->block_pos, (long long) rz->block_off); } */ diff --git a/samtools/sam.c b/samtools/sam.c.pysam.c similarity index 78% rename from samtools/sam.c rename to samtools/sam.c.pysam.c index ecdee02..7f71f7a 100644 --- a/samtools/sam.c +++ b/samtools/sam.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include "faidx.h" @@ -40,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; @@ -59,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) - fprintf(stderr, "[samopen] no @SQ lines in the header.\n"); - } else fprintf(stderr, "[samopen] SAM header is present: %d sequences.\n", fp->header->n_targets); + if (fp->header->n_targets == 0 && bam_verbose >= 1) + fprintf(pysamerr, "[samopen] no @SQ lines in the header.\n"); + } 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; @@ -76,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 @@ -89,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(stderr, "[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]); @@ -162,11 +168,11 @@ char *samfaipath(const char *fn_ref) strcat(strcpy(fn_list, fn_ref), ".fai"); if (access(fn_list, R_OK) == -1) { // fn_list is unreadable if (access(fn_ref, R_OK) == -1) { - fprintf(stderr, "[samfaipath] fail to read file %s.\n", fn_ref); + fprintf(pysamerr, "[samfaipath] fail to read file %s.\n", fn_ref); } else { - fprintf(stderr, "[samfaipath] build FASTA index...\n"); + if (bam_verbose >= 3) fprintf(pysamerr, "[samfaipath] build FASTA index...\n"); if (fai_build(fn_ref) == -1) { - fprintf(stderr, "[samfaipath] fail to build FASTA index.\n"); + fprintf(pysamerr, "[samfaipath] fail to build FASTA index.\n"); free(fn_list); fn_list = 0; } } diff --git a/samtools/sam_header.c b/samtools/sam_header.c.pysam.c similarity index 98% rename from samtools/sam_header.c rename to samtools/sam_header.c.pysam.c index 05d75de..2178047 100644 --- a/samtools/sam_header.c +++ b/samtools/sam_header.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include "sam_header.h" #include #include @@ -38,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}; @@ -55,7 +57,7 @@ static void debug(const char *format, ...) { va_list ap; va_start(ap, format); - vfprintf(stderr, format, ap); + vfprintf(pysamerr, format, ap); va_end(ap); } @@ -563,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; @@ -571,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 @@ -711,8 +714,8 @@ void *sam_header_merge(int n, const void **_dicts) if ( status==2 ) { - print_header_line(stderr,tmpl_hlines->data); - print_header_line(stderr,out_hlines->data); + print_header_line(pysamerr,tmpl_hlines->data); + print_header_line(pysamerr,out_hlines->data); debug("Conflicting lines, cannot merge the headers.\n"); return 0; } diff --git a/samtools/sam_view.c b/samtools/sam_view.c.pysam.c similarity index 54% rename from samtools/sam_view.c rename to samtools/sam_view.c.pysam.c index 3b10e2e..2c47363 100644 --- a/samtools/sam_view.c +++ b/samtools/sam_view.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -6,15 +8,28 @@ #include "sam_header.h" #include "sam.h" #include "faidx.h" +#include "kstring.h" #include "khash.h" KHASH_SET_INIT_STR(rg) +// When counting records instead of printing them, +// data passed to the bam_fetch callback is encapsulated in this struct. +typedef struct { + bam_header_t *header; + int *count; +} count_func_data_t; + 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) { @@ -37,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) { @@ -54,7 +71,38 @@ static inline int __g_skip_aln(const bam_header_t *h, const bam1_t *b) return 0; } -// callback function for bam_fetch() +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) { if (!__g_skip_aln(((samfile_t*)data)->header, b)) @@ -62,19 +110,30 @@ static int view_func(const bam1_t *b, void *data) return 0; } +// callback function for bam_fetch() that counts nonskipped records +static int count_func(const bam1_t *b, void *data) +{ + if (!__g_skip_aln(((count_func_data_t*)data)->header, b)) { + (*((count_func_data_t*)data)->count)++; + } + return 0; +} + 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; + 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; char in_mode[5], out_mode[5], *fn_out = 0, *fn_list = 0, *fn_ref = 0, *fn_rg = 0; /* parse command-line options */ strcpy(in_mode, "r"); strcpy(out_mode, "w"); - while ((c = getopt(argc, argv, "Sbt: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; case 'S': is_bamin = 0; break; case 'b': is_bamout = 1; break; @@ -85,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; @@ -96,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 { @@ -105,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 @@ -124,15 +189,26 @@ int main_samview(int argc, char *argv[]) if (fn_list == 0 && fn_ref) fn_list = samfaipath(fn_ref); // open file handlers if ((in = samopen(argv[optind], in_mode, fn_list)) == 0) { - fprintf(stderr, "[main_samview] fail to open file for reading.\n"); + fprintf(pysamerr, "[main_samview] fail to open \"%s\" for reading.\n", argv[optind]); + ret = 1; goto view_end; } if (in->header == 0) { - fprintf(stderr, "[main_samview] fail to read the header.\n"); + fprintf(pysamerr, "[main_samview] fail to read the header from \"%s\".\n", argv[optind]); + ret = 1; goto view_end; } - if ((out = samopen(fn_out? fn_out : "-", out_mode, in->header)) == 0) { - fprintf(stderr, "[main_samview] fail to open file for writing.\n"); + 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; goto view_end; } if (is_header_only) goto view_end; // no need to print alignments @@ -143,35 +219,53 @@ int main_samview(int argc, char *argv[]) while ((r = samread(in, b)) >= 0) { // read one alignment from `in' if (!__g_skip_aln(in->header, b)) { if (slx2sngr) sol2sanger(b); - samwrite(out, b); // write the alignment to `out' + if (!is_count) samwrite(out, b); // write the alignment to `out' + count++; } } - if (r < -1) fprintf(stderr, "[main_samview] truncated file.\n"); + if (r < -1) { + fprintf(pysamerr, "[main_samview] truncated file.\n"); + ret = 1; + } bam_destroy1(b); } else { // retrieve alignments in specified regions int i; bam_index_t *idx = 0; if (is_bamin) idx = bam_index_load(argv[optind]); // load BAM index if (idx == 0) { // index is unavailable - fprintf(stderr, "[main_samview] random alignment retrieval only works for indexed BAM files.\n"); + fprintf(pysamerr, "[main_samview] random alignment retrieval only works for indexed BAM files.\n"); ret = 1; goto view_end; } for (i = optind + 1; i < argc; ++i) { - int tid, beg, end; + int tid, beg, end, result; bam_parse_region(in->header, argv[i], &tid, &beg, &end); // parse a region in the format like `chr2:100-200' if (tid < 0) { // reference name is not found - fprintf(stderr, "[main_samview] fail to get the reference name. Continue anyway.\n"); + fprintf(pysamerr, "[main_samview] region \"%s\" specifies an unknown reference name. Continue anyway.\n", argv[i]); continue; } - bam_fetch(in->x.bam, idx, tid, beg, end, out, view_func); // fetch alignments + // fetch alignments + if (is_count) { + count_func_data_t count_data = { in->header, &count }; + result = bam_fetch(in->x.bam, idx, tid, beg, end, &count_data, count_func); + } else + result = bam_fetch(in->x.bam, idx, tid, beg, end, out, view_func); + if (result < 0) { + fprintf(pysamerr, "[main_samview] retrieval of region \"%s\" failed due to truncated file or corrupt BAM index file\n", argv[i]); + ret = 1; + break; + } } bam_index_destroy(idx); // destroy the BAM index } view_end: + if (is_count && ret == 0) { + printf("%d\n", count); + } // 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) @@ -179,34 +273,38 @@ view_end: kh_destroy(rg, g_rghash); } samclose(in); - samclose(out); + if (!is_count) + samclose(out); return ret; } static int usage(int is_long_help) { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: samtools view [options] | [region1 [...]]\n\n"); - fprintf(stderr, "Options: -b output BAM\n"); - fprintf(stderr, " -h print header for the SAM output\n"); - fprintf(stderr, " -H print header only (no alignments)\n"); - fprintf(stderr, " -S input is SAM\n"); - fprintf(stderr, " -u uncompressed BAM output (force -b)\n"); - fprintf(stderr, " -x output FLAG in HEX (samtools-C specific)\n"); - fprintf(stderr, " -X output FLAG in string (samtools-C specific)\n"); - fprintf(stderr, " -t FILE list of reference names and lengths (force -S) [null]\n"); - fprintf(stderr, " -T FILE reference sequence file (force -S) [null]\n"); - fprintf(stderr, " -o FILE output file name [stdout]\n"); - fprintf(stderr, " -R FILE list of read groups to be outputted [null]\n"); - fprintf(stderr, " -f INT required flag, 0 for unset [0]\n"); - fprintf(stderr, " -F INT filtering flag, 0 for unset [0]\n"); - fprintf(stderr, " -q INT minimum mapping quality [0]\n"); - fprintf(stderr, " -l STR only output reads in library STR [null]\n"); - fprintf(stderr, " -r STR only output reads in read group STR [null]\n"); - fprintf(stderr, " -? longer help\n"); - fprintf(stderr, "\n"); + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: samtools view [options] | [region1 [...]]\n\n"); + fprintf(pysamerr, "Options: -b output BAM\n"); + fprintf(pysamerr, " -h print header for the SAM output\n"); + 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"); + fprintf(pysamerr, " -R FILE list of read groups to be outputted [null]\n"); + fprintf(pysamerr, " -f INT required flag, 0 for unset [0]\n"); + fprintf(pysamerr, " -F INT filtering flag, 0 for unset [0]\n"); + fprintf(pysamerr, " -q INT minimum mapping quality [0]\n"); + fprintf(pysamerr, " -l STR only output reads in library STR [null]\n"); + fprintf(pysamerr, " -r STR only output reads in read group STR [null]\n"); + fprintf(pysamerr, " -? longer help\n"); + fprintf(pysamerr, "\n"); if (is_long_help) - fprintf(stderr, "Notes:\n\ + fprintf(pysamerr, "Notes:\n\ \n\ 1. By default, this command assumes the file on the command line is in\n\ the BAM format and it prints the alignments in SAM. If `-t' is\n\ @@ -243,7 +341,7 @@ int main_import(int argc, char *argv[]) int argc2, ret; char **argv2; if (argc != 4) { - fprintf(stderr, "Usage: bamtk import \n"); + fprintf(pysamerr, "Usage: bamtk import \n"); return 1; } argc2 = 6; diff --git a/samtools/sample.c.pysam.c b/samtools/sample.c.pysam.c new file mode 100644 index 0000000..dc8e627 --- /dev/null +++ b/samtools/sample.c.pysam.c @@ -0,0 +1,95 @@ +#include "pysam.h" + +#include +#include +#include "sample.h" +#include "khash.h" +KHASH_MAP_INIT_STR(sm, int) + +bam_sample_t *bam_smpl_init(void) +{ + bam_sample_t *s; + s = calloc(1, sizeof(bam_sample_t)); + s->rg2smid = kh_init(sm); + s->sm2id = kh_init(sm); + return s; +} + +void bam_smpl_destroy(bam_sample_t *sm) +{ + int i; + khint_t k; + khash_t(sm) *rg2smid = (khash_t(sm)*)sm->rg2smid; + if (sm == 0) return; + for (i = 0; i < sm->n; ++i) free(sm->smpl[i]); + free(sm->smpl); + for (k = kh_begin(rg2smid); k != kh_end(rg2smid); ++k) + if (kh_exist(rg2smid, k)) free((char*)kh_key(rg2smid, k)); + kh_destroy(sm, sm->rg2smid); + kh_destroy(sm, sm->sm2id); + free(sm); +} + +static void add_pair(bam_sample_t *sm, khash_t(sm) *sm2id, const char *key, const char *val) +{ + khint_t k_rg, k_sm; + int ret; + khash_t(sm) *rg2smid = (khash_t(sm)*)sm->rg2smid; + k_rg = kh_get(sm, rg2smid, key); + if (k_rg != kh_end(rg2smid)) return; // duplicated @RG-ID + k_rg = kh_put(sm, rg2smid, strdup(key), &ret); + k_sm = kh_get(sm, sm2id, val); + if (k_sm == kh_end(sm2id)) { // absent + if (sm->n == sm->m) { + sm->m = sm->m? sm->m<<1 : 1; + sm->smpl = realloc(sm->smpl, sizeof(void*) * sm->m); + } + sm->smpl[sm->n] = strdup(val); + k_sm = kh_put(sm, sm2id, sm->smpl[sm->n], &ret); + kh_val(sm2id, k_sm) = sm->n++; + } + kh_val(rg2smid, k_rg) = kh_val(sm2id, k_sm); +} + +int bam_smpl_add(bam_sample_t *sm, const char *fn, const char *txt) +{ + const char *p = txt, *q, *r; + kstring_t buf; + int n = 0; + khash_t(sm) *sm2id = (khash_t(sm)*)sm->sm2id; + memset(&buf, 0, sizeof(kstring_t)); + while ((q = strstr(p, "@RG")) != 0) { + p = q + 3; + r = q = 0; + if ((q = strstr(p, "\tID:")) != 0) q += 4; + if ((r = strstr(p, "\tSM:")) != 0) r += 4; + if (r && q) { + char *u, *v; + int oq, or; + for (u = (char*)q; *u && *u != '\t' && *u != '\n'; ++u); + for (v = (char*)r; *v && *v != '\t' && *v != '\n'; ++v); + oq = *u; or = *v; *u = *v = '\0'; + buf.l = 0; kputs(fn, &buf); kputc('/', &buf); kputs(q, &buf); + add_pair(sm, sm2id, buf.s, r); + *u = oq; *v = or; + } else break; + p = q > r? q : r; + ++n; + } + if (n == 0) add_pair(sm, sm2id, fn, fn); +// add_pair(sm, sm2id, fn, fn); + free(buf.s); + return 0; +} + +int bam_smpl_rg2smid(const bam_sample_t *sm, const char *fn, const char *rg, kstring_t *str) +{ + khint_t k; + khash_t(sm) *rg2smid = (khash_t(sm)*)sm->rg2smid; + if (rg) { + str->l = 0; + kputs(fn, str); kputc('/', str); kputs(rg, str); + k = kh_get(sm, rg2smid, str->s); + } else k = kh_get(sm, rg2smid, fn); + return k == kh_end(rg2smid)? -1 : kh_val(rg2smid, k); +} diff --git a/samtools/sample.h b/samtools/sample.h new file mode 100644 index 0000000..85fe499 --- /dev/null +++ b/samtools/sample.h @@ -0,0 +1,17 @@ +#ifndef BAM_SAMPLE_H +#define BAM_SAMPLE_H + +#include "kstring.h" + +typedef struct { + int n, m; + char **smpl; + void *rg2smid, *sm2id; +} bam_sample_t; + +bam_sample_t *bam_smpl_init(void); +int bam_smpl_add(bam_sample_t *sm, const char *abs, const char *txt); +int bam_smpl_rg2smid(const bam_sample_t *sm, const char *fn, const char *rg, kstring_t *str); +void bam_smpl_destroy(bam_sample_t *sm); + +#endif diff --git a/samtools/win32/xcurses.h b/samtools/win32/xcurses.h new file mode 100644 index 0000000..6f3ce19 --- /dev/null +++ b/samtools/win32/xcurses.h @@ -0,0 +1,1377 @@ +/* Public Domain Curses */ + +/* $Id: curses.h,v 1.295 2008/07/15 17:13:25 wmcbrine Exp $ */ + +/*----------------------------------------------------------------------* + * PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start************************************************************** + +PDCurses definitions list: (Only define those needed) + + XCURSES True if compiling for X11. + PDC_RGB True if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR. + PDC_WIDE True if building wide-character support. + PDC_DLL_BUILD True if building a Win32 DLL. + NCURSES_MOUSE_VERSION Use the ncurses mouse API instead + of PDCurses' traditional mouse API. + +PDCurses portable platform definitions list: + + PDC_BUILD Defines API build version. + PDCURSES Enables access to PDCurses-only routines. + XOPEN Always true. + SYSVcurses True if you are compiling for SYSV portability. + BSDcurses True if you are compiling for BSD portability. + +**man-end****************************************************************/ + +#define PDC_BUILD 3401 +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSVcurses 1 /* System V Curses routines */ +#define BSDcurses 1 /* BSD Curses routines */ +#define CHTYPE_LONG 1 /* size of chtype; long */ + +/*----------------------------------------------------------------------*/ + +#include +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Manifest Constants + * + */ + +#ifndef FALSE +# define FALSE 0 +#endif +#ifndef TRUE +# define TRUE 1 +#endif +#ifndef NULL +# define NULL (void *)0 +#endif +#ifndef ERR +# define ERR (-1) +#endif +#ifndef OK +# define OK 0 +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Type Declarations + * + */ + +typedef unsigned char bool; /* PDCurses Boolean type */ + +#ifdef CHTYPE_LONG +# if _LP64 +typedef unsigned int chtype; +# else +typedef unsigned long chtype; /* 16-bit attr + 16-bit char */ +# endif +#else +typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/*---------------------------------------------------------------------- + * + * PDCurses Mouse Interface -- SYSVR4, with extensions + * + */ + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of each button */ + int changes; /* flags indicating what has changed with the mouse */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed + * 10 <- button 2 has changed + * 100 <- button 3 has changed + * 1000 <- mouse has moved + * 10000 <- mouse position report + * 100000 <- mouse wheel up + * 1000000 <- mouse wheel down + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5 */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * PDCurses Structure Definitions + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; +#endif + short line_color; /* color of line attributes - default -1 */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * PDCurses External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ + +/*man-start************************************************************** + +PDCurses Text Attributes +======================== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + +------------------------------------------------- +|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| +------------------------------------------------- + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + +---------------------------------------------------------------------------- +|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|..| 3| 2| 1| 0| +---------------------------------------------------------------------------- + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, invisible, +right-line, left-line, protect, reverse and blink. 256 color pairs (8 +bits), 8 bits for other attributes, and 16 bits for character data. + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG +# define A_ALTCHARSET (chtype)0x00010000 +# define A_RIGHTLINE (chtype)0x00020000 +# define A_LEFTLINE (chtype)0x00040000 +# define A_INVIS (chtype)0x00080000 +# define A_UNDERLINE (chtype)0x00100000 +# define A_REVERSE (chtype)0x00200000 +# define A_BLINK (chtype)0x00400000 +# define A_BOLD (chtype)0x00800000 + +# define A_ATTRIBUTES (chtype)0xffff0000 +# define A_CHARTEXT (chtype)0x0000ffff +# define A_COLOR (chtype)0xff000000 + +# define A_ITALIC A_INVIS +# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE) + +# define PDC_ATTR_SHIFT 19 +# define PDC_COLOR_SHIFT 24 +#else +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_PROTECT A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ + +# define A_LEFTLINE A_NORMAL +# define A_RIGHTLINE A_NORMAL +# define A_ITALIC A_NORMAL +# define A_INVIS A_NORMAL + +# define PDC_ATTR_SHIFT 8 +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ +#define A_DIM A_NORMAL + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_LEFT A_LEFTLINE +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHTLINE +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_NORMAL +#define WA_LOW A_NORMAL +#define WA_TOP A_NORMAL +#define WA_VERTICAL A_NORMAL + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define ACS_PICK(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_ULCORNER ACS_PICK('l', '+') +#define ACS_LLCORNER ACS_PICK('m', '+') +#define ACS_URCORNER ACS_PICK('k', '+') +#define ACS_LRCORNER ACS_PICK('j', '+') +#define ACS_RTEE ACS_PICK('u', '+') +#define ACS_LTEE ACS_PICK('t', '+') +#define ACS_BTEE ACS_PICK('v', '+') +#define ACS_TTEE ACS_PICK('w', '+') +#define ACS_HLINE ACS_PICK('q', '-') +#define ACS_VLINE ACS_PICK('x', '|') +#define ACS_PLUS ACS_PICK('n', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 ACS_PICK('o', '-') +#define ACS_S9 ACS_PICK('s', '_') +#define ACS_DIAMOND ACS_PICK('`', '+') +#define ACS_CKBOARD ACS_PICK('a', ':') +#define ACS_DEGREE ACS_PICK('f', '\'') +#define ACS_PLMINUS ACS_PICK('g', '#') +#define ACS_BULLET ACS_PICK('~', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW ACS_PICK(',', '<') +#define ACS_RARROW ACS_PICK('+', '>') +#define ACS_DARROW ACS_PICK('.', 'v') +#define ACS_UARROW ACS_PICK('-', '^') +#define ACS_BOARD ACS_PICK('h', '#') +#define ACS_LANTERN ACS_PICK('i', '*') +#define ACS_BLOCK ACS_PICK('0', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 ACS_PICK('p', '-') +#define ACS_S7 ACS_PICK('r', '-') +#define ACS_LEQUAL ACS_PICK('y', '<') +#define ACS_GEQUAL ACS_PICK('z', '>') +#define ACS_PI ACS_PICK('{', 'n') +#define ACS_NEQUAL ACS_PICK('|', '+') +#define ACS_STERLING ACS_PICK('}', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_ULCORNER (&(acs_map['l'])) +# define WACS_LLCORNER (&(acs_map['m'])) +# define WACS_URCORNER (&(acs_map['k'])) +# define WACS_LRCORNER (&(acs_map['j'])) +# define WACS_RTEE (&(acs_map['u'])) +# define WACS_LTEE (&(acs_map['t'])) +# define WACS_BTEE (&(acs_map['v'])) +# define WACS_TTEE (&(acs_map['w'])) +# define WACS_HLINE (&(acs_map['q'])) +# define WACS_VLINE (&(acs_map['x'])) +# define WACS_PLUS (&(acs_map['n'])) + +# define WACS_S1 (&(acs_map['o'])) +# define WACS_S9 (&(acs_map['s'])) +# define WACS_DIAMOND (&(acs_map['`'])) +# define WACS_CKBOARD (&(acs_map['a'])) +# define WACS_DEGREE (&(acs_map['f'])) +# define WACS_PLMINUS (&(acs_map['g'])) +# define WACS_BULLET (&(acs_map['~'])) + +# define WACS_LARROW (&(acs_map[','])) +# define WACS_RARROW (&(acs_map['+'])) +# define WACS_DARROW (&(acs_map['.'])) +# define WACS_UARROW (&(acs_map['-'])) +# define WACS_BOARD (&(acs_map['h'])) +# define WACS_LANTERN (&(acs_map['i'])) +# define WACS_BLOCK (&(acs_map['0'])) + +# define WACS_S3 (&(acs_map['p'])) +# define WACS_S7 (&(acs_map['r'])) +# define WACS_LEQUAL (&(acs_map['y'])) +# define WACS_GEQUAL (&(acs_map['z'])) +# define WACS_PI (&(acs_map['{'])) +# define WACS_NEQUAL (&(acs_map['|'])) +# define WACS_STERLING (&(acs_map['}'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions. + * Many are just for compatibility. + * + */ + +#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */ + +#define KEY_BREAK 0x101 /* Not on PC KBD */ +#define KEY_DOWN 0x102 /* Down arrow key */ +#define KEY_UP 0x103 /* Up arrow key */ +#define KEY_LEFT 0x104 /* Left arrow key */ +#define KEY_RIGHT 0x105 /* Right arrow key */ +#define KEY_HOME 0x106 /* home key */ +#define KEY_BACKSPACE 0x107 /* not on pc */ +#define KEY_F0 0x108 /* function keys; 64 reserved */ + +#define KEY_DL 0x148 /* delete line */ +#define KEY_IL 0x149 /* insert line */ +#define KEY_DC 0x14a /* delete character */ +#define KEY_IC 0x14b /* insert char or enter ins mode */ +#define KEY_EIC 0x14c /* exit insert char mode */ +#define KEY_CLEAR 0x14d /* clear screen */ +#define KEY_EOS 0x14e /* clear to end of screen */ +#define KEY_EOL 0x14f /* clear to end of line */ +#define KEY_SF 0x150 /* scroll 1 line forward */ +#define KEY_SR 0x151 /* scroll 1 line back (reverse) */ +#define KEY_NPAGE 0x152 /* next page */ +#define KEY_PPAGE 0x153 /* previous page */ +#define KEY_STAB 0x154 /* set tab */ +#define KEY_CTAB 0x155 /* clear tab */ +#define KEY_CATAB 0x156 /* clear all tabs */ +#define KEY_ENTER 0x157 /* enter or send (unreliable) */ +#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */ +#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */ +#define KEY_PRINT 0x15a /* print/copy */ +#define KEY_LL 0x15b /* home down/bottom (lower left) */ +#define KEY_ABORT 0x15c /* abort/terminate key (any) */ +#define KEY_SHELP 0x15d /* short help */ +#define KEY_LHELP 0x15e /* long help */ +#define KEY_BTAB 0x15f /* Back tab key */ +#define KEY_BEG 0x160 /* beg(inning) key */ +#define KEY_CANCEL 0x161 /* cancel key */ +#define KEY_CLOSE 0x162 /* close key */ +#define KEY_COMMAND 0x163 /* cmd (command) key */ +#define KEY_COPY 0x164 /* copy key */ +#define KEY_CREATE 0x165 /* create key */ +#define KEY_END 0x166 /* end key */ +#define KEY_EXIT 0x167 /* exit key */ +#define KEY_FIND 0x168 /* find key */ +#define KEY_HELP 0x169 /* help key */ +#define KEY_MARK 0x16a /* mark key */ +#define KEY_MESSAGE 0x16b /* message key */ +#define KEY_MOVE 0x16c /* move key */ +#define KEY_NEXT 0x16d /* next object key */ +#define KEY_OPEN 0x16e /* open key */ +#define KEY_OPTIONS 0x16f /* options key */ +#define KEY_PREVIOUS 0x170 /* previous object key */ +#define KEY_REDO 0x171 /* redo key */ +#define KEY_REFERENCE 0x172 /* ref(erence) key */ +#define KEY_REFRESH 0x173 /* refresh key */ +#define KEY_REPLACE 0x174 /* replace key */ +#define KEY_RESTART 0x175 /* restart key */ +#define KEY_RESUME 0x176 /* resume key */ +#define KEY_SAVE 0x177 /* save key */ +#define KEY_SBEG 0x178 /* shifted beginning key */ +#define KEY_SCANCEL 0x179 /* shifted cancel key */ +#define KEY_SCOMMAND 0x17a /* shifted command key */ +#define KEY_SCOPY 0x17b /* shifted copy key */ +#define KEY_SCREATE 0x17c /* shifted create key */ +#define KEY_SDC 0x17d /* shifted delete char key */ +#define KEY_SDL 0x17e /* shifted delete line key */ +#define KEY_SELECT 0x17f /* select key */ +#define KEY_SEND 0x180 /* shifted end key */ +#define KEY_SEOL 0x181 /* shifted clear line key */ +#define KEY_SEXIT 0x182 /* shifted exit key */ +#define KEY_SFIND 0x183 /* shifted find key */ +#define KEY_SHOME 0x184 /* shifted home key */ +#define KEY_SIC 0x185 /* shifted input key */ + +#define KEY_SLEFT 0x187 /* shifted left arrow key */ +#define KEY_SMESSAGE 0x188 /* shifted message key */ +#define KEY_SMOVE 0x189 /* shifted move key */ +#define KEY_SNEXT 0x18a /* shifted next key */ +#define KEY_SOPTIONS 0x18b /* shifted options key */ +#define KEY_SPREVIOUS 0x18c /* shifted prev key */ +#define KEY_SPRINT 0x18d /* shifted print key */ +#define KEY_SREDO 0x18e /* shifted redo key */ +#define KEY_SREPLACE 0x18f /* shifted replace key */ +#define KEY_SRIGHT 0x190 /* shifted right arrow */ +#define KEY_SRSUME 0x191 /* shifted resume key */ +#define KEY_SSAVE 0x192 /* shifted save key */ +#define KEY_SSUSPEND 0x193 /* shifted suspend key */ +#define KEY_SUNDO 0x194 /* shifted undo key */ +#define KEY_SUSPEND 0x195 /* suspend key */ +#define KEY_UNDO 0x196 /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 0x197 +#define ALT_1 0x198 +#define ALT_2 0x199 +#define ALT_3 0x19a +#define ALT_4 0x19b +#define ALT_5 0x19c +#define ALT_6 0x19d +#define ALT_7 0x19e +#define ALT_8 0x19f +#define ALT_9 0x1a0 +#define ALT_A 0x1a1 +#define ALT_B 0x1a2 +#define ALT_C 0x1a3 +#define ALT_D 0x1a4 +#define ALT_E 0x1a5 +#define ALT_F 0x1a6 +#define ALT_G 0x1a7 +#define ALT_H 0x1a8 +#define ALT_I 0x1a9 +#define ALT_J 0x1aa +#define ALT_K 0x1ab +#define ALT_L 0x1ac +#define ALT_M 0x1ad +#define ALT_N 0x1ae +#define ALT_O 0x1af +#define ALT_P 0x1b0 +#define ALT_Q 0x1b1 +#define ALT_R 0x1b2 +#define ALT_S 0x1b3 +#define ALT_T 0x1b4 +#define ALT_U 0x1b5 +#define ALT_V 0x1b6 +#define ALT_W 0x1b7 +#define ALT_X 0x1b8 +#define ALT_Y 0x1b9 +#define ALT_Z 0x1ba + +#define CTL_LEFT 0x1bb /* Control-Left-Arrow */ +#define CTL_RIGHT 0x1bc +#define CTL_PGUP 0x1bd +#define CTL_PGDN 0x1be +#define CTL_HOME 0x1bf +#define CTL_END 0x1c0 + +#define KEY_A1 0x1c1 /* upper left on Virtual keypad */ +#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */ +#define KEY_A3 0x1c3 /* upper right on Vir. keypad */ +#define KEY_B1 0x1c4 /* middle left on Virt. keypad */ +#define KEY_B2 0x1c5 /* center on Virt. keypad */ +#define KEY_B3 0x1c6 /* middle right on Vir. keypad */ +#define KEY_C1 0x1c7 /* lower left on Virt. keypad */ +#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */ +#define KEY_C3 0x1c9 /* lower right on Vir. keypad */ + +#define PADSLASH 0x1ca /* slash on keypad */ +#define PADENTER 0x1cb /* enter on keypad */ +#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */ +#define ALT_PADENTER 0x1cd /* alt-enter on keypad */ +#define PADSTOP 0x1ce /* stop on keypad */ +#define PADSTAR 0x1cf /* star on keypad */ +#define PADMINUS 0x1d0 /* minus on keypad */ +#define PADPLUS 0x1d1 /* plus on keypad */ +#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */ +#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */ +#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */ +#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */ +#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */ +#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */ +#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */ +#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */ +#define ALT_PADSLASH 0x1da /* alt-slash on keypad */ +#define ALT_PADSTAR 0x1db /* alt-star on keypad */ +#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */ +#define CTL_INS 0x1dd /* ctl-insert */ +#define ALT_DEL 0x1de /* alt-delete */ +#define ALT_INS 0x1df /* alt-insert */ +#define CTL_UP 0x1e0 /* ctl-up arrow */ +#define CTL_DOWN 0x1e1 /* ctl-down arrow */ +#define CTL_TAB 0x1e2 /* ctl-tab */ +#define ALT_TAB 0x1e3 +#define ALT_MINUS 0x1e4 +#define ALT_EQUAL 0x1e5 +#define ALT_HOME 0x1e6 +#define ALT_PGUP 0x1e7 +#define ALT_PGDN 0x1e8 +#define ALT_END 0x1e9 +#define ALT_UP 0x1ea /* alt-up arrow */ +#define ALT_DOWN 0x1eb /* alt-down arrow */ +#define ALT_RIGHT 0x1ec /* alt-right arrow */ +#define ALT_LEFT 0x1ed /* alt-left arrow */ +#define ALT_ENTER 0x1ee /* alt-enter */ +#define ALT_ESC 0x1ef /* alt-escape */ +#define ALT_BQUOTE 0x1f0 /* alt-back quote */ +#define ALT_LBRACKET 0x1f1 /* alt-left bracket */ +#define ALT_RBRACKET 0x1f2 /* alt-right bracket */ +#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */ +#define ALT_FQUOTE 0x1f4 /* alt-forward quote */ +#define ALT_COMMA 0x1f5 /* alt-comma */ +#define ALT_STOP 0x1f6 /* alt-stop */ +#define ALT_FSLASH 0x1f7 /* alt-forward slash */ +#define ALT_BKSP 0x1f8 /* alt-backspace */ +#define CTL_BKSP 0x1f9 /* ctl-backspace */ +#define PAD0 0x1fa /* keypad 0 */ + +#define CTL_PAD0 0x1fb /* ctl-keypad 0 */ +#define CTL_PAD1 0x1fc +#define CTL_PAD2 0x1fd +#define CTL_PAD3 0x1fe +#define CTL_PAD4 0x1ff +#define CTL_PAD5 0x200 +#define CTL_PAD6 0x201 +#define CTL_PAD7 0x202 +#define CTL_PAD8 0x203 +#define CTL_PAD9 0x204 + +#define ALT_PAD0 0x205 /* alt-keypad 0 */ +#define ALT_PAD1 0x206 +#define ALT_PAD2 0x207 +#define ALT_PAD3 0x208 +#define ALT_PAD4 0x209 +#define ALT_PAD5 0x20a +#define ALT_PAD6 0x20b +#define ALT_PAD7 0x20c +#define ALT_PAD8 0x20d +#define ALT_PAD9 0x20e + +#define CTL_DEL 0x20f /* clt-delete */ +#define ALT_BSLASH 0x210 /* alt-back slash */ +#define CTL_ENTER 0x211 /* ctl-enter */ + +#define SHF_PADENTER 0x212 /* shift-enter on keypad */ +#define SHF_PADSLASH 0x213 /* shift-slash on keypad */ +#define SHF_PADSTAR 0x214 /* shift-star on keypad */ +#define SHF_PADPLUS 0x215 /* shift-plus on keypad */ +#define SHF_PADMINUS 0x216 /* shift-minus on keypad */ +#define SHF_UP 0x217 /* shift-up on keypad */ +#define SHF_DOWN 0x218 /* shift-down on keypad */ +#define SHF_IC 0x219 /* shift-insert on keypad */ +#define SHF_DC 0x21a /* shift-delete on keypad */ + +#define KEY_MOUSE 0x21b /* "mouse" key */ +#define KEY_SHIFT_L 0x21c /* Left-shift */ +#define KEY_SHIFT_R 0x21d /* Right-shift */ +#define KEY_CONTROL_L 0x21e /* Left-control */ +#define KEY_CONTROL_R 0x21f /* Right-control */ +#define KEY_ALT_L 0x220 /* Left-alt */ +#define KEY_ALT_R 0x221 /* Right-alt */ +#define KEY_RESIZE 0x222 /* Window resize */ +#define KEY_SUP 0x223 /* Shifted up arrow */ +#define KEY_SDOWN 0x224 /* Shifted down arrow */ + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_SDOWN /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +int addch(const chtype); +int addchnstr(const chtype *, int); +int addchstr(const chtype *); +int addnstr(const char *, int); +int addstr(const char *); +int attroff(chtype); +int attron(chtype); +int attrset(chtype); +int attr_get(attr_t *, short *, void *); +int attr_off(attr_t, void *); +int attr_on(attr_t, void *); +int attr_set(attr_t, short, void *); +int baudrate(void); +int beep(void); +int bkgd(chtype); +void bkgdset(chtype); +int border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype); +int box(WINDOW *, chtype, chtype); +bool can_change_color(void); +int cbreak(void); +int chgat(int, attr_t, short, const void *); +int clearok(WINDOW *, bool); +int clear(void); +int clrtobot(void); +int clrtoeol(void); +int color_content(short, short *, short *, short *); +int color_set(short, void *); +int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int); +int curs_set(int); +int def_prog_mode(void); +int def_shell_mode(void); +int delay_output(int); +int delch(void); +int deleteln(void); +void delscreen(SCREEN *); +int delwin(WINDOW *); +WINDOW *derwin(WINDOW *, int, int, int, int); +int doupdate(void); +WINDOW *dupwin(WINDOW *); +int echochar(const chtype); +int echo(void); +int endwin(void); +char erasechar(void); +int erase(void); +void filter(void); +int flash(void); +int flushinp(void); +chtype getbkgd(WINDOW *); +int getnstr(char *, int); +int getstr(char *); +WINDOW *getwin(FILE *); +int halfdelay(int); +bool has_colors(void); +bool has_ic(void); +bool has_il(void); +int hline(chtype, int); +void idcok(WINDOW *, bool); +int idlok(WINDOW *, bool); +void immedok(WINDOW *, bool); +int inchnstr(chtype *, int); +int inchstr(chtype *); +chtype inch(void); +int init_color(short, short, short, short); +int init_pair(short, short, short); +WINDOW *initscr(void); +int innstr(char *, int); +int insch(chtype); +int insdelln(int); +int insertln(void); +int insnstr(const char *, int); +int insstr(const char *); +int instr(char *); +int intrflush(WINDOW *, bool); +bool isendwin(void); +bool is_linetouched(WINDOW *, int); +bool is_wintouched(WINDOW *); +char *keyname(int); +int keypad(WINDOW *, bool); +char killchar(void); +int leaveok(WINDOW *, bool); +char *longname(void); +int meta(WINDOW *, bool); +int move(int, int); +int mvaddch(int, int, const chtype); +int mvaddchnstr(int, int, const chtype *, int); +int mvaddchstr(int, int, const chtype *); +int mvaddnstr(int, int, const char *, int); +int mvaddstr(int, int, const char *); +int mvchgat(int, int, int, attr_t, short, const void *); +int mvcur(int, int, int, int); +int mvdelch(int, int); +int mvderwin(WINDOW *, int, int); +int mvgetch(int, int); +int mvgetnstr(int, int, char *, int); +int mvgetstr(int, int, char *); +int mvhline(int, int, chtype, int); +chtype mvinch(int, int); +int mvinchnstr(int, int, chtype *, int); +int mvinchstr(int, int, chtype *); +int mvinnstr(int, int, char *, int); +int mvinsch(int, int, chtype); +int mvinsnstr(int, int, const char *, int); +int mvinsstr(int, int, const char *); +int mvinstr(int, int, char *); +int mvprintw(int, int, const char *, ...); +int mvscanw(int, int, const char *, ...); +int mvvline(int, int, chtype, int); +int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +int mvwaddchstr(WINDOW *, int, int, const chtype *); +int mvwaddch(WINDOW *, int, int, const chtype); +int mvwaddnstr(WINDOW *, int, int, const char *, int); +int mvwaddstr(WINDOW *, int, int, const char *); +int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +int mvwdelch(WINDOW *, int, int); +int mvwgetch(WINDOW *, int, int); +int mvwgetnstr(WINDOW *, int, int, char *, int); +int mvwgetstr(WINDOW *, int, int, char *); +int mvwhline(WINDOW *, int, int, chtype, int); +int mvwinchnstr(WINDOW *, int, int, chtype *, int); +int mvwinchstr(WINDOW *, int, int, chtype *); +chtype mvwinch(WINDOW *, int, int); +int mvwinnstr(WINDOW *, int, int, char *, int); +int mvwinsch(WINDOW *, int, int, chtype); +int mvwinsnstr(WINDOW *, int, int, const char *, int); +int mvwinsstr(WINDOW *, int, int, const char *); +int mvwinstr(WINDOW *, int, int, char *); +int mvwin(WINDOW *, int, int); +int mvwprintw(WINDOW *, int, int, const char *, ...); +int mvwscanw(WINDOW *, int, int, const char *, ...); +int mvwvline(WINDOW *, int, int, chtype, int); +int napms(int); +WINDOW *newpad(int, int); +SCREEN *newterm(const char *, FILE *, FILE *); +WINDOW *newwin(int, int, int, int); +int nl(void); +int nocbreak(void); +int nodelay(WINDOW *, bool); +int noecho(void); +int nonl(void); +void noqiflush(void); +int noraw(void); +int notimeout(WINDOW *, bool); +int overlay(const WINDOW *, WINDOW *); +int overwrite(const WINDOW *, WINDOW *); +int pair_content(short, short *, short *); +int pechochar(WINDOW *, chtype); +int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +int prefresh(WINDOW *, int, int, int, int, int, int); +int printw(const char *, ...); +int putwin(WINDOW *, FILE *); +void qiflush(void); +int raw(void); +int redrawwin(WINDOW *); +int refresh(void); +int reset_prog_mode(void); +int reset_shell_mode(void); +int resetty(void); +int ripoffline(int, int (*)(WINDOW *, int)); +int savetty(void); +int scanw(const char *, ...); +int scr_dump(const char *); +int scr_init(const char *); +int scr_restore(const char *); +int scr_set(const char *); +int scrl(int); +int scroll(WINDOW *); +int scrollok(WINDOW *, bool); +SCREEN *set_term(SCREEN *); +int setscrreg(int, int); +int slk_attroff(const chtype); +int slk_attr_off(const attr_t, void *); +int slk_attron(const chtype); +int slk_attr_on(const attr_t, void *); +int slk_attrset(const chtype); +int slk_attr_set(const attr_t, short, void *); +int slk_clear(void); +int slk_color(short); +int slk_init(int); +char *slk_label(int); +int slk_noutrefresh(void); +int slk_refresh(void); +int slk_restore(void); +int slk_set(int, const char *, int); +int slk_touch(void); +int standend(void); +int standout(void); +int start_color(void); +WINDOW *subpad(WINDOW *, int, int, int, int); +WINDOW *subwin(WINDOW *, int, int, int, int); +int syncok(WINDOW *, bool); +chtype termattrs(void); +attr_t term_attrs(void); +char *termname(void); +void timeout(int); +int touchline(WINDOW *, int, int); +int touchwin(WINDOW *); +int typeahead(int); +int untouchwin(WINDOW *); +void use_env(bool); +int vidattr(chtype); +int vid_attr(attr_t, short, void *); +int vidputs(chtype, int (*)(int)); +int vid_puts(attr_t, short, void *, int (*)(int)); +int vline(chtype, int); +int vw_printw(WINDOW *, const char *, va_list); +int vwprintw(WINDOW *, const char *, va_list); +int vw_scanw(WINDOW *, const char *, va_list); +int vwscanw(WINDOW *, const char *, va_list); +int waddchnstr(WINDOW *, const chtype *, int); +int waddchstr(WINDOW *, const chtype *); +int waddch(WINDOW *, const chtype); +int waddnstr(WINDOW *, const char *, int); +int waddstr(WINDOW *, const char *); +int wattroff(WINDOW *, chtype); +int wattron(WINDOW *, chtype); +int wattrset(WINDOW *, chtype); +int wattr_get(WINDOW *, attr_t *, short *, void *); +int wattr_off(WINDOW *, attr_t, void *); +int wattr_on(WINDOW *, attr_t, void *); +int wattr_set(WINDOW *, attr_t, short, void *); +void wbkgdset(WINDOW *, chtype); +int wbkgd(WINDOW *, chtype); +int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +int wchgat(WINDOW *, int, attr_t, short, const void *); +int wclear(WINDOW *); +int wclrtobot(WINDOW *); +int wclrtoeol(WINDOW *); +int wcolor_set(WINDOW *, short, void *); +void wcursyncup(WINDOW *); +int wdelch(WINDOW *); +int wdeleteln(WINDOW *); +int wechochar(WINDOW *, const chtype); +int werase(WINDOW *); +int wgetch(WINDOW *); +int wgetnstr(WINDOW *, char *, int); +int wgetstr(WINDOW *, char *); +int whline(WINDOW *, chtype, int); +int winchnstr(WINDOW *, chtype *, int); +int winchstr(WINDOW *, chtype *); +chtype winch(WINDOW *); +int winnstr(WINDOW *, char *, int); +int winsch(WINDOW *, chtype); +int winsdelln(WINDOW *, int); +int winsertln(WINDOW *); +int winsnstr(WINDOW *, const char *, int); +int winsstr(WINDOW *, const char *); +int winstr(WINDOW *, char *); +int wmove(WINDOW *, int, int); +int wnoutrefresh(WINDOW *); +int wprintw(WINDOW *, const char *, ...); +int wredrawln(WINDOW *, int, int); +int wrefresh(WINDOW *); +int wscanw(WINDOW *, const char *, ...); +int wscrl(WINDOW *, int); +int wsetscrreg(WINDOW *, int, int); +int wstandend(WINDOW *); +int wstandout(WINDOW *); +void wsyncdown(WINDOW *); +void wsyncup(WINDOW *); +void wtimeout(WINDOW *, int); +int wtouchln(WINDOW *, int, int, int); +int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +int addnwstr(const wchar_t *, int); +int addwstr(const wchar_t *); +int add_wch(const cchar_t *); +int add_wchnstr(const cchar_t *, int); +int add_wchstr(const cchar_t *); +int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +int box_set(WINDOW *, const cchar_t *, const cchar_t *); +int echo_wchar(const cchar_t *); +int erasewchar(wchar_t *); +int getbkgrnd(cchar_t *); +int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +int getn_wstr(wint_t *, int); +int get_wch(wint_t *); +int get_wstr(wint_t *); +int hline_set(const cchar_t *, int); +int innwstr(wchar_t *, int); +int ins_nwstr(const wchar_t *, int); +int ins_wch(const cchar_t *); +int ins_wstr(const wchar_t *); +int inwstr(wchar_t *); +int in_wch(cchar_t *); +int in_wchnstr(cchar_t *, int); +int in_wchstr(cchar_t *); +char *key_name(wchar_t); +int killwchar(wchar_t *); +int mvaddnwstr(int, int, const wchar_t *, int); +int mvaddwstr(int, int, const wchar_t *); +int mvadd_wch(int, int, const cchar_t *); +int mvadd_wchnstr(int, int, const cchar_t *, int); +int mvadd_wchstr(int, int, const cchar_t *); +int mvgetn_wstr(int, int, wint_t *, int); +int mvget_wch(int, int, wint_t *); +int mvget_wstr(int, int, wint_t *); +int mvhline_set(int, int, const cchar_t *, int); +int mvinnwstr(int, int, wchar_t *, int); +int mvins_nwstr(int, int, const wchar_t *, int); +int mvins_wch(int, int, const cchar_t *); +int mvins_wstr(int, int, const wchar_t *); +int mvinwstr(int, int, wchar_t *); +int mvin_wch(int, int, cchar_t *); +int mvin_wchnstr(int, int, cchar_t *, int); +int mvin_wchstr(int, int, cchar_t *); +int mvvline_set(int, int, const cchar_t *, int); +int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +int mvwget_wch(WINDOW *, int, int, wint_t *); +int mvwget_wstr(WINDOW *, int, int, wint_t *); +int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +int mvwins_wch(WINDOW *, int, int, const cchar_t *); +int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +int mvwin_wch(WINDOW *, int, int, cchar_t *); +int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +int mvwinwstr(WINDOW *, int, int, wchar_t *); +int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +int pecho_wchar(WINDOW *, const cchar_t*); +int setcchar(cchar_t*, const wchar_t*, const attr_t, short, const void*); +int slk_wset(int, const wchar_t *, int); +int unget_wch(const wchar_t); +int vline_set(const cchar_t *, int); +int waddnwstr(WINDOW *, const wchar_t *, int); +int waddwstr(WINDOW *, const wchar_t *); +int wadd_wch(WINDOW *, const cchar_t *); +int wadd_wchnstr(WINDOW *, const cchar_t *, int); +int wadd_wchstr(WINDOW *, const cchar_t *); +int wbkgrnd(WINDOW *, const cchar_t *); +void wbkgrndset(WINDOW *, const cchar_t *); +int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +int wecho_wchar(WINDOW *, const cchar_t *); +int wgetbkgrnd(WINDOW *, cchar_t *); +int wgetn_wstr(WINDOW *, wint_t *, int); +int wget_wch(WINDOW *, wint_t *); +int wget_wstr(WINDOW *, wint_t *); +int whline_set(WINDOW *, const cchar_t *, int); +int winnwstr(WINDOW *, wchar_t *, int); +int wins_nwstr(WINDOW *, const wchar_t *, int); +int wins_wch(WINDOW *, const cchar_t *); +int wins_wstr(WINDOW *, const wchar_t *); +int winwstr(WINDOW *, wchar_t *); +int win_wch(WINDOW *, cchar_t *); +int win_wchnstr(WINDOW *, cchar_t *, int); +int win_wchstr(WINDOW *, cchar_t *); +wchar_t *wunctrl(cchar_t *); +int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +chtype getattrs(WINDOW *); +int getbegx(WINDOW *); +int getbegy(WINDOW *); +int getmaxx(WINDOW *); +int getmaxy(WINDOW *); +int getparx(WINDOW *); +int getpary(WINDOW *); +int getcurx(WINDOW *); +int getcury(WINDOW *); +void traceoff(void); +void traceon(void); +char *unctrl(chtype); + +int crmode(void); +int nocrmode(void); +int draino(int); +int resetterm(void); +int fixterm(void); +int saveterm(void); +int setsyx(int, int); + +int mouse_set(unsigned long); +int mouse_on(unsigned long); +int mouse_off(unsigned long); +int request_mouse_pos(void); +int map_button(unsigned long); +void wmouse_position(WINDOW *, int *, int *); +unsigned long getmouse(void); +unsigned long getbmap(void); + +/* ncurses */ + +int assume_default_colors(int, int); +const char *curses_version(void); +bool has_key(int); +int use_default_colors(void); +int wresize(WINDOW *, int, int); + +int mouseinterval(int); +mmask_t mousemask(mmask_t, mmask_t *); +bool mouse_trafo(int *, int *, bool); +int nc_getmouse(MEVENT *); +int ungetmouse(MEVENT *); +bool wenclose(const WINDOW *, int, int); +bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +int addrawch(chtype); +int insrawch(chtype); +bool is_termresized(void); +int mvaddrawch(int, int, chtype); +int mvdeleteln(int, int); +int mvinsertln(int, int); +int mvinsrawch(int, int, chtype); +int mvwaddrawch(WINDOW *, int, int, chtype); +int mvwdeleteln(WINDOW *, int, int); +int mvwinsertln(WINDOW *, int, int); +int mvwinsrawch(WINDOW *, int, int, chtype); +int raw_output(bool); +int resize_term(int, int); +WINDOW *resize_window(WINDOW *, int, int); +int waddrawch(WINDOW *, chtype); +int winsrawch(WINDOW *, chtype); +char wordchar(void); + +#ifdef PDC_WIDE +wchar_t *slk_wlabel(int); +#endif + +void PDC_debug(const char *, ...); +int PDC_ungetch(int); +int PDC_set_blink(bool); +int PDC_set_line_color(short); +void PDC_set_title(const char *); + +int PDC_clearclipboard(void); +int PDC_freeclipboard(char *); +int PDC_getclipboard(char **, long *); +int PDC_setclipboard(const char *, long); + +unsigned long PDC_get_input_fd(void); +unsigned long PDC_get_key_modifiers(void); +int PDC_return_key_modifiers(bool); +int PDC_save_key_modifiers(bool); + +#ifdef XCURSES +WINDOW *Xinitscr(int, char **); +void XCursesExit(void); +int sb_init(void); +int sb_set_horz(int, int, int); +int sb_set_vert(int, int, int); +int sb_get_horz(int *, int *, int *); +int sb_get_vert(int *, int *, int *); +int sb_refresh(void); +#endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/samtools/win32/zconf.h b/samtools/win32/zconf.h new file mode 100644 index 0000000..03a9431 --- /dev/null +++ b/samtools/win32/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/samtools/win32/zlib.h b/samtools/win32/zlib.h new file mode 100644 index 0000000..0228179 --- /dev/null +++ b/samtools/win32/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/setup.cfg b/setup.cfg index 652736c..b9711b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,3 +4,9 @@ vendor = TDB packager = TDB distribution-name = Red Hat Linux requires = python + +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + diff --git a/setup.py b/setup.py index ef3d29f..4f9b15a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,8 @@ pysam ''' -import os, sys, glob, shutil, hashlib +import os, sys, glob, shutil, hashlib, re, fnmatch +import platform name = "pysam" @@ -16,11 +17,37 @@ import version version = version.__version__ -samtools_exclude = ( "bamtk.c", "razip.c", "bgzip.c", "errmod.c", "bam_reheader.c", "bam2bcf.c" ) +samtools_exclude = ( "bamtk.c", "razip.c", "bgzip.c", + "bam_reheader.c", + "main.c", "calDepth.c", "bam2bed.c", + "wgsim.c", "md5fa.c", "maq2sam.c",) samtools_dest = os.path.abspath( "samtools" ) tabix_exclude = ( "main.c", ) tabix_dest = os.path.abspath( "tabix" ) +def locate(pattern, root=os.curdir): + '''Locate all files matching supplied filename pattern in and below + supplied root directory.''' + for path, dirs, files in os.walk(os.path.abspath(root)): + 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": if len(sys.argv) < 3: raise ValueError("missing PATH to samtools source directory") @@ -34,26 +61,74 @@ if len(sys.argv) >= 2 and sys.argv[1] == "import": srcdir = os.path.abspath( srcdir ) if not os.path.exists( srcdir ): raise IOError( "samtools src dir `%s` does not exist." % srcdir ) - cfiles = glob.glob( os.path.join( srcdir, "*.c" ) ) - hfiles = glob.glob( os.path.join( srcdir, "*.h" ) ) + cfiles = locate( "*.c", srcdir ) + hfiles = locate( "*.h", srcdir ) ncopied = 0 - for new_file in cfiles + hfiles: - f = os.path.basename(new_file) - if f in exclude: continue - old_file = os.path.join( destdir, f ) + + def _compareAndCopy( src, srcdir, destdir, exclude ): + + d, f = os.path.split(src) + if f in exclude: return None + common_prefix = os.path.commonprefix( (d, srcdir ) ) + subdir = re.sub( common_prefix, "", d )[1:] + targetdir = os.path.join( destdir, subdir ) + if not os.path.exists( targetdir ): + os.makedirs( targetdir ) + old_file = os.path.join( targetdir, f ) if os.path.exists( old_file ): md5_old = hashlib.md5("".join(open(old_file,"r").readlines())).digest() - md5_new = hashlib.md5("".join(open(new_file,"r").readlines())).digest() - if md5_old == md5_new: continue - raise ValueError( "incompatible files for %s and %s" % (old_file, new_file )) + md5_new = hashlib.md5("".join(open(src,"r").readlines())).digest() + if md5_old != md5_new: + raise ValueError( "incompatible files for %s and %s" % (old_file, src )) + + shutil.copy( src, targetdir ) + return old_file + + for src_file in hfiles: + _compareAndCopy( src_file, srcdir,destdir, exclude ) + ncopied += 1 - shutil.copy( new_file, destdir ) + cf = [] + for src_file in cfiles: + cf.append( _compareAndCopy( src_file, srcdir, destdir, exclude ) ) ncopied += 1 + 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) + + sys.exit(0) -from distutils.core import setup, Extension -from Cython.Distutils import build_ext +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() + +from setuptools import Extension, setup + +## note that for automatic cythoning, +## both pyrex and cython need to be installed. +## see http://mail.python.org/pipermail/distutils-sig/2007-September/008204.html + +try: + from Cython.Distutils import build_ext +except: + from setuptools.command.build_ext import build_ext classifiers = """ Development Status :: 2 - Alpha @@ -68,27 +143,55 @@ 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", "*.c" ) ), + [ "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'), + define_macros = [('_FILE_OFFSET_BITS','64'), ('_USE_KNETFILE','')], ) tabix = Extension( "ctabix", # name of extension - [ "pysam/ctabix.pyx" ] +\ - [ "pysam/%s" % x for x in ()] +\ - glob.glob( os.path.join( "tabix", "*.c" ) ), + [ "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_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", "pysam" ], + include_dirs= ["tabix",] + include_os, libraries=[ "z", ], language="c", ) @@ -108,8 +211,12 @@ metadata = { "pysam/Pileup", "pysam/namedtuple", "pysam/version" ], - 'ext_modules': [samtools, tabix], + 'requires' : ['cython (>=0.12)'], + '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 index 0000000..c3ab06f --- /dev/null +++ b/tabix/bedidx.c.pysam.c @@ -0,0 +1,158 @@ +#include "pysam.h" + +#include +#include +#include +#include +#include + +#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); +} diff --git a/tabix/bgzf.c b/tabix/bgzf.c.pysam.c similarity index 83% rename from tabix/bgzf.c rename to tabix/bgzf.c.pysam.c index 7a936a8..067b89d 100644 --- a/tabix/bgzf.c +++ b/tabix/bgzf.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* The MIT License Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology @@ -111,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; @@ -148,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; @@ -156,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 @@ -177,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; @@ -194,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; } @@ -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,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; @@ -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 @@ -471,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; @@ -498,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; @@ -508,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; @@ -527,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"); @@ -550,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; @@ -573,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; } } @@ -581,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 @@ -612,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); @@ -648,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; @@ -659,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 diff --git a/tabix/bgzf.h b/tabix/bgzf.h index f544a67..7295f37 100644 --- a/tabix/bgzf.h +++ b/tabix/bgzf.h @@ -26,7 +26,6 @@ #include #include -#include #include #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; @@ -126,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 } diff --git a/tabix/bgzip.c b/tabix/bgzip.c.pysam.c similarity index 72% rename from tabix/bgzip.c rename to tabix/bgzip.c.pysam.c index d144632..55e7029 100644 --- a/tabix/bgzip.c +++ b/tabix/bgzip.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* The MIT License Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology @@ -35,15 +37,15 @@ static const int WINDOW_SIZE = 64 * 1024; static int bgzip_main_usage() { - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: bgzip [options] [file] ...\n\n"); - fprintf(stderr, "Options: -c write on standard output, keep original files unchanged\n"); - fprintf(stderr, " -d decompress\n"); - fprintf(stderr, " -f overwrite files without asking\n"); - fprintf(stderr, " -b INT decompress at virtual file pointer INT\n"); - fprintf(stderr, " -s INT decompress INT bytes in the uncompressed file\n"); - fprintf(stderr, " -h give this help\n"); - fprintf(stderr, "\n"); + fprintf(pysamerr, "\n"); + fprintf(pysamerr, "Usage: bgzip [options] [file] ...\n\n"); + fprintf(pysamerr, "Options: -c write on standard output, keep original files unchanged\n"); + fprintf(pysamerr, " -d decompress\n"); + fprintf(pysamerr, " -f overwrite files without asking\n"); + fprintf(pysamerr, " -b INT decompress at virtual file pointer INT\n"); + fprintf(pysamerr, " -s INT decompress INT bytes in the uncompressed file\n"); + fprintf(pysamerr, " -h give this help\n"); + fprintf(pysamerr, "\n"); return 1; } @@ -53,17 +55,17 @@ static int write_open(const char *fn, int is_forced) char c; if (!is_forced) { if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0666)) < 0 && errno == EEXIST) { - fprintf(stderr, "[bgzip] %s already exists; do you wish to overwrite (y or n)? ", fn); + fprintf(pysamerr, "[bgzip] %s already exists; do you wish to overwrite (y or n)? ", fn); scanf("%c", &c); if (c != 'Y' && c != 'y') { - fprintf(stderr, "[bgzip] not overwritten\n"); + fprintf(pysamerr, "[bgzip] not overwritten\n"); exit(1); } } } if (fd < 0) { if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { - fprintf(stderr, "[bgzip] %s: Fail to write\n", fn); + fprintf(pysamerr, "[bgzip] %s: Fail to write\n", fn); exit(1); } } @@ -72,7 +74,7 @@ static int write_open(const char *fn, int is_forced) static void fail(BGZF* fp) { - fprintf(stderr, "Error: %s\n", fp->error); + fprintf(pysamerr, "Error: %s\n", fp->error); exit(1); } @@ -96,7 +98,7 @@ int main(int argc, char **argv) } if (size >= 0) end = start + size; if (end >= 0 && end < start) { - fprintf(stderr, "[bgzip] Illegal region: [%ld, %ld]\n", start, end); + fprintf(pysamerr, "[bgzip] Illegal region: [%ld, %ld]\n", start, end); return 1; } if (compress == 1) { @@ -108,12 +110,12 @@ int main(int argc, char **argv) { if ( stat(argv[optind],&sbuf)<0 ) { - fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); + fprintf(pysamerr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); return 1; } if ((f_src = open(argv[optind], O_RDONLY)) < 0) { - fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); + fprintf(pysamerr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); return 1; } @@ -138,7 +140,7 @@ int main(int argc, char **argv) if (bgzf_write(fp, buffer, c) < 0) fail(fp); // f_dst will be closed here if (bgzf_close(fp) < 0) fail(fp); - if (argc > optind) unlink(argv[optind]); + if (argc > optind && !pstdout) unlink(argv[optind]); free(buffer); close(f_src); return 0; @@ -150,26 +152,31 @@ int main(int argc, char **argv) { if ( stat(argv[optind],&sbuf)<0 ) { - fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); + fprintf(pysamerr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]); return 1; } char *name; int len = strlen(argv[optind]); if ( strcmp(argv[optind]+len-3,".gz") ) { - fprintf(stderr, "[bgzip] %s: unknown suffix -- ignored\n", argv[optind]); + fprintf(pysamerr, "[bgzip] %s: unknown suffix -- ignored\n", argv[optind]); return 1; } fp = bgzf_open(argv[optind], "r"); if (fp == NULL) { - fprintf(stderr, "[bgzip] Could not open file: %s\n", argv[optind]); + fprintf(pysamerr, "[bgzip] Could not open file: %s\n", argv[optind]); return 1; } - name = strdup(argv[optind]); - name[strlen(name) - 3] = '\0'; - f_dst = write_open(name, is_forced); - free(name); + if (pstdout) { + f_dst = fileno(stdout); + } + else { + name = strdup(argv[optind]); + name[strlen(name) - 3] = '\0'; + f_dst = write_open(name, is_forced); + free(name); + } } else if (!pstdout && isatty(fileno((FILE *)stdin)) ) return bgzip_main_usage(); @@ -178,7 +185,7 @@ int main(int argc, char **argv) f_dst = fileno(stdout); fp = bgzf_fdopen(fileno(stdin), "r"); if (fp == NULL) { - fprintf(stderr, "[bgzip] Could not read from stdin: %s\n", strerror(errno)); + fprintf(pysamerr, "[bgzip] Could not read from stdin: %s\n", strerror(errno)); return 1; } } diff --git a/tabix/index.c b/tabix/index.c.pysam.c similarity index 85% rename from tabix/index.c rename to tabix/index.c.pysam.c index e5b227c..486e26f 100644 --- a/tabix/index.c +++ b/tabix/index.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include @@ -19,7 +21,7 @@ typedef struct { } pair64_t; #define pair64_lt(a,b) ((a).u < (b).u) -KSORT_INIT(off, pair64_t, pair64_lt) +KSORT_INIT(offt, pair64_t, pair64_lt) typedef struct { uint32_t m, n; @@ -156,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; @@ -190,19 +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 == 5) { // ALT - char *t; - int max = 1; - for (s = str->s + b; s < str->s + i;) { - if (s[i] == 'D') { - long x = strtol(s + 1, &t, 10); - if (x > max) max = x; - s = t + 1; - } else ++s; + if (id == 4) { + if (b < i) intv->end = intv->beg + (i - b); + } else if (id == 8) { // look for "END=" + int c = line[i]; + line[i] = 0; + s = strstr(line + b, "END="); + if (s == line + b) s += 4; + else if (s) { + s = strstr(line + b, ";END="); + if (s) s += 5; } - intv->end = intv->beg + max; + if (s) intv->end = strtol(s, &s, 0); + line[i] = c; } } } @@ -210,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 * ************/ @@ -238,7 +263,7 @@ static inline void insert_offset(khash_t(i) *h, int bin, uint64_t beg, uint64_t l->list[l->n].u = beg; l->list[l->n++].v = end; } -static inline void insert_offset2(ti_lidx_t *index2, int _beg, int _end, uint64_t offset) +static inline uint64_t insert_offset2(ti_lidx_t *index2, int _beg, int _end, uint64_t offset) { int i, beg, end; beg = _beg >> TAD_LIDX_SHIFT; @@ -257,6 +282,7 @@ static inline void insert_offset2(ti_lidx_t *index2, int _beg, int _end, uint64_ if (index2->offset[i] == 0) index2->offset[i] = offset; } if (index2->n < end + 1) index2->n = end + 1; + return (uint64_t)beg<<32 | end; } static void merge_chunks(ti_index_t *idx) @@ -297,7 +323,7 @@ ti_index_t *ti_index_core(BGZF *fp, const ti_conf_t *conf) ti_index_t *idx; uint32_t last_bin, save_bin; int32_t last_coor, last_tid, save_tid; - uint64_t save_off, last_off, lineno = 0; + uint64_t save_off, last_off, lineno = 0, offset0 = (uint64_t)-1, tmp; kstring_t *str; str = calloc(1, sizeof(kstring_t)); @@ -319,14 +345,25 @@ 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? [pos %d]\n",(unsigned long long)lineno,intv.beg+1); + exit(1); + } last_tid = intv.tid; last_bin = 0xffffffffu; } else if (last_coor > intv.beg) { - fprintf(stderr, "[ti_index_core] the file out of order at line %llu\n", (unsigned long long)lineno); + fprintf(pysamerr, "[ti_index_core] the file out of order at line %llu\n", (unsigned long long)lineno); exit(1); } - insert_offset2(&idx->index2[intv.tid], intv.beg, intv.end, last_off); + tmp = insert_offset2(&idx->index2[intv.tid], intv.beg, intv.end, last_off); + if (last_off == 0) offset0 = tmp; if (intv.bin != last_bin) { // then possibly write the binning index if (save_bin != 0xffffffffu) // save_bin==0xffffffffu only happens to the first record insert_offset(idx->index[save_tid], save_bin, save_off, last_off); @@ -336,7 +373,7 @@ ti_index_t *ti_index_core(BGZF *fp, const ti_conf_t *conf) if (save_tid < 0) break; } if (bgzf_tell(fp) <= last_off) { - fprintf(stderr, "[ti_index_core] bug in BGZF: %llx < %llx\n", + fprintf(pysamerr, "[ti_index_core] bug in BGZF: %llx < %llx\n", (unsigned long long)bgzf_tell(fp), (unsigned long long)last_off); exit(1); } @@ -346,6 +383,10 @@ ti_index_t *ti_index_core(BGZF *fp, const ti_conf_t *conf) if (save_tid >= 0) insert_offset(idx->index[save_tid], save_bin, save_off, bgzf_tell(fp)); merge_chunks(idx); fill_missing(idx); + if (offset0 != (uint64_t)-1 && idx->n && idx->index2[0].offset) { + int i, beg = offset0>>32, end = offset0&0xffffffffu; + for (i = beg; i <= end; ++i) idx->index2[0].offset[i] = 0; + } free(str->s); free(str); return idx; @@ -469,12 +510,12 @@ static ti_index_t *ti_index_load_core(BGZF *fp) ti_index_t *idx; ti_is_be = bam_is_big_endian(); if (fp == 0) { - fprintf(stderr, "[ti_index_load_core] fail to load index.\n"); + fprintf(pysamerr, "[ti_index_load_core] fail to load index.\n"); return 0; } bgzf_read(fp, magic, 4); if (strncmp(magic, "TBI\1", 4)) { - fprintf(stderr, "[ti_index_load] wrong magic number.\n"); + fprintf(pysamerr, "[ti_index_load] wrong magic number.\n"); return 0; } idx = (ti_index_t*)calloc(1, sizeof(ti_index_t)); @@ -580,11 +621,11 @@ static void download_from_remote(const char *url) ++fn; // fn now points to the file name fp_remote = knet_open(url, "r"); if (fp_remote == 0) { - fprintf(stderr, "[download_from_remote] fail to open remote file.\n"); + fprintf(pysamerr, "[download_from_remote] fail to open remote file.\n"); return; } if ((fp = fopen(fn, "w")) == 0) { - fprintf(stderr, "[download_from_remote] fail to create file in the working directory.\n"); + fprintf(pysamerr, "[download_from_remote] fail to create file in the working directory.\n"); knet_close(fp_remote); return; } @@ -617,7 +658,7 @@ static char *get_local_version(const char *fn) free(url); return fnidx; } - fprintf(stderr, "[%s] downloading the index file...\n", __func__); + fprintf(pysamerr, "[%s] downloading the index file...\n", __func__); download_from_remote(url); free(url); } @@ -643,8 +684,8 @@ ti_index_t *ti_index_load(const char *fn) char *fname = get_local_version(fn); if (fname == 0) return 0; idx = ti_index_load_local(fname); + if (idx == 0) fprintf(pysamerr, "[ti_index_load] fail to load the index: %s\n", fname); free(fname); - if (idx == 0) fprintf(stderr, "[ti_index_load] fail to load BAM index.\n"); return idx; } @@ -654,7 +695,7 @@ int ti_index_build2(const char *fn, const ti_conf_t *conf, const char *_fnidx) BGZF *fp, *fpidx; ti_index_t *idx; if ((fp = bgzf_open(fn, "r")) == 0) { - fprintf(stderr, "[ti_index_build2] fail to open the BAM file.\n"); + fprintf(pysamerr, "[ti_index_build2] fail to open the file: %s\n", fn); return -1; } idx = ti_index_core(fp, conf); @@ -665,7 +706,7 @@ int ti_index_build2(const char *fn, const ti_conf_t *conf, const char *_fnidx) } else fnidx = strdup(_fnidx); fpidx = bgzf_open(fnidx, "w"); if (fpidx == 0) { - fprintf(stderr, "[ti_index_build2] fail to create the index file.\n"); + fprintf(pysamerr, "[ti_index_build2] fail to create the index file.\n"); free(fnidx); return -1; } @@ -801,10 +842,13 @@ ti_iter_t ti_iter_query(const ti_index_t *idx, int tid, int beg, int end) if (p->list[j].v > min_off) off[n_off++] = p->list[j]; } } + if (n_off == 0) { + free(bins); free(off); return iter; + } free(bins); { int l; - ks_introsort(off, n_off, off); + ks_introsort(offt, n_off, off); // resolve completely contained adjacent blocks for (i = 1, l = 0; i < n_off; ++i) if (off[l].v < off[i].v) @@ -886,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/knetfile.c b/tabix/knetfile.c.pysam.c similarity index 95% rename from tabix/knetfile.c rename to tabix/knetfile.c.pysam.c index 7c96a3e..88d92f5 100644 --- a/tabix/knetfile.c +++ b/tabix/knetfile.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + /* The MIT License Copyright (c) 2008 Genome Research Ltd (GRL). @@ -75,9 +77,9 @@ static int socket_wait(int fd, int is_read) if (ret == -1) perror("select"); #else if (ret == 0) - fprintf(stderr, "select time-out\n"); + fprintf(pysamerr, "select time-out\n"); else if (ret == SOCKET_ERROR) - fprintf(stderr, "select: %d\n", WSAGetLastError()); + fprintf(pysamerr, "select: %d\n", WSAGetLastError()); #endif return ret; } @@ -151,7 +153,7 @@ static SOCKET socket_connect(const char *host, const char *port) { #define __err_connect(func) \ do { \ - fprintf(stderr, "%s: %d\n", func, WSAGetLastError()); \ + fprintf(pysamerr, "%s: %d\n", func, WSAGetLastError()); \ return -1; \ } while (0) @@ -215,7 +217,7 @@ static int kftp_get_response(knetFile *ftp) char *p; if (socket_wait(ftp->ctrl_fd, 1) <= 0) return 0; while (netread(ftp->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O - //fputc(c, stderr); + //fputc(c, pysamerr); if (n >= ftp->max_response) { ftp->max_response = ftp->max_response? ftp->max_response<<1 : 256; ftp->response = realloc(ftp->response, ftp->max_response); @@ -259,7 +261,7 @@ static int kftp_pasv_connect(knetFile *ftp) { char host[80], port[10]; if (ftp->pasv_port == 0) { - fprintf(stderr, "[kftp_pasv_connect] kftp_pasv_prep() is not called before hand.\n"); + fprintf(pysamerr, "[kftp_pasv_connect] kftp_pasv_prep() is not called before hand.\n"); return -1; } sprintf(host, "%d.%d.%d.%d", ftp->pasv_ip[0], ftp->pasv_ip[1], ftp->pasv_ip[2], ftp->pasv_ip[3]); @@ -331,7 +333,7 @@ int kftp_connect_file(knetFile *fp) #ifndef _WIN32 if ( sscanf(fp->response,"%*d %lld", &file_size) != 1 ) { - fprintf(stderr,"[kftp_connect_file] %s\n", fp->response); + fprintf(pysamerr,"[kftp_connect_file] %s\n", fp->response); return -1; } #else @@ -356,7 +358,7 @@ int kftp_connect_file(knetFile *fp) kftp_pasv_connect(fp); ret = kftp_get_response(fp); if (ret != 150) { - fprintf(stderr, "[kftp_connect_file] %s\n", fp->response); + fprintf(pysamerr, "[kftp_connect_file] %s\n", fp->response); netclose(fp->fd); fp->fd = -1; return -1; @@ -437,7 +439,7 @@ int khttp_connect_file(knetFile *fp) } } else if (ret != 206 && ret != 200) { free(buf); - fprintf(stderr, "[khttp_connect_file] fail to open file (HTTP code: %d).\n", ret); + fprintf(pysamerr, "[khttp_connect_file] fail to open file (HTTP code: %d).\n", ret); netclose(fp->fd); fp->fd = -1; return -1; @@ -455,7 +457,7 @@ knetFile *knet_open(const char *fn, const char *mode) { knetFile *fp = 0; if (mode[0] != 'r') { - fprintf(stderr, "[kftp_open] only mode \"r\" is supported.\n"); + fprintf(pysamerr, "[kftp_open] only mode \"r\" is supported.\n"); return 0; } if (strstr(fn, "ftp://") == fn) { @@ -537,7 +539,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) off_t offset = lseek(fp->fd, off, whence); if (offset == -1) { // Be silent, it is OK for knet_seek to fail when the file is streamed - // fprintf(stderr,"[knet_seek] %s\n", strerror(errno)); + // fprintf(pysamerr,"[knet_seek] %s\n", strerror(errno)); return -1; } fp->offset = offset; @@ -557,7 +559,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) else if (fp->type == KNF_TYPE_HTTP) { if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future? - fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n"); + fprintf(pysamerr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n"); errno = ESPIPE; return -1; } @@ -569,7 +571,7 @@ off_t knet_seek(knetFile *fp, int64_t off, int whence) return fp->offset; } errno = EINVAL; - fprintf(stderr,"[knet_seek] %s\n", strerror(errno)); + fprintf(pysamerr,"[knet_seek] %s\n", strerror(errno)); return -1; } diff --git a/tabix/kseq.h b/tabix/kseq.h new file mode 100644 index 0000000..82face0 --- /dev/null +++ b/tabix/kseq.h @@ -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 */ + +/* + 2009-07-16 (lh3): in kstream_t, change "char*" to "unsigned char*" + */ + +/* Last Modified: 12APR2009 */ + +#ifndef AC_KSEQ_H +#define AC_KSEQ_H + +#include +#include +#include + +#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/kstring.c b/tabix/kstring.c.pysam.c similarity index 99% rename from tabix/kstring.c rename to tabix/kstring.c.pysam.c index e0203fa..3114a23 100644 --- a/tabix/kstring.c +++ b/tabix/kstring.c.pysam.c @@ -1,3 +1,5 @@ +#include "pysam.h" + #include #include #include diff --git a/tabix/msvc_compat.h b/tabix/msvc_compat.h new file mode 100644 index 0000000..624cc99 --- /dev/null +++ b/tabix/msvc_compat.h @@ -0,0 +1,60 @@ +// Windows-specific code, include with: +// #ifdef _MSC_VER +// #include +// #endif + +//#define _CRT_SECURE_NO_WARNINGS +#ifndef MSVC_COMPAT_H +#define MSVC_COMPAT_H + +#define inline __inline +#define __func__ __FUNCTION__ + +#include +#define isnan _isnan +static int isinf(double x) { + int y = _finite(x); + if(y == 0) { + return 0; + } else { + return 1; + } +} +#define alloca _alloca +#define atoll _atoi64 + +#define ftello ftell + +typedef int bool; + +static int R_OK = 4; + +#ifndef lgamma +/* Log gamma function + * \log{\Gamma(z)} + * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245 + */ +static double lgamma(double z) +{ + double x = 0; + x += 0.1659470187408462e-06 / (z+7); + x += 0.9934937113930748e-05 / (z+6); + x -= 0.1385710331296526 / (z+5); + x += 12.50734324009056 / (z+4); + x -= 176.6150291498386 / (z+3); + x += 771.3234287757674 / (z+2); + x -= 1259.139216722289 / (z+1); + x += 676.5203681218835 / z; + x += 0.9999999999995183; + return log(x) - 5.58106146679532777 - z + (z-0.5) * log(z+6.5); +} +#endif + +#ifndef M_LN10 +#define M_LN10 2.30258509299404568402 +#endif +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif + +#endif diff --git a/tabix/pysam.h b/tabix/pysam.h new file mode 100644 index 0000000..008cbbd --- /dev/null +++ b/tabix/pysam.h @@ -0,0 +1,5 @@ +#ifndef PYSAM_H +#define PYSAM_H +#include "stdio.h" +extern FILE * pysamerr; +#endif diff --git a/tabix/tabix.h b/tabix/tabix.h index 4390c09..7b4497a 100644 --- a/tabix/tabix.h +++ b/tabix/tabix.h @@ -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 * *******************/ diff --git a/tests/Makefile b/tests/Makefile index 38d30f0..3482829 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,11 +1,14 @@ -all: ex1.glf ex1.pileup.gz ex1.bam.bai ex1.glfview.gz \ +all: ex1.pileup.gz ex1.bam.bai \ ex2.sam.gz ex2.sam ex1.sam \ ex2.bam \ ex3.bam ex3.bam.bai \ ex4.bam ex4.bam.bai \ ex5.bam ex5.bam.bai \ ex6.bam \ - ex8.bam + ex8.bam ex8.bam.bai \ + ex9_nofail.bam.bai \ + ex9_fail.bam.bai \ + ex10.bam ex10.bam.bai ex2.sam.gz: ex1.bam ex1.bam.bai samtools view -h ex1.bam | gzip > ex2.sam.gz @@ -24,10 +27,8 @@ ex1.bam:ex1.sam.gz ex1.fa.fai samtools index $< ex1.pileup.gz:ex1.bam ex1.fa samtools pileup -cf ex1.fa ex1.bam | gzip > ex1.pileup.gz -ex1.glf:ex1.bam ex1.fa - samtools pileup -gf ex1.fa ex1.bam > ex1.glf -ex1.glfview.gz:ex1.glf - samtools glfview ex1.glf | gzip > ex1.glfview.gz clean: - rm -fr *.bam *.bai *.glf* *.fai *.pileup* *~ calDepth *.dSYM pysam_*.sam ex2.sam ex2.sam.gz ex1.sam + rm -fr *.bam *.bai *.fai *.pileup* \ + *~ calDepth *.dSYM pysam_*.sam \ + ex2.sam ex2.sam.gz ex1.sam diff --git a/tests/ex10.sam b/tests/ex10.sam new file mode 100644 index 0000000..45f08c5 --- /dev/null +++ b/tests/ex10.sam @@ -0,0 +1,19 @@ +@HD VN:1.0 +@SQ SN:1 LN:249250621 +read1 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:65536 ZL:i:25 +read2 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:214748 ZL:i:25 +read3 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:2147484 ZL:i:25 +read4 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:2147483647 ZL:i:25 +read5 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:-65536 ZL:i:25 +read6 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:-214748 ZL:i:25 +read7 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:-2147484 ZL:i:25 +read8 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:i:-2147483647 ZL:i:25 +read1 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:65536 ZL:i:25 +read2 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:214748 ZL:i:25 +read3 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:2147484 ZL:i:25 +read5 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:-65536 ZL:i:25 +read6 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:-214748 ZL:i:25 +read7 115 1 142618765 255 25M = 142618765 25 CGACCCACTCCGCCATTTTCATCCG IIGIIIHIGIIFIIIIIIIGIGIII NM:i:0 ZP:f:-2147484 ZL:i:25 + + + diff --git a/tests/ex9_fail.bam b/tests/ex9_fail.bam new file mode 100644 index 0000000000000000000000000000000000000000..c30a7a746acd614ab168c316bf883aa929291e3b GIT binary patch literal 10280 zcmZWvcRbX8{BKd2jk9ys7iW)*%w%uQJY-XHM)nFt*4bO6I5IDs>{aN@Y@K;zXPmN$ z@_YOJ`TP0f^Z0x|@AaC`=kxP$EU`DPUAp)?C%vSobmh_uu6WC!v!gY{=XXS@E$s3w zc1Bmv=z%r)`J?bjev2&|2|JNufjeApUiTmwO26_tyr{ zMzvq{;*@1^FzS{PTIkuDR!oHaaxS&Fr@w1gbB?SjxiHja79TaN$DXO};7 zGR7<)f61DQAk4J#gmMP!I~+MH->u3$ITdZF(mC2xv}chdRL1mI&zWx6&+fPFO?K<7 zDXrer&6zu*UGFS964<+*bD~&V?4XsS$~l!iG=AV<$ui#QaR0L-fparxF<}xtpJI<7 zj?cBM2d*$@x{gRXyC=xU)tFQt$a(*<*@N=YJz;uxq*OQ9{nc6`_g9P2UeTWGu!CdH z@rM!rbe&&b1v|X>pgEZ1*y-RHLVL<%Emr7{B9T{OFFD89G|e0vvvz=JB9aO^XK|qq z@whr6fo4XNI=lF~NT<^A8nkn{Pbbjrh13^oa);R+-IvTZPA zW-hjlr*%KeVw*-^EIvbI6OWbo&}M5g19s&|R5Qajl?sA)@Z_l7W^kUo@7O{7^mm<^ zojcq3ldjXknek86#GFAtJRiaL><6{aM>AybuezTB_nMzIE38k(%IS$0cWq#7iO zO7PLw^VJxIc{C@flSkoXKL4n>X74ASCwgOW`v!A|XdQ>Iu&-%M+O?;Cg{@)O=B{+6 zW+ZuN4`2A5w-cTT8{uJl&^Ur?Ibkh#X7g)?Cw*gip;UNsvsFoJ7m@xf+@o0&!b@Mv zq&yrh(mY$**tO-k);H4!WBkO|qPax&fm(G-wRl8_%2Uilb&Ir;g~QizxJkmUTY+(u ztp29z7H?wuPE*r|#TzKUq3gY#VLBIYT=vz8z^YBAx+yC1&Zfrg))d9yhQDUqcUQQM>V|W^ zhonJfj4=s^PubhjsKJf>9!+cQA%U7mu#@yLc%6T@iS(%t=Jng};u{6nCReHKF?;j< zt_@O;`r#LgrQE6;jCz&HO^=lM=}VbfuyJENVk2kLrAq{4Va0VuH4dM6@lVOpD%$29 zT^n^f*9v^%OWdBDo0bL^_*h6JjWl(|&ONhaFlruY5}5IOP_S|@XYdmZjK0|Lpx5!^ z+oiDNrs*9eF#}T>-4~BLeA#J>+Y|h~#0-ixuT5A!KD(u5$U;3Tz2*4$@x)%#lTTr- ziGv$AG=ZU-r);FfHAZTPHz!UQ!7&#Vdmp(me}?iUOGd(zZVnfWTfaj@-RL99DUwl1 zkzv=+E+3jY5PflMG zhR#N!Ef*FvL(oM5|Qoef#JdFxA01s>Qyt7OF(j+>ZtDX2n|&fNhezNg3gLHI~@Z-cMhfvL_WdYCqe!y&Ihu&%K_~f`>@tn%uFZ@ye zq$QW6p-V{K0=4{(tX0=GW4X7zUoKreR_004NG~Dd(5>kmt#rETQ$L3*v4h+G@Aql0 zt8BSdEK^r(lyVUCev6swZuf*R=gz9^o&mGs2eU>REQ`Ig?zxpa$~`!Hptkn&!4&gT z5g)a}`;3j7EgNyOB8IW5+oDKa4!?Am`@QX~#Xf>+qSWYOaIt1ea8p+!7`?rZdDviMr3YZ@}7`P_@+1AnH9&iQir_b zkkKFuAc3ZgGh|&L_p>ZH(em8(ey@6;iw4%?N|R@O)$q9v`xRri*&3BHep-qKW;Ws+ahmVr2;y$W zJA-4xbPtC-s5XPx`<1e{5+w9JococJa@B8fKP?NcYGxP72s%gF442S1+q3A4`cCv@ za)KjgDz4@=;-8skl`P-&L+vy*Y zzs2&sm@W@!a$FB@c8npc{m|D7_D-o!O6O=MN%ZwNERm5;SYFS>F$}h+L+Kn1^~xVG zwQm;gdj2k5Yh&spzZa55c&*mLul7s!5nLjnJD+kYe4D-WY)eA+Fv`(BAiTySfe#nk=E2Rs9x+yi|V)}_xwRkbZWO<(qGP?SxYXY**oRL z8eQFxx+U76qZl>^?!XrQ*|=_VNv5$_@)Oo-!`5$Fvy=g^5ITcxduHw0T2Q*W#q1&7 z16uSKsb=?gk&O-0+$BBR#je+WO!Zi;*!mhmch0wpWVvJ;F>l?xJjR#OZM_qd*=1%5 z5P4e*e#`UUbPs!^(+GO~eYJn^Yi1&K6ERVaiJ!?^tjgSj+1mpc_vjTjPz;hx1SVx> zFP~x>V|N$#Tk31!E{Ty11679EGzCGqRQDTCc%r--$}^te;sY?21Y@T4hO8VudABMZ zxlK9ARS!5cR80c4)g=r4u`SOxxNu+ZNyJu#xpeo6#$nIn?A$H5u#2y$s}1w&s_eTi ztjkl|sRpZ6O|I`tJDy1BFX@6n5AsK%6_WmlxJ_}Z188XXHC!X~YK2#;`imy|2_~^a zT!R&drs3NSn$bC22^5*Jcqp4-#5-oJ)hgsRY!Qu5!~NZ_IqdVsFMdhG={1Nsa5l)L zE}Ed4kufB6PlH^>dD~;;pNd!r=6a!+_M_cs?1RF^kRCzM8MFQtd+Y~Gx8VZw#hTU8 zhGWiHUcE;X2qYIkIq-f|7eIm$s}EJ4yYKynyZ!_pz3P33;Uctsvp)Wh~Z- zB`=?OqbiQdjNv!6_h(B*myDs+FjZWV>%V&*^m4SCr?PCW?_0&M_)J%PH-lm`0*4E` z9U0oW<1JFHc?&Ol4GFBjcIK~4CM)mS^=>Ok*@|Lfq$v(4EGrw4t@Fb7?%o(Lv)H>c z>lPTr9Et&7t-mP}w2Z^JtGA?_F04k}eiC=zwNZgHr}as+`BHh zo{Y?^Ys;;}uX4+7w1V=76$DBP7`1xI;f>wKIA)y0LAQoVP0ScXRleAcQTr(%%fJ1_ zkpi^K&g@3L&`(z5zXk$hbf1m1M2>y@=Nn6&4Hd4e_&L*&IeZ)o?yuGUL~6QpwAH|0 zzdq9YX+Wzs>w^Fk9o6a{Qk+p$#V{Y6T%&6-n=-)iEz;^N`V6=RzUo2dNXQvP z574t%)42{F_Z*C_HuHEV*QnGJhvOI)>{;x*sNGn-w7oj$Zc@$c|Jc3W`NFD4_xLy$ zMN5cR`hMEXQ`ngu^!)A=bM{Uveb3AB*$6HE`~f7rgR`sdG3}y;fX-7=Nmtyf`M8~( zlln&T%vvX}K01x$8U~D7twZR;*IwG+ivO*hph)SS&?X2_-v3^|5-t?7h!!{^@_z`x zKsS?5{K+Ui%-CcHj;#s|k$c^S{@aA$oEyJ$c3QuUtw@Ueyf!x*)cnD>Ia2YiVSIR;j6_ zOFvhC72hgw4;jlysy)%MNQiR=nJ|02DFSV9tW4$jz%aAaEI-f-MYcYhD2VZHh7MJw zwtk%%?16SyOL7FgNx1Y;&r4n>7Tcd$g)4@lTB9~nu?;}rS4^@mf`u)6|E8Wp0 z@#E3}b3<}>2*!VV262C*PU9%cz43acti*s^gK}bybseXW7L(ghH|JDlIujyz$4Pu} z!GStw=4lCZy~WKTkw6S?OXzkCn80!bn>G4O{*@+;*Rbw744&?+{+l!sJ|rVP;SW8v zZSG!AZX<@!g}-_BerRdr3)9e&%*WtSS?NT-P=$yrv!jWf=$Ag9o%^NEcuDgE{61N+ zo@+{G&`o*I_?sq%LJ6kE7Mb71Ny+&f{>hQ~eJg8plNQ;1Dz*{JT zMxf?Que+YxWL_IncfV|WFN;Qjh)Co_uQOqc!k}P86I!7t=RG0dE=4_RPddD3{~#4Fme-GnZDk{>Hl-PiIW`uzFy?#bHd)FuE{CI2uJSp-#P*2(?9Jqbz*jV zuVkG)JoKp6gqum*pS`D*Gr9gRjV$-1*+aJN+xPe-M^P%@HGlGQ+9iLi;TL7UgznXS zd3OhWb@!vwI*0l#x6#-ZUL-;Ha?^bMilx}EnUvB`ro~6&q1*w_`ZLorIRh<3oDNq< zcx(3GE{&YjGIhtkT2u|n5mFje{}XS)exHzA|0XV#pl-E{_#j`fU*b5pD^2*g9>T*R z?CBRuok8yPm7`x*GP~O(MLs^zA%C-L@3_JluuAmVQQNMk$@@&vpLvsib!dvD?dRGG z|8%4Hie-khzM7pYS>T<>xekUulOLbZZ0u}Wizoe{&9V70%l356V` z*?7{AEnQ}ceR%(6?!B=xwTzMl6S)Kr#{L%;*G$iUtIHj}p$IjN=sC;EbYHg-rkd-| zD;fx5IBR!b+__Fo_(9E=?SAYP;LT4zcv$D{fjRgZA6R&-=FKgUzT(c78sXBQlV~(5 zT-{A)qV_nz$;Lkm8nvJBz@6F4HuyBa@xheV?BaSS=L2YOxMYd&(Sm2sv3iKWtI03I zZFKegnxPgEZ}~ZN9&*(O1Xeq>(y!Pv%D&y%`MR8*^wBmh@h?l~O%@sQsN3=q9SH$E z;Z;5lmX_qDmzE~X)T~~$inKOhaI%O*`uVK5#BZziR(-6YUC;Y6Z}_R21&{{&H$W?~ zi&)g-*4(|GVfnsn5Bmoz1y?(svj~2^EFQPFlj>*RwTbmTkZEY?pqBP{masXUdbLw% zL6r6QW87DD@uhvQ0vNBZrd2VwUAg`IDam`#U+>wxC(_pQTA zkBWrGlJBm^`mubx*&ccl#!en~zDvUJx8rPuyv8o#q@S+AxKlLzFv*zYd_7kGw>SM6 zpc|Cc@AHX9%n9wlOEmC;OCJQN= zKT!#uJdQa!=!dPBrDU>m#PlhJJM zlU^k-fn9p_^svX2jvrut%J39!G_3y<+-P|KR<^6+qMVvzUncnQ6`GAM3?{Vu0z%Tr zheAIl6<_@?5ocuf?`oGkT_a^tnI}z=^Dd0OV|HZ~#+brpZ?>G;tN>YdD8VY9*uu*H zn~E*1o+XPF+Wk-4_*rZQmzr&vAdQNW6(z$ayLF_I_^|m$cnFnBOq$}rZdWVoV!C1Z z1A?#6N}|5^p&(uDw51W+Ud(V`u6?1+TRe%M{pyJoEon4=+dUQ zv89oZZGA}&TgR`LLcT;bBy*AI?a_DjLn7Y1762euf0idmf2aC7593NL9Xih1n6W z=d0qTqwLCHnRaFWJq#-qb)HYU@evH1z?^r3Kql|Q7$p9eIxxhW|$ojwjPG#{A_}|A5G`wdKWMIUhA_Ig@(wZI=A75rbm~iLmWB#&=8DkHTFtVCu2y#B6 zG-Z~uOAAYDT4P5vgO&Ni$WgVG5k*vsS&y)Xqe?2k`9yulEm5$mZID9R@^LF`pJyw9 zmG_1Y80td2NPQ@OPr1oc_-D zO}`II1~%}4aGi?4tgwes!p2`a^^7pC!iT8Z&j}2%k4fw+5vNa_GVO@*RmZvoWeD=( zmnDcGEwCi$4x|zh^c2+VZCKxEUMZ@U#?V-bPDRIx;-e|1m8po)Qz}}t{$kt1SFk=c z5#y9#ePB6X{sHi+JC25U7Z}YB@o5xCMYdc~tsO3v<;92GQ-QlhGo-$_WDa&mY8x-R z3md1uL`QZpBDy2cTbwsf71H4M!4{T?7wN@zW|RXe z8rVaDEDzRJEmSRc0j%et5({uBn%z>WSs`ubzg!5?IttAjn!u3rHah<2ZUCrt@?lq; zc@-}gXg4KLoJ+#Sif$>OpGF~X zP`paQuVo}0V4&+0h6O?9?7IH@6$LVv*j|k~V?dS3-i>wl)YJYx@*5bH7*555U!>r{ z|C7DIiPMYjm#4h{B!K4P@rAbW$|cbG+z9(jI<$HKm6#&-@QHqg9dRHJ^hdXC+3R;W z0A}}4WauCedzK>SLTM01zzu55)6p0N`TaB+BwrC~_lF#-rsrqSb|ucA?1+0J_UWm@ z#;LLJ@fAjwuL?JMP_>x_upgy7eE5)uX`n|I7FhdsJpuS!%`jdO1gMsoh3!wwbIMB; z=fhjw3@<>CSFB(VGa~ki^(vscC=6+8c%R^==ey#(rF%i^Mx)vMq84e8pR380AN_+G zs+_<}K-+NWx7ZPx;YP!MfnnAZ%ph%7Fp9Y8Ae(q4x9g5Pcq`IU2$I^S40f7$37$gt zhy#LTNo0s^xo&7&le(sTc#1&;QG@FIdy$S%rA-=ueHUQx>|56GgDgLno~&egPZJEy zMeC1bmGx^?b+Nfe8lh@`5c)vHUxpwTT5>_vB|16=P!;idO40}6rYmh!t9cx7)8!)H z6;72+Fu^xLCF2f29C$7w&Mj=8(F)_;)x==??urNE{ktg&8ea$%_JS7N z$lp@AnR{-AJ@f%JJAK`@jMrKXo|>3f(m!NlrZo5p*zhtD4ByX-Bt7W^S@6jc>EAhh zWVCFEuuuPti=zx41;f_DOG$jxuF7ys@XP`$+3xpF1;`2$K+WgWG$2k}B=F?-U*n9o zU&cFm@}Q*O*`n+O=x?Fyh~#ick{tv%qX1&oUTq9Pz7J!Fy%z&IDiX~V_3J7;lQ3Dq zRv!tlf=&rE^xgbYP^eC2c0>UzhJU`ph(s<{1$!t|)y4G`Sbc7zI+~?|r5)@6FU3dkThrr0}C^8`?k< zgtIRmf&Fg}tAT9Tck#Y|d9f(g(I-GULws2;j~_Sv6b)m222B2<9BcQ{rb}BP9}z_I z1XBobG4YELbFT>;L(*prqWQxBf@Hh)0fyfO%D@dMgCj+F@_7eiIS4No%U4F3Kfhz` z1Q4s`b^^mCWr(0t0xN2_5};brOHZ)9Z`2NE30+1b+SmGr7RbFh@rz zIzyUkx!_q613!=}+Sv8g7I)%<;jLPzl^?OY_~E9lBLQH*cX;scP-u3bx6{ur3=5%+ z{nc|BY^EFvpc)A<`x!t$fyv`CJ6A<`23>wh&k7L6tU&a+>W{A^g8q5>65y~5nAtYW zhMRt<0#|&fZH$SyYGsU(gR0PUegL~wfWmxgTgGO}l3m7w4=X4HmpAzUh$o)iFw0I~Ok%!ATY82Lh+10?to{SsPQgdm3= z6d{77pM3K?vARV=vE+=Z4P%$Hur*_TRLp~?y#)wn8}`}+c;a=TV|3tYEB+U#muSCZ z42{Q0HVUDnNr!7XnoY2W(m(6$h@BS<_r5z$W3VgEY%Z!4)p8+fv`VudlU}skr6R`a z>wxbgqT|8gg+(A{moGR2l94|091lT0j43VK4`y|yUjh$9iX&f!BZ@AxCP^bD;78g; z8{lTMjS&rUK_5&whsIXEW(FEHoI$3;-4GKIZUjP0hPsk%0Or-_VICcxO7s*B1CiTq zL__%$xZ&iY+>KNKH?N|eY?0%x`2uxtj}#p(kE%eNMgx*_iu?sce0w!7RP>MHNTDV6 zPz*x(xGlKbIu^~Er~+5sd~S-7qg7$J{Fx6w2jpKI8PHyIL{fP7riLY!_BR%g918vN z6)#v?dqG(~K+LRQg@K*Vy*HD$B|xL>t_sHNYRT#b_WfN7K1qhA}rl}5XvLi|X zzL>LQEpuYpK-DsD4>>57&yVnflq-Fce7+iJsESaGX1=kj;*0clY&$*j@ z1{lK05gQuzD;#_b1OA5z8EOvzSqNQ}BNhlRifLu+VSOIBn*d6b`W4VK3y3iqq|ldY z#;#Ma*8Szb4ey~UK781(dhmHctpX3ZJT2anfxi$wMk?}Ar9IX&G{}ckfbzj-)YaA> z_W4X&O4vgqh)Td;w_BV6`|`IOPl%SRyt~v<;U#@T+n3>~+`mZRncTMVR|PDTu)Yt0 zv^)*Y;zhUn!|?Lt_n%O-GNNj!Rc;ff!N-gn#K(J(3TN(;X(#aGP#;5Ly$W;zm3I2` zVoIPK^_AI|`R{^z=O9n;(fcZcH{IfMP8BWacXgDaoE2Rv82Oh!O z6-q{ax`+er3quPIb*WNFkr?=(w!lKVd|00nJZ-rge10M?2r<*P4CSs04pQs9qK}Cn zM*+hxSJ^_4?qoPVyyEc?J)~F|Xy&g*30D7}F$|_|hAc(?h zYbwBpLeQDmB1yX4lpEFcB^A5ZK|g8ZJ4YLSYcJOnw|wv0q{0Vc3kTQHqmfIA?So^s z&&LS?V%oYFqF7HEer0(kfKA)2icXnC5V9ppMp`f6`|fILy^R^|)IsQHmhiLd*h`mK z{?Cuk5-wXNXt_Z|Zbb&AU=-Ml9xiTZCt4Hm{>hZ1mymvbUtARWZj|D$)Qjy8Wufd(0F!!Q1yThrL*(3pYDC1SChNOaj@O@;!3}6q5jsOP#9DQbw&M8 zfElDvQnqb_>3!do)49?G*;t?cyJ%?EUHk7y#j=H_l0Xlm;5$`y*pSrm*EBKKJIXu!W7 z>RvCz$$j#fsnZ$TH!x7-SZ7+SoO)mP-27Dg&jg|Jqb5(|CU425Y|Srp7vk z#_2yGWfd0PHl34)C`~73w;7}Z1;c2!RCTQ;nII?S;~Dqa9e=D@!dT@>r+3|~&RYN4 pGq3ZVnIjhWIk|gtP$<6e_^RZR)F+NB|34i}m#+TrPXjM5{{x6`SaJXW literal 0 HcmV?d00001 diff --git a/tests/ex9_nofail.bam b/tests/ex9_nofail.bam new file mode 100644 index 0000000000000000000000000000000000000000..1f90cda422127a80b756aa44a479e0128a132e0a GIT binary patch literal 10270 zcmZX4cRZWl`+k>dt4iD06;)NSNA10W+Nl+rpeUvGrlm?_#46rq#U`pj>`~R2rS{&V zRzpRt>i8a?KYu@eJTGz1bMABQ`?{~|I zLz4QAU&X2BQ*(;vo(3<_psHORD64OxbXhpHMXn}Jh(vytPLQJ76spZ)dW&R#%1-wv z-G5DJ^iKKqQOo<&fP?0Rg|FLVf2VdElzfL|}8a{T7)zMf2}D;#^QTWt$C=HUN*8M!fgVC6XHGj$^P zU16=}q8#79e>5KJD$(piX*K(WpOx9j15wNkxT+q+vC7=Z;Jt||#jZEpM`80M0 zUGMJL;(K{RCcRr;DY1!L3clI8l9_{1{d4xr+UzJ=m-A%J%!&H&Bkf85a=dFJH1&(M zc*t&c8D`uMTEU3JaSo>GteY=YC7I~$L#soWEGCOiee&>_%$MH_)X7hB?RVS?ta?wgWn1;%Le);vft-iB>yUeo zFwXa>`@DAxIlixUgM}cW&ZcI@JM{}H9r7Un^OmZb`s*pX`MTY*VCI0IRawBuiMUf$ zmCo;Br{>W<V_5thOGR zYZsIGYClwkn0t@GEuH1}MEUxCgRyi&xc%%W_%Si!-1TqwCfpk3U7hg<^7?E|o4?dZ zTSX-QtA5+TDGIs_eeTnh=~DC7mZ@mx)&$DDb&--{Pv=HB`GaJ)qpOLKr-X(F z<+?9ZCSB|dof%Jiy`@G$WXE#0^>edud=s-i(D;Lu+u0u=`Jl9vCSB zi=C#vx6z(%xie~E=iA`5_RIkiH$`Vv=n*+g$>EznvhjdYikX+gH(~;Fvq{9sk_B&f zm)bdU<`ReR+pb=J%ei3->zypSk^QWzJ>fT-XU3F9 z_Pq!Ewst-<{^3K7YK9V$73GF4Lyi0_-Af!?y(lLZb^yF_g}%hav*+w@*~6 zP21ucB>l~_-%{Sj= ze!sAp$@rU5J((_hW)P-UXE|uYRBqSzDAsGpi+;rS^S}HdX$o8BMad~y6FbQ+t+D92 zR8vt@m*Zcj&+mUc=TzvW9sTTFmH)^inUx8dFD$c0Wnnzks*`UZlf$3y8!<3GRAR|~ z1?^U~a(=)iMB+)YblQ`?63dker_uK}o!}BvYy5=zgYcq>dRCTKE33YuW>Z(?NPKmZ z6vhY#q7_rztk|-zho_7&MJMU>EaDkXLSxO`cYhvG_rUR&-?}yHF>Wr{5h^YuU8OF}x zX<$rEF7|yoZcQr=)|OL4N`g{NTFu+Ba}MLBoja4Ltm)B1!_*O(&Wdl%In!ga3LR{- zto?+bpVUXK4c76-A^ZQW({!9%3)$@JMR^2vDXu`LKJj=4+B<)1YT|tJsc2_BP@wOP z+)&>r>$)?+yUxP%#>An0qxQfL`p%S|AJKG0OHtC;AI_3(g{4`CGEb`zvPC)0qa?0) zdx(2Xyf|9I|8-QRhAW`P|txzPfdARBHROSQWf0{4RXHcaVgAr#I&4#rmeayXGQPUX;+aMw@Hi)rkyIa`o_8Qx>*tTz;WROXH&$9 zp)&XAcPtL1LM&#@N$7Q0SdeZT+8>RGU-;o_Ur82f;>H|@`5HiP=U5o))-_0O?ez*Z zc4;JLlMsCRhd*S{)wviXGO>LbmsDj5FJxJF2=CD69m>>f{p_W#a;_v-=QZ zGvjusvGEO!Bj_@TT8S$K`%1OyDzi@}x%<&WExJ+v&Hhg5keW5ps$TAt9e=-57Uym8 zrJs&XVzMabActkY9)@Y-V1fJEL1~`*<Zev+1G?Wdxd;I$X=jd_YlS?-c&CB z;f9wNRBr`YTm8Y+LePsdd27$VK@8)UjcBQlyvsDfBFoo#z+4%KX|oGow!oa9Xt263 zZyCEy&3uZosJvOot$T3Ic^74f5!3Prf~xbp-7G7dXOP(7S9R%K4h=L5a*%fMu<2dq zvS6;dHJkIugO@l*_#7TnEhql;?V@UKbvl3AfE1BBP_+(?Z&Au1)XQN=IEQ)s@)e*_NC#$DO(dRPWQL70+|{7rpT1}0e9$)&5%<( zon*UM% z8V~N^ITzG~(G$ptCMnDj2GRV5`Kfk7al2<4KmX#^H(6=3QHLDY55Jz?5p?J7t2i#W zvi)-^DVHGKMI{>Nv&Z^1a_aL)e5KpK%8R}&Kc_cZh7#*TRpo92`Gm*Wixk7qv5;EV zlS*h}-CD%yjuY}zvsMqGoFUD zkXmw1!z)#>i^-i8J%V(@FB;ZUy_LmMCp03B>;j~%4IdqLP{*N1WFH%iIYDQnw(SEh zJsqnEc;hHiId`{GZJ$|+VoNEbYfL-nK?p#0+eQ7Dp!X*cd2-oCTlWKT$*~)IM!8Q_ z^<*Bk@Qp;N_hD=3`pv&pX#N#B)k`)t;bS4ZCh1$0n^!x-=0aGycTM89e5_Ijex~Od z9xae><^DAn`8Tn(S1;NfdV-31{G*Q{Vp7*9*=i|r^FhnUz~CymE$w|t{(&X@q{W+= zs*{M!pWR~m<_o&!F8jBk2lG0C7AXk1Z2GeK2Iw|V-Dcvm8s-U>=C-WuXQdq`@<*RJ ze$qqf{T4;e+Qr}PV1~gvp)9mCbu-4gtdQ}ybn~voXpQ4AnJhz~qNp0*Y+W-eGL0zT z3-Yx{o%y-3I`ys4?8`7c%}~d@M4N#Yax!+8s9{#j@7D8;rut~|?Y9Rl+Oq`yhfa~1 zu4(VD#AG(PpLEo043#-S3mJL}CSvzEuUR^&9g9e1nIjv##y)+Q5A%q5u-EuayhU-9 zppyyZ{`@2sQyC-f7`z(jygvtN)R@N3_&RmQ{=n1V8z?0bq>7}LVlG8J3w(YOVJk0a z&lUVz7ap_InYZ<44l-=pFIWHO`;Go%tLyfPPj^0XrVf4+yDmZy=L)9UD@ZMR7?D}K z{L#Jh`1tqCY-FEVjnrC9fyVUp@qDwYHnvYv555`v+Yg3EP(7sTN`3v`)(p9wLBV4v z_0%_YSk@SG&>bur`MMrQoAV^Na;TJWvcfHUw9~3{=@>-(wn@%p^uFM}(=zwC$x?;g z=9z;I$td@j-#U2B{p6NONl>OYhHKJ&I?1$vX-?}>RR83B?VZrNtXi}}uJUZ5)RcMm zzQ6cYBkbk{V za<52j*ZAJI8?)VZ3dXWW&u~mWGX+6k>SiOfpqbyG7TB(S!I`AALh8Epm89=|z0|l? z{~G4?=T%Ytq=$wWZ!3wauAM`9>#mim=IzPER@|)g_fXb|&H_QZQ+bl@RA~1``+9bU zi!A2Phq;xX8VkN{G3{S!zOL^%Eyk_yWsl1{L$kY@6y7O+!JTgVtA1>>Cam2FrHdGB zZZZ{22rFdii*aov>F#f(KAo*qIXAS@+Y~J)-JjQvf!4m5Dd>9S<@8ZjA5%Qcn#)nABPameXh#S{#sGj?p-6Ly?0mkv2`(wO8y8@E&IvM4u&FKz^s z$z%k!x%RQ#YeK~Q+PH+7==GkvCF|`smlRp@b%xQqekZ_{t32fOMxrh$bS5=E+W zb7uUBB9u^H&lTmBZW*yyqZb1$zZj+&Iq-W<5^DWzt8-6;iL%M7InpS`qj{3s1}oEL z=M|VMAp$F?I}I_fGWV6(gj>BOxD}t9+npf`WE?%~8J#L03EFB)ZmwDD>+QSMQo$%1 zwC_Y`7C5lC@q0RMg{bI}-_oDP?tK4GCx7C9I|DP?ojq>%1wC<(a}j}~B8~ysJLBGM zDK{A#n%XG)BBhoS9g11{?RX#Ms>xLi`m6*5n-GAisQwMI4v;GUs>S53|NU>#HG^zn zck9Q0?1*nive!A6aUqwt5HS-M4jRo5?tSg^Ua6vI3*|o_<;lk@*c(fHmVq2aK3Lvo zXbaL5l8W8jdl5&>W%{Ta?>xq#HTt|9+9et1(8?cP9_C*FJ=K2QR<3Lx`lYYVTZoZz z*Fk^eTg&yoixPXs5m9bGqUic1emBTU(_eQCGH;X|4_sE0d;FWD@pfh}xh|ncS$wug zoyVDRYK5wtz`(ktnZv|dq0e9HtMV0^g*;)ocNz~(e(ajjlbES6(4kj)T;)(K7DS= zMW7oQ0Ez8rzdpfH{>|yH>wQ99R-~-fRNf2@&!Z zZWBfOZ;<`Z8@tYHb_gz!bykG4>kTK>^Qakj#&b!%6m_~TPz+<#mxRH9LTd@9^o1w0F)kC}(3*VO;9VPR>zmk~)WY?rZo7*#}~ zd45UnLVigP6o>C4ra$dwx_d2V_6A((Fb~$Nqo1-$r*GFy4usG(+(wtpQmNe&or)y- zHJmSECQHJ21%~h1T_*=<)2)@K^Yp~MJ5FDF599F^e}W_5hlo9bZISIJquDDLyh>pF zH^lOWA*yiqs2*~OU7}}G2 zG(B1Nf`P-yz1R=|PbzJrHBIfY)jXkB4Sh%XP8zRc9TN3+E+7(;^Ez*>alOMO*$Wo+ zdOqZ9?Y0v(D&#lIxD#30Xb7PW;IzlZ1XDjAQ*t?sHqou{q$qky z))RU~=)+HrvRl8Xn!dN*;ZIQHZQPu+E4%-XTCA2&uRRw2mlpoE=8+4TCcUgr3gn3{ zp-j;80y;dH7LI7WyfT(73pH?P;EFX7^kgn7v*4&}^=n{3zm`3(YL_=Be1SXtrn7L| zee2ilOs3Fi>^(-)iO%lh$+S*lrcIyc)^Vpe&Y2deKj>5aUh3A z%R13Smsz|fN(4wg`A$}aP>-$#l9P+`VRv6}Mxa=>pW1Be8+6>`@)XmB$kV{?66C2m zOq0wEaR^{Rqq8tr9tkys$_-kG3)^cfd$F{ga#ay&3Z1bkR+qrE%2`V6-L|MwtSnXUV_XY!Y9)#kBy7Z9_zoG9sfRx_ z1$a{C3+-01xkBgCMkU5GK7R|2kbi-_Ul#=qB7c!N4|%EyG147d9d5b1Mb1R7Brqtd z5vO;tus-b1g%W z1V3uP#{be4JjVTTgjwMayM&ECcjy`7o(UbI32hMo99Qisk*80b(om#>568OsWk{;x z7bVCb1C2st&@D(MGDt@I?P@!$clcc?nm}h@Bt;3=31u(?1M1pht0J@xZY?MhX7?f@ zCF~P0?@DoKf?(u0?|AEthsHH}s>Eq3#OT^L7&G}6TidJlWWuDCFjI3AKfjCCblf)=A z#AQi?iOxmg8k3A^J_sfNAjXbH|K{~J#~=6(Zi@gp*i}NLIGz>IJ=(#crVpGaU&sz_Vhl1M zQncmiw~>G%soPxfbM4koMUkGpvjmkR#yw&|zJjKLOcQ4r!r~C9FKSopNT-+%fxW}!YOGZ~UGs5AamjK*?0I6wx znOrN@7ai=%pmV8w(T>1TOn4gONa@0PGxvDMt67q&{JeY~3mpN#UJSclJAf z;^zL?I_ z`E}KrreLG zW_ox_WdKdMKmuuDHt-3MAD3M12f(0jHaEr7i@iYcXVrmyg0GQGbK*xJHW$Qpqr}M-=g>z?Tm4Mu9xH~wUTkj(`R4O z*N*?(F#GgI#eX)j@;6kcJYPc~U#2H*8O z!1(}f#X?3ZKtyqW=+Uo#Q$#~tDB$Pyq`|g*fXpO+Xoa{~zbHj##S={$SkLmOldk!d z0Au#FrUgwB2e={*8$DVK8~;>V3LBTdDqVmKqC3-|M?gF%^GfOaZ@2vjwuc591+U;mf%b=$v||a8+pca-eB(+ z+nAaTv>Q?=6$2k~)5S0ZIM`+?1M2B(XaWQ2A|m0+j3xe10uY9oVKACdj4kQr0A_c4 zPylc;YL8V)(Fhm0fdR)B1G0D%I35ZXYa^Tvtd}ec?DloI(M|+WqJaY4`1|UUJ7jwR znot^a_$(_Z`6)ew^Jj-4(M)m?q+eztlM+ zG2^#_wj3E2v8B>(t3^mE;YJ-iy*3IA{Yn7(7?RGD_g@XLgf|}2H;BgqBSTEb+ji?3 z;98hc#Re@WATE?Cz@WIFiK*KMZHSA)O9uy2A-hDovz~6!S3Nu}LIzzzUv@hx0-h2= z@l!(#WV=LyI6We4m)dt2USh*&Vt}JND|O%26=@xO?F$V&y`MUJ%~LcXH-Z`P`ztJ8 zSH~ppc<3DfhUa{(J#&ar;TJ`8^8_?u;q{p}q&@S70l-v;rVIB`3L7P^D{j-da2q9S zor&eqCqtD(MPP_%@k5|>MnNVN!mA)Im`_zA%mW~UT*5|gTWM6O?PkFTQy4R2;~;?7 z8|>Y>7r<{T-_bU}g-C$Y^WW(O6QVvGYfgfA7t`?^zr{h7z>%iA@?r0|3%SSt(xixW zhb~;6f`FN0>1Eg@+!-CjZTM4{0KGdMj19?4|M(sm^shq^GNe94=fc*^pvu($1EA>; zX-rg6vxa5V@Q&xa#=h*U+dXyxm!+F9v=i$N@Df-U$D-f=ygnMy4qo^)cX!KQu9SED zg1j$rT1y`yq+bXe-(?_Ke-7no9Re?8&UjE zfSXZ3-%5%C8xjY4;m#1vGyS>|^-LX+CSzj|C41>Hur5^a^X%_{WJX|Ld0;Kigb6Hm z0bvQ^TP)$CH__~Qt{_ctUO)=O!70{WBX;gjo}TfjsEW`b>Fq{X7h{eX9PX?R7awr{t+RKSe8GPIfaF=LAX2QOe5tDneTdU`;QsK{mWMn6 z1~4i>@-a$7ih{?;jm}|xoE#k-VO7VX`UnajV`|k(r3(Lh_?*`0WKHhwQ*!;;)dY$2 zc<0~(8{dgqrgI6qVgMIqq#;fhqdH^rOjPiP=V4e&8K9OC*!Y2|JY)<|eu`Nruy}oU z0H7mEZ|&3o*K`NHarjXmh_g7hXHI`KF^n20mCZ1?NL>Wpc}Z- zIfT;b1lS#gi>v2-v~*Gw-s?RD;z8~bSV9DSZ(23#ta*9z8-ift^OR@S`2lkEKhbac zxE8TgvDL9Nebs_ptD-zy8TezyxS{M`f1POd;VdeLkP)2a3(Q-Z2~7wR9!tO|0YABv z@m(KBVbBX6ZJ$8giv~lamtZ#%XVz23mV=pG2|l5~t@5%6&v+{%Tq)<=nKkhP!oi=A z0mdG}co?sUF=to2Mv?Zx<-{4Vd$D4fZlWc~kun4xa1Namd>d{W%JK_TQCZt)uRj{R z_8fT*O?a;40ggc>9*ZKyopJD$e@qd}5U|i2a75E5;I4JIsEiQ`vK$6|=xdJwD-LRT z%IL+m$H>WGV%p&q*^b1ImUa6%jQ%3N&|4Q-z6{(((V|-S{nNAJm{`Eq-|L@Nxe%fs z?LO=)Gv4v>o4=eqk_T>^w-G7lPJE#klDEH8AYM{Y$he2KKa0sWXf=GDu*T)UN{~dggvz8Y`~!>k{m12?~Qj z1<@BYeg&99^849sy04^D=4z5^Iu}#+=`Y3xYUpp4xF+M~R!+2RE#E zIbS^vsnk)MwrD|2kJELTqD);>2o)&4axS6QLS-LTD5axUZYV$$7) z6-yH%9Rs7ci;%MS=3O=&lZR+cCswx^7yIi>!(CEU1kGy#oYWRG?z4OTc+>ci%C!#f v+F70TzIA7>e|s}WZ0_@Ncjlqc@q*)v5-U>G92froa**}C( zEy>BR^Y!!Xa&`Co@O`~$a9uQDTu`D+gW|pG|9xM~Prg4ttrri=o4cp`hvk>e-LjwQ#$w{ndWwrv%ww@NMz;;@h15 zI{$k6_wDlb#{N_0Cl}Y(?>~PmKezd#g=yMkw)pSU5}+kQ+x1&?@@}zOE$(l=uNFV#7-1jG1;%#)X_*zPtFP{3&;!*N3-7PdTN4{vhZJy%WSpwmSmoiO`u8 zGr|Qx9~pW*TCJcf2GK)&vO323=s_0 zA>O2x&>)LVF{zYd0ja?OM|UyfXSo>oW`Gm>C}RKwg6$aPzy1EHVn&z-W>L(nH(`W` znfcV#o1A(Exg<2mj4F;;CbPfJKE3CcgVQRzHJoTPC$9XQgeDoB2<0MoN^fjV@p{_l zRCo;lbwE&4A9=Nj$^sYGqzFeqScl;?RejYLYbsEzA1J56iv<-O(e8_CwSM}(iAo7a z_CX-RN{FxuW{`R&q@IijIb&3?4BMp?W^%M4IY`pEwP7r2c*Z20R0k5y{bj%ccyA*J z#Jh;M*;3B+F7s-)rN`=@8(F;x*>-U<0Zu+n$_!qn5e80PPK7^iaDqI-pP&M$!-1OW z$ZJG(N~l~;5My-47}gnZVS)=Ts{k5;3-8!%f`YN@^O_|mg%LP|7(oH3E@vVTl8I`Zn##Sokzx`>J{ zgv4?tG**ymc8uKyC>Xn5uPF)6<#Zg*06@h#g8?{!Gl<%pAdwa`i5aXJ_{Xkwnk6U0 z0-R>p#x+5K)9eC8VdRCK!4RCl8Ke}tNKEz4C-k#*Q&nceCtyZ)$^=fn{6I3y>_gAch{D1)t_cd9!MLC%I`ZnyU7{w)18&Vu*F%Cj% z;$cF0%g-RFrat@zL^bvCHzcZw4#37OTZ52-sYDXoLkua66_nV; zc?Uq1Dk?Z&`yiyI8gaA_KM>VnP)$`;jW||Q4Tlwv7{@kY+bVUeH7d`1Z-vb$Q#=G) zQp)$wFR%FQ-W7rT?1LbZBK<~q1lrbV3iRDCXgJkQ@H!4WLxH<^3)Teb&>f|~x<6~% z-Hx*CrD&(YtD>Alxb50vOp$qVnxjvliPEo)T*Jc;rcd|ogPJYauE}$^}30-ng|Me zn2Eq?@Y)bGhTJh~!M&GWW*c}2K)eA+McIVk5au0deEo|ExvTZ`!56C=w}Y74C*94V-xdOkCHXzXn_KoWNT-!SWAg(_Of*~7|6zwwMBgvCaalC3`p}`5XVTFC(SYd0yB|2 z!yaau8#3+4#z&>mWNE;_R(v%LtV#plG`^)Vzzo%d+q$0{j6td~XfTCnU;v-RmGxO% z2R2Xw(nOh-Ou?oOXj7YH!2k@C4(zH!tqG7|2!=viOi6Kp5U4d9X?^1qBN`L?tkwnE zWlB*|sN!Wxux9&nscB5Nlbo%~BUxB?T|4DmZ8yF;K-xui96*W*wh9Q7g&|7@;xu^i zK)f(&NnR$BNok}oB1~vn@Fm;5{zy(%$Crb{f1;-tpFh z1#B)T^H9pH&sSR0%ZjJ)#-f0I5bQQ(u5jz}2rR%os>-(sm*uVPv$8EfeKhJtP*>pw zQ+}ABPHN26OktC81QtjXLOPVL2*D`Y!X7h@>1y4NKM-BdG&- zg8=OQu#334!b~U&9oFi{>@;{)n3E8@;{)l#>Yi?PwN1P-&M+%kzm5<_IW{ zO&QyyP7xg3GX)_*?~tIROpvD8l%s+$NSR;i1_873s zqj(TfSeO?~NET;I*uXo755k!a&p8lsY-k%*2P=w!c5m91stFg=z6cT8@Cptw&mj)Q z8T5P@J%cyw@P-)KZ3)?PYrwgav!F1CIlg_y#gaC}8)Mt&9cRc^MztHtZow%y=jfT! zUeihcIOl}vq*%`Gp^WuxrJ~(?2?S_&(JobOkL{9{vs8go;;1bK4RJQ#l5+Q%daFG{ zQ={%-bS~bmde3gW7^mBHi$ejjbAs+yA5@fF_0Er$@qLo#k zhBjE=@vSd6d5C?nB}1Xzy(+l7*RCe!ZiczKG^(TQ5>xMXnB0>4-LFWfx+hFVodGWq zZK=8sl-zFN%knIEfIl|;%KcT?HB;e37CqRV1|wtdUnl2u9*?`_h87|*6Xi>2DZ5Lm zl$RGJyb5Lsmyon^s};cRyeiH~jQw*InFK+p zT}s_p1RH7s=dn3cOzp%nB}xX4Gh|qa;9S09iVwWA38T?Lqa@NY>LL?Ex^)ZLmbB(F z;N$$Hodz$6ba$Og@f+ePd#!ISLr`nCS}VIigv9xFK_lJA{{GWyO(@GsAnoqfX(+qm zErbT%Bk``3Er^}VqJqjmWC5gyBMsJibZad*;$S_-(R6c)j7h`eXtAN5G7h5!Ho03VA81ONa4009360763o06GKh+FftjFcb#h>-1Md+2z#AKK@p( z5bIWHEtOi@U7{#NEm9j0$*S$&&khM6fj~kMG$f;z2rxE0J$++aN&e14*PG3!K^Vv3 zc$CcjC=TY6S>j#0s|TYv@sr=N>-`)&{2FY&6!{;zi{2dvL6Ew_a0v+OChy^A`0m2B z`{sZ8kw1D3Bi-&{IJ|wn|A7`aV8Fa(i&dw2yJ6N&V6MFDi{NdJo!j0^Z_sm0cMfJq zkEsusNa4)5s8GA*}Q%q$zM|4xCY~e7ReiD8l7FY0eoF^`!?7 zFE@83(xMr3-gP;&sN+l}s^pA_*qy%%XHEo&W1I^O&dRx#ae4YS6ttCks8X{;V1k-Q3Ek|zGE>-GEJp7fJJ zFpkX^G7t3{nXYXJZIhclHNc0-3FsRtkf)`+G~ZL$*1R?IwM9%O&xtHwFk1Q6bin(BJS8|=2>rXpR^3$b8C$`*ATkc#UVW)uY zP5~GD%u+C}^g$_v%deCJf%slqB7|z`O1VA~O80iv*@be;0V?k^8)qRZInyoYbQ>sl zR>0G%HEKH-8l07LE#tCfU}HgBsfQ|ckq9~nIJM3#JAZM5>BmPHC9a>i$y?}#(fHyY n%;kR26)*q*ABzYC000000RIL6LPG)o8vp|U0000000000i;_dq literal 3778 zcmV;z4n6T7iwFb&00000{{{d;LjnMM3+f&>0tNYFDc2fB#RU&N}fbM1uCNn!_<#oo)7Yny#4wJi??T=-hTY$ z!{YPR^je?EG8yjiVpAMd|EZ5mt^ z4Y-huYTKar*{A<~UmhKQe|&ga-mk82AMWl~UpC)cKixe2SRWn#=j{B?v&|P*H{a|J zTwVa2Fn$5-4K#n3r^8x{cDJ=}?RI`biTeeAE&pErb;N!?`g-&C&Fbdb{a22T&#$iD zfBsm$Z~Mnc+w@I2hUoW#zR)`*oMyWtgq{eUE4iRTBJ_!&*Q3=6y5<-? z#7C-f_*`KGM-iwRTX_ehtPAr;}(0)$R&kH#MhtJ?(NTyas~WBdEELyxK%% zfeQ>R!VwhKet6AQU-iYB3KSm(s@34df{Ko4cSW^+dicJHN~s|3K{3Kgh_DJ~n0h9p zo}5ax;7sxi+od&dHQA6HCFy*&VLWMg#w47~1QO2OWxxXXU?Ygc`-pehQX$MX^Xj&x zhw7gjS-lO}wsA5=PCicB4qk2uASW-U!XGy{VIJX6P!ZJrK+SdJHKIB#buK52F?wSR z=M03j!G%y&0FA+gckDJn;n?+g&61M_g3cgDPzb8e8H~XRok5&4P&T=LMva+)f9y6u zp)>HMnvyHBkdkT?RM2TQIiWA`4m^cXv)fEmvKPM@&IUPi(-vEU5Uoa`C zxm&35K+V)dHKL0VIAL@V64Jm=M7<(Z#^Dv>j&1V!;b02;qqMG~o8xz$`2Vmnitx-r}@|bj9 zyNfnB#vDIzjU{$*-T_giiV6?X-V3R@MjYM44@I>fRC85TBaSu9;Gx75 z#<5MDP9*rys?BR7*YNP8 z>9c*uLCqFySPxVwvi7oWL|xYGP-CA=N+(_At}jkZDUcJ}QkS%K`?r;%iu7RT}xG@hy!3a8eU) z=YDQ92C2rN!4#u`5qy@=&Swb|*g%O$6J=U5MVmUJO>L4z129fHu&oYtCP1Mf7z=GN zB_$*wsMc(x^^H@U8ldi3tqXL^l#!xP#mkg};k$FGX-uCdIXjm}vaoKuZk2O&-R#-| z(k-&X08&h_RY15Z3|TUeR)ZH0#0#UAUFw(EY2_aJAmnGf2;lz zf;=Eb!~}Va7LjdF@o(YPGf}r1On^EUZxUMHY%U6NAA&3{8`ti#F8dVBOB$52ZZ$xf zQ3*PC8Q0SIU34lk#|jp`wh2God^tM))kaYEi?_FTYxic{KN%6l28Qq_z#~6_&Y7Qz zw=oKk_q4oAdz;6*)!>Elj<+5>U~^HK`%-3ozS5aqUOc5Y7Deo%V0S5Vh1--zU?J{F zRsNiCIo`%SE8Bw9C!<~jbro(j<@*WhlmVd^8f?Z9SRm1am{7VRC1+%ZcUEDv@t_~A zFxn)PpIgc@l5!w5ELj5(Wde7DAnf6=i@3SMOc@Uy*6PRHYVfKsCn4^#2F2}m#z3fo z-xwa;CSin7GM(Jn`5$jTc*yZQa+|LGuag=FqU%Fu>abclHlaV*ZL=l$pzyg)bFxlcUnOE?YI9?Sijj?Ias{ ztHD&rM*y7!*=q_=qI;BRWfhpEjn;R1>nm&?;$B?IP-u6r4({%CtBJXrVJKMNO z=G_jHTXMhs6$w@Ml&h#S;1yvVRri6C+h_QyJPRJ-PYu6ve-(Dab@-4)5B64riLno_ zlWTPzkGtcB7OH^D@+GvC-6vHh%8L?S1+#=pNV>Sy3Sf8f`Oc+4e2pEwTX4b4coAIp zj`?SNLrvWQ;w$bocHB%|cD_Rpky|sIRGd+aX!a1%H05dlOnsQ6dx>-}ZE$EG`@@>r zU91iqpzzY|q>+NT7X_gu6Jv-BaWhPr-NW^=Dnomwmhz`JQf8K@Rac~~Y;&$sy^=E{ zH0Y1KoLdcE73UGO?sPw~#%PHbMn_oS$^7!3!eYU*}T%hIqzm6E)!MJt$}Ui;Am1(+ zVusk?e_E{xWmyTN+q-od%C2}zX^{6syenl(>gKYTWGWC@AnEZ)qqUygT1!C$T90Wo z-JBxhN^<316c1DgaH4cDF_F8d*Q?93)9Ya+FuIF!M~8#7tox5=&c@Pe@G7u)k<=YK z>ZNBGiGXjQRMPM<`lKwPYGa9D@wxM!%*{`yyz$R6dT>eT4}Y=NZZM$Qvu5XQ?mXeg6+CNcltn0096WiwFb&00000{{{d;LjnLP z1MS+;ZrU&u2H@-LDNt^wR`#)dY^zs@b*r?NN-OOyQ3O$o)CB}twY~l9kkAkaBu#>b zWYjh)J$1s@(;wSP{Cm~&zYp(!4*jcMybPk%WI0>J<0$wQ_Wb@Wf@DNrQn&y@P04Hc z7QXi2s`nDS1yL}54kJ@{KN{UU-hCtM2M7@Urs93jtZtOnNs8LP`ZRf2Qtzh!)F1Xe zJDf)aG3PV~%9Qdhz0c;;{$MhHsnB}+s`nQpzZ?Hum!BXNyfsq-^DO}B=B=8+|)Qab5V zNOM4C4=A`%zSu9#G(&Yr8c_&YUwU}|bbVVQEt^4SLzhF#I?h~?O3sAI{rS6gMkYai z#JNy#R?fAI%hR`^pzG9Qoth?sklbdkP((QAPMrlbch*!RoS}2&IayU_YMsi{Bh^;O zh|}&uJMC(zky&Q~%B4q#>Cuj}>*r(rthi(@H%{QJsm*8e)y?iY%nbw%#2$p8&bdQp zh7{durG00}oF7L&JWz^qk5Q!M;Y@9U(*wv1B;xL-W*p9<@nk-oMb8yBh`#pkC?$gu z+wHOHYzw91UXX3lIC$>)gTa>v^WOqDMfoqTKZ$;Mq~uH=Ujrcm%7n^y|#%yTyt7&U-RQ-P!T;GH@( z-KKxXz=58xX0@ zXqTPcD7QI5<$Y%BEM+BUzT=#117*${Fu7Z!wsWE2tek5Zmn{Pu3%X7{)~V}6FhPLa sIk)Wm50iKxG}SKv03VA81ONa4009360763o02=@U000000000001%faGynhq diff --git a/tests/example.gtf.gz.tbi b/tests/example.gtf.gz.tbi index eb3f24c6ba9cd8cf5c4551ced2edfd08518ce9e7..4e2b56faf242539d584c8c2c710815451b1d0fef 100644 GIT binary patch delta 188 zcmV;t07L(T0)zsPGk>5er6DRFAA``ILJ)Cbs7|pG2<-(Ghw`DFEM#DQg@pyWUtn(CwH=jK--&8B%xqBT!@@UL0y1JxvjT(;fx4qj3&Lk$ qxXK42Vc`pNSAjBwhJ`PT57WoPfB-N(FuN$FVRirjL{K4kk>nt5!cPGJ delta 188 zcmV;t07L(T0)zsPGk+i|KT1JV>^KIYJ%u3RFz~thR5ZW6m4&%RE2BCeR z;xNAEHVEwt6^HRx?uXERP;nT)^bmyhhl)Qs4B;O*3!wv`;xPWzw-7oIDh}hb{)Es$ zP;nSPTC|267BVJK55vL&-7he=_HRd}|Lj1u8)h~r^kL!aBr*Z9Cqe;2hd|vCtp(vT qFf8K(k+ATExyw}nsyr&NRh diff --git a/tests/pysam_test.py b/tests/pysam_test.py index aefcbb9..d2bf415 100755 --- a/tests/pysam_test.py +++ b/tests/pysam_test.py @@ -7,11 +7,12 @@ and data files located there. import pysam import unittest -import os, re -import itertools +import os, re, sys +import itertools, collections import subprocess import shutil - +import logging +SAMTOOLS="samtools" def checkBinaryEqual( filename1, filename2 ): '''return true if the two files are binary equal.''' @@ -50,7 +51,7 @@ def runSamtools( cmd ): def getSamtoolsVersion(): '''return samtools version''' - pipe = subprocess.Popen("samtools", shell=True, stderr=subprocess.PIPE).stderr + pipe = subprocess.Popen(SAMTOOLS, shell=True, stderr=subprocess.PIPE).stderr lines = "".join(pipe.readlines()) return re.search( "Version:\s+(\S+)", lines).groups()[0] @@ -67,42 +68,42 @@ class BinaryTest(unittest.TestCase): mCommands = \ { "faidx" : \ ( - ("ex1.fa.fai", "samtools faidx ex1.fa"), + ("ex1.fa.fai", "faidx ex1.fa"), ("pysam_ex1.fa.fai", (pysam.faidx, "ex1.fa") ), ), "import" : ( - ("ex1.bam", "samtools import ex1.fa.fai ex1.sam.gz ex1.bam" ), + ("ex1.bam", "import ex1.fa.fai ex1.sam.gz ex1.bam" ), ("pysam_ex1.bam", (pysam.samimport, "ex1.fa.fai ex1.sam.gz pysam_ex1.bam") ), ), "index": ( - ("ex1.bam.bai", "samtools index ex1.bam" ), + ("ex1.bam.bai", "index ex1.bam" ), ("pysam_ex1.bam.bai", (pysam.index, "pysam_ex1.bam" ) ), ), "pileup1" : ( - ("ex1.pileup", "samtools pileup -cf ex1.fa ex1.bam > ex1.pileup" ), + ("ex1.pileup", "pileup -cf ex1.fa ex1.bam > ex1.pileup" ), ("pysam_ex1.pileup", (pysam.pileup, "-c -f ex1.fa ex1.bam" ) ) ), "pileup2" : ( - ("ex1.glf", "samtools pileup -gf ex1.fa ex1.bam > ex1.glf" ), + ("ex1.glf", "pileup -gf ex1.fa ex1.bam > ex1.glf" ), ("pysam_ex1.glf", (pysam.pileup, "-g -f ex1.fa ex1.bam" ) ) ), "glfview" : ( - ("ex1.glfview", "samtools glfview ex1.glf > ex1.glfview"), + ("ex1.glfview", "glfview ex1.glf > ex1.glfview"), ("pysam_ex1.glfview", (pysam.glfview, "ex1.glf" ) ), ), "view" : ( - ("ex1.view", "samtools view ex1.bam > ex1.view"), + ("ex1.view", "view ex1.bam > ex1.view"), ("pysam_ex1.view", (pysam.view, "ex1.bam" ) ), ), "view2" : ( - ("ex1.view", "samtools view -bT ex1.fa -o ex1.view2 ex1.sam"), + ("ex1.view", "view -bT ex1.fa -o ex1.view2 ex1.sam"), # note that -o ex1.view2 throws exception. ("pysam_ex1.view", (pysam.view, "-bT ex1.fa -oex1.view2 ex1.sam" ) ), ), @@ -110,7 +111,10 @@ class BinaryTest(unittest.TestCase): # some tests depend on others. The order specifies in which order # the samtools commands are executed. - mOrder = ('faidx', 'import', 'index', 'pileup1', 'pileup2', 'glfview', 'view', 'view2' ) + mOrder = ('faidx', 'import', 'index', + 'pileup1', 'pileup2', + # 'glfview', deprecated + 'view', 'view2' ) def setUp( self ): '''setup tests. @@ -127,24 +131,29 @@ class BinaryTest(unittest.TestCase): command = self.mCommands[label] samtools_target, samtools_command = command[0] pysam_target, pysam_command = command[1] - runSamtools( samtools_command ) + runSamtools( " ".join( (SAMTOOLS, samtools_command ))) 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() BinaryTest.first_time = False samtools_version = getSamtoolsVersion() - if samtools_version != pysam.__samtools_version__: + + 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__): raise ValueError("versions of pysam/samtools and samtools differ: %s != %s" % \ (pysam.__samtools_version__, samtools_version )) def checkCommand( self, command ): - if command: samtools_target, pysam_target = self.mCommands[command][0][0], self.mCommands[command][1][0] self.assertTrue( checkBinaryEqual( samtools_target, pysam_target ), @@ -162,14 +171,15 @@ class BinaryTest(unittest.TestCase): def testPileup2( self ): self.checkCommand( "pileup2" ) - def testGLFView( self ): - self.checkCommand( "glfview" ) + # deprecated + # def testGLFView( self ): + # self.checkCommand( "glfview" ) def testView( self ): self.checkCommand( "view" ) def testEmptyIndex( self ): - self.assertRaises( pysam.SamtoolsError, pysam.index, "exdoesntexist.bam" ) + self.assertRaises( IOError, pysam.index, "exdoesntexist.bam" ) def __del__(self): return @@ -262,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" ) @@ -270,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.''' @@ -292,12 +307,19 @@ class TestIteratorRow(unittest.TestCase): def checkRange( self, rnge ): '''compare results from iterator with those from samtools.''' ps = list(self.samfile.fetch(region=rnge)) - sa = list(pysam.view( "ex1.bam", rnge , raw = True) ) + sa = list(pysam.view( "ex1.bam", rnge, raw = True) ) self.assertEqual( len(ps), len(sa), "unequal number of results for range %s: %i != %i" % (rnge, len(ps), len(sa) )) # check if the same reads are returned and in the same order for line, pair in enumerate( zip( ps, sa ) ): - data = pair[1].split("\t") - self.assertEqual( pair[0].qname, data[0], "read id mismatch in line %i: %s != %s" % (line, pair[0].rname, data[0]) ) + a,b = pair + d = b.split("\t") + self.assertEqual( a.qname, d[0], "line %i: read id mismatch: %s != %s" % (line, a.rname, d[0]) ) + self.assertEqual( a.pos, int(d[3])-1, "line %i: read position mismatch: %s != %s, \n%s\n%s\n" % \ + (line, a.pos, int(d[3])-1, + str(a), str(d) ) ) + self.assertEqual( a.qual, d[10], "line %i: quality mismatch: %s != %s, \n%s\n%s\n" % \ + (line, a.qual, d[10], + str(a), str(d) ) ) def testIteratePerContig(self): '''check random access per contig''' @@ -313,7 +335,6 @@ class TestIteratorRow(unittest.TestCase): def tearDown(self): self.samfile.close() - class TestIteratorRowAll(unittest.TestCase): def setUp(self): @@ -381,7 +402,9 @@ class TestIteratorColumn(unittest.TestCase): # one read, all columns of the read are returned self.assertEqual( len(columns), refcolumns, "pileup incomplete at position %i: got %i, expected %i " %\ (pos, len(columns), refcolumns)) + + def tearDown(self): self.samfile.close() @@ -516,7 +539,17 @@ class TestHeaderSam(unittest.TestCase): def testHeaders(self): self.compareHeaders( self.header, self.samfile.header ) self.compareHeaders( self.samfile.header, self.header ) - + + def testNameMapping( self ): + for x, y in enumerate( ("chr1", "chr2")): + tid = self.samfile.gettid( y ) + ref = self.samfile.getrname( x ) + self.assertEqual( tid, x ) + self.assertEqual( ref, y ) + + self.assertEqual( self.samfile.gettid("chr?"), -1 ) + self.assertRaises( ValueError, self.samfile.getrname, 2 ) + def tearDown(self): self.samfile.close() @@ -599,19 +632,30 @@ class TestExceptions(unittest.TestCase): self.assertRaises( ValueError, self.samfile.fetch, "chr1", 5, 0 ) self.assertRaises( ValueError, self.samfile.fetch, "chr1", -5, -10 ) + self.assertRaises( ValueError, self.samfile.count, "chr1", 5, -10 ) + self.assertRaises( ValueError, self.samfile.count, "chr1", 5, 0 ) + self.assertRaises( ValueError, self.samfile.count, "chr1", -5, -10 ) + def testOutOfRangeNegativeOldFormat(self): self.assertRaises( ValueError, self.samfile.fetch, region="chr1:-5-10" ) self.assertRaises( ValueError, self.samfile.fetch, region="chr1:-5-0" ) self.assertRaises( ValueError, self.samfile.fetch, region="chr1:-5--10" ) + self.assertRaises( ValueError, self.samfile.count, region="chr1:-5-10" ) + self.assertRaises( ValueError, self.samfile.count, region="chr1:-5-0" ) + self.assertRaises( ValueError, self.samfile.count, region="chr1:-5--10" ) + def testOutOfRangNewFormat(self): self.assertRaises( ValueError, self.samfile.fetch, "chr1", 9999999999, 99999999999 ) + self.assertRaises( ValueError, self.samfile.count, "chr1", 9999999999, 99999999999 ) def testOutOfRangeLargeNewFormat(self): 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" ) + self.assertRaises( ValueError, self.samfile.count, "chr1:99999999999999999-999999999999999999" ) def testZeroToZero(self): '''see issue 44''' @@ -620,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.''' @@ -661,6 +704,14 @@ class TestFastaFile(unittest.TestCase): # unknown sequence returns "" self.assertEqual( "", self.file.fetch("chr12") ) + def testOutOfRangeAccess( self ): + '''test out of range access.''' + # out of range access returns an empty string + for contig, s in self.mSequences.iteritems(): + self.assertEqual( self.file.fetch( contig, len(s), len(s)+1), "" ) + + self.assertEqual( self.file.fetch( "chr3", 0 , 100), "" ) + def testFetchErrors( self ): self.assertRaises( ValueError, self.file.fetch ) self.assertRaises( ValueError, self.file.fetch, "chr1", -1, 10 ) @@ -958,10 +1009,12 @@ class TestRemoteFileFTP(unittest.TestCase): region = "1:1-1000" def testFTPView( self ): + return result = pysam.view( self.url, self.region ) self.assertEqual( len(result), 36 ) def testFTPFetch( self ): + return samfile = pysam.Samfile(self.url, "rb") result = list(samfile.fetch( region = self.region )) self.assertEqual( len(result), 36 ) @@ -973,7 +1026,11 @@ class TestRemoteFileHTTP( unittest.TestCase): local = "ex1.bam" def testView( self ): - self.assertRaises( pysam.SamtoolsError, pysam.view, self.url, self.region ) + samfile_local = pysam.Samfile(self.local, "rb") + ref = list(samfile_local.fetch( region = self.region )) + + result = pysam.view( self.url, self.region ) + self.assertEqual( len(result), len(ref) ) def testFetch( self ): samfile = pysam.Samfile(self.url, "rb") @@ -995,10 +1052,254 @@ class TestRemoteFileHTTP( unittest.TestCase): for x, y in zip(result, ref): self.assertEqual( x.compare( y ), 0 ) +class TestLargeOptValues( unittest.TestCase ): + ints = ( 65536, 214748, 2147484, 2147483647 ) + floats = ( 65536.0, 214748.0, 2147484.0 ) + + def check( self, samfile ): + + i = samfile.fetch() + for exp in self.ints: + rr = i.next() + obs = rr.opt("ZP") + self.assertEqual( exp, obs, "expected %s, got %s\n%s" % (str(exp), str(obs), str(rr))) + + for exp in [ -x for x in self.ints ]: + rr = i.next() + obs = rr.opt("ZP") + self.assertEqual( exp, obs, "expected %s, got %s\n%s" % (str(exp), str(obs), str(rr))) + + for exp in self.floats: + rr = i.next() + obs = rr.opt("ZP") + self.assertEqual( exp, obs, "expected %s, got %s\n%s" % (str(exp), str(obs), str(rr))) + + for exp in [ -x for x in self.floats ]: + rr = i.next() + obs = rr.opt("ZP") + self.assertEqual( exp, obs, "expected %s, got %s\n%s" % (str(exp), str(obs), str(rr))) + + def testSAM( self ): + samfile = pysam.Samfile("ex10.sam", "r") + self.check( samfile ) + + def testBAM( self ): + samfile = pysam.Samfile("ex10.bam", "rb") + self.check( samfile ) + +class TestSNPCalls( unittest.TestCase ): + '''test pysam SNP calling ability.''' + + def checkEqual( self, a, b ): + for x in ("reference_base", + "pos", + "genotype", + "consensus_quality", + "snp_quality", + "mapping_quality", + "coverage" ): + self.assertEqual( getattr(a, x), getattr(b,x), "%s mismatch: %s != %s\n%s\n%s" % + (x, getattr(a, x), getattr(b,x), str(a), str(b))) + + def testAllPositionsViaIterator( self ): + samfile = pysam.Samfile( "ex1.bam", "rb") + fastafile = pysam.Fastafile( "ex1.fa" ) + try: + refs = [ x for x in pysam.pileup( "-c", "-f", "ex1.fa", "ex1.bam" ) if x.reference_base != "*"] + except pysam.SamtoolsError: + pass + + i = samfile.pileup( stepper = "samtools", fastafile = fastafile ) + calls = list(pysam.IteratorSNPCalls(i)) + for x,y in zip( refs, calls ): + self.checkEqual( x, y ) + + def testPerPositionViaIterator( self ): + # test pileup for each position. This is a slow operation + # so this test is disabled + return + samfile = pysam.Samfile( "ex1.bam", "rb") + fastafile = pysam.Fastafile( "ex1.fa" ) + for x in pysam.pileup( "-c", "-f", "ex1.fa", "ex1.bam" ): + if x.reference_base == "*": continue + i = samfile.pileup( x.chromosome, x.pos, x.pos+1, + fastafile = fastafile, + stepper = "samtools" ) + z = [ zz for zz in pysam.IteratorSamtools(i) if zz.pos == x.pos ] + self.assertEqual( len(z), 1 ) + self.checkEqual( x, z[0] ) + + def testPerPositionViaCaller( self ): + # test pileup for each position. This is a fast operation + samfile = pysam.Samfile( "ex1.bam", "rb") + fastafile = pysam.Fastafile( "ex1.fa" ) + i = samfile.pileup( stepper = "samtools", fastafile = fastafile ) + caller = pysam.SNPCaller( i ) + + for x in pysam.pileup( "-c", "-f", "ex1.fa", "ex1.bam" ): + if x.reference_base == "*": continue + call = caller.call( x.chromosome, x.pos ) + self.checkEqual( x, call ) + +class TestIndelCalls( unittest.TestCase ): + '''test pysam indel calling.''' + + def checkEqual( self, a, b ): + + for x in ("pos", + "genotype", + "consensus_quality", + "snp_quality", + "mapping_quality", + "coverage", + "first_allele", + "second_allele", + "reads_first", + "reads_second", + "reads_diff"): + if b.genotype == "*/*" and x == "second_allele": + # ignore test for second allele (positions chr2:439 and chr2:1512) + continue + self.assertEqual( getattr(a, x), getattr(b,x), "%s mismatch: %s != %s\n%s\n%s" % + (x, getattr(a, x), getattr(b,x), str(a), str(b))) + + def testAllPositionsViaIterator( self ): + + samfile = pysam.Samfile( "ex1.bam", "rb") + fastafile = pysam.Fastafile( "ex1.fa" ) + try: + refs = [ x for x in pysam.pileup( "-c", "-f", "ex1.fa", "ex1.bam" ) if x.reference_base == "*"] + except pysam.SamtoolsError: + pass + + i = samfile.pileup( stepper = "samtools", fastafile = fastafile ) + calls = [ x for x in list(pysam.IteratorIndelCalls(i)) if x != None ] + for x,y in zip( refs, calls ): + self.checkEqual( x, y ) + + def testPerPositionViaCaller( self ): + # test pileup for each position. This is a fast operation + samfile = pysam.Samfile( "ex1.bam", "rb") + fastafile = pysam.Fastafile( "ex1.fa" ) + i = samfile.pileup( stepper = "samtools", fastafile = fastafile ) + caller = pysam.IndelCaller( i ) + + for x in pysam.pileup( "-c", "-f", "ex1.fa", "ex1.bam" ): + if x.reference_base != "*": continue + call = caller.call( x.chromosome, x.pos ) + self.checkEqual( x, call ) + +class TestLogging( unittest.TestCase ): + '''test around bug issue 42, + + failed in versions < 0.4 + ''' + + def check( self, bamfile, log ): + + if log: + logger = logging.getLogger('franklin') + logger.setLevel(logging.INFO) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + log_hand = logging.FileHandler('log.txt') + log_hand.setFormatter(formatter) + logger.addHandler(log_hand) + + bam = pysam.Samfile(bamfile, 'rb') + cols = bam.pileup() + self.assert_( True ) + + def testFail1( self ): + self.check( "ex9_fail.bam", False ) + self.check( "ex9_fail.bam", True ) + + def testNoFail1( self ): + self.check( "ex9_nofail.bam", False ) + self.check( "ex9_nofail.bam", True ) + + def testNoFail2( self ): + self.check( "ex9_nofail.bam", True ) + self.check( "ex9_nofail.bam", True ) + # TODOS # 1. finish testing all properties within pileup objects # 2. check exceptions and bad input problems (missing files, optional fields that aren't present, etc...) +# 3. check: presence of sequence + +class TestSamfileUtilityFunctions( unittest.TestCase ): + + def testCount( self ): + + samfile = pysam.Samfile( "ex1.bam", "rb" ) + + for contig in ("chr1", "chr2" ): + for start in xrange( 0, 2000, 100 ): + end = start + 1 + self.assertEqual( len( list( samfile.fetch( contig, start, end ) ) ), + samfile.count( contig, start, end ) ) + + # test empty intervals + self.assertEqual( len( list( samfile.fetch( contig, start, start ) ) ), + samfile.count( contig, start, start ) ) + + # test half empty intervals + self.assertEqual( len( list( samfile.fetch( contig, start ) ) ), + samfile.count( contig, start ) ) + + def testMate( self ): + '''test mate access.''' + + readnames = [ x.split("\t")[0] for x in open( "ex1.sam", "rb" ).readlines() ] + counts = collections.defaultdict( int ) + for x in readnames: counts[x] += 1 + + samfile = pysam.Samfile( "ex1.bam", "rb" ) + for read in samfile.fetch(): + if not read.is_paired: + self.assertRaises( ValueError, samfile.mate, read ) + elif read.mate_is_unmapped: + self.assertRaises( ValueError, samfile.mate, read ) + else: + if counts[read.qname] == 1: + self.assertRaises( ValueError, samfile.mate, read ) + else: + mate = samfile.mate( read ) + self.assertEqual( read.qname, mate.qname ) + self.assertEqual( read.is_read1, mate.is_read2 ) + self.assertEqual( read.is_read2, mate.is_read1 ) + self.assertEqual( read.pos, mate.mpos ) + self.assertEqual( read.mpos, mate.pos ) + +class TestSamtoolsProxy( unittest.TestCase ): + '''tests for sanity checking access to samtools functions.''' + + def testIndex( self ): + self.assertRaises( IOError, pysam.index, "missing_file" ) + + def testView( self ): + # note that view still echos "open: No such file or directory" + self.assertRaises( pysam.SamtoolsError, pysam.view, "missing_file" ) + + 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 diff --git a/tests/tabix_test.py b/tests/tabix_test.py index 8eb8a60..207a59c 100644 --- a/tests/tabix_test.py +++ b/tests/tabix_test.py @@ -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() -- 2.30.2