def get_ext_modules(): ext = ".pyx" if HAVE_CYTHON else ".c" src_files = glob.glob( os.path.join(os.path.dirname(__file__), "pairtools", "lib", "*" + ext) ) ext_modules = [] for src_file in src_files: name = "pairtools.lib." + os.path.splitext(os.path.basename(src_file))[0] if not "pysam" in name and not "regions" in name: ext_modules.append(Extension(name, [src_file])) elif "regions" in name: ext_modules.append(Extension( name, [src_file], language="c++", )) else: import pysam ext_modules.append( Extension( name, [src_file], extra_link_args=pysam.get_libraries(), include_dirs=pysam.get_include(), define_macros=pysam.get_defines(), ) ) if HAVE_CYTHON: # .pyx to .c ext_modules = cythonize(ext_modules) # , annotate=True return ext_modules
# Nubiscan motif mapping #Nubiscan = Extension( # "CGAT.Nubiscan.cnubiscan", # [ 'CGAT/Nubiscan/cnubiscan.pyx'], # library_dirs=[], # libraries=[], # include_dirs = [numpy.get_include()], # language="c", # ) # Automatically build script extensions pyx_files = glob.glob("scripts/*.pyx") script_extensions = [] pysam_dirname = os.path.dirname(pysam.__file__) include_dirs = [numpy.get_include()] + pysam.get_include() if IS_OSX: # linking against bundles does no work (and apparently is not needed) # within OS X extra_link_args = [] else: extra_link_args = [os.path.join(pysam_dirname, "csamtools.so")] for pyx_file in pyx_files: script_name = os.path.basename(pyx_file) script_prefix = script_name[:-4] script_extensions.append( Extension("CGAT.%s" % (script_prefix), sources=[pyx_file], extra_link_args=extra_link_args,
# installs into root dir (not what i want) #data_files=[('eddlib', ['eddlib/default_parameters.conf'])], package_data={'': ['*.conf']}, scripts=[ 'bin/edd', #'bin/edd-tools', ], install_requires=[ 'Logbook', 'pybedtools', 'statsmodels', 'patsy', # statsmodels dependency 'pandas', 'python-dateutil', # pandas dependency 'scipy', 'numpy', ], ext_modules=[ Extension( 'eddlib.read_bam', sources=['eddlib/read_bam.pyx'], include_dirs=pysam.get_include() + [np.get_include()], define_macros=pysam.get_defines(), ), Extension('eddlib.algorithm.chrom_max_segments', sources=['eddlib/algorithm/chrom_max_segments.pyx'], include_dirs=[np.get_include()]), ], cmdclass={'build_ext': build_ext}, )
import pysam name = 'genda' version = '0.1' try: from Cython.Distutils import build_ext except ImportError: use_cython = False print("Cython not found") else: use_cython = True cmdclass = {} ext_modules = [] includes = pysam.get_include() includes.append(numpy.get_include()) if use_cython: print('**********using cython*********') ext_modules += [ Extension("genda.transcripts.exon_utils", ["genda/transcripts/exon_utils.pyx"], include_dirs=includes), Extension("genda.pysam_callbacks.allele_counter", ["genda/pysam_callbacks/allele_counter.pyx"], include_dirs=includes, define_macros=pysam.get_defines()), Extension("genda.stats.aei_count_samples", ["genda/stats/aei_count_samples.pyx"], include_dirs=includes,
from distutils.core import setup from distutils.extension import Extension import Cython from Cython.Build import cythonize import pysam from Cython.Compiler.Options import get_directive_defaults #directive_defaults = get_directive_defaults() #directive_defaults['linetrace'] = True #directive_defaults['binding'] = True setup( cmdclass={'build_ext': Cython.Build.build_ext}, ext_modules = cythonize([Extension("chileup", sources=["hile.c", "chileup.pyx"], depends=["hile.h", "khash.h"], language='c', libraries=["z", "hts"], #define_macros=[('CYTHON_TRACE', '1')], include_dirs=["."] + pysam.get_include(), )]) )
import pysam from Cython.Build import cythonize if __name__ == '__main__': cythonize('pysamstats.pyx', include_path=pysam.get_include())
import numpy as np import sys from Cython.Compiler.Options import get_directive_defaults # directive_defaults = get_directive_defaults() # directive_defaults['linetrace'] = True # directive_defaults['binding'] = True setup( name="chileup", version="1.0.0", cmdclass={"build_ext": Cython.Build.build_ext}, install_requires=["pysam", "numpy"], ext_modules=cythonize( [ Extension( "chileup", sources=["hile.c", "chileup.pyx"], depends=["hile.h", "khash.h"], language="c", libraries=["z", "hts"], compiler_directives={"language_level", sys.version_info[0]}, # define_macros=[('CYTHON_TRACE', '1')], # extra_compile_args=['-std=c99'], include_dirs=["."] + pysam.get_include() + [np.get_include()], ) ] ), )
import os import glob import numpy from setuptools import setup, Extension import pysam src_list = glob.glob("src/*.c") pyx_list = glob.glob("dnaUtilsPy/*.pyx") include_dirs = pysam.get_include() + ["src", numpy.get_include()] extra_link_args = pysam.get_libraries() extensions = [] for pyx in pyx_list: assert pyx.endswith(".pyx") submodule = os.path.basename(pyx)[:-len(".pyx")] extensions.append( Extension("dnaUtilsPy." + submodule, sources=[pyx] + src_list, include_dirs=include_dirs, extra_link_args=extra_link_args)) setup(name="dnaUtilsPy", packages=["dnaUtilsPy"], ext_modules=extensions, install_requires=['numpy', 'pysam'], setup_requires=['numpy', 'pysam', 'cython'])
import pysam def get_version(): """Extract version number from source file.""" from ast import literal_eval with open('pysamstats.pyx') as f: for line in f: if line.startswith('__version__'): return literal_eval(line.partition('=')[2].lstrip()) raise ValueError("__version__ not found") extensions = [Extension('pysamstats', sources=['pysamstats.c'], include_dirs=pysam.get_include(), define_macros=pysam.get_defines())] setup( name='pysamstats', version=get_version(), author='Alistair Miles', author_email='*****@*****.**', url='https://github.com/alimanfoo/pysamstats', license='MIT Licenses', description='A Python utility for calculating statistics against genome ' 'position based on sequence alignments from a SAM, ' 'BAM or CRAM file.', scripts=['scripts/pysamstats'], classifiers=[
name = 'genda' version = '0.1' try: from Cython.Distutils import build_ext except ImportError: use_cython = False print("Cython not found") else: use_cython = True cmdclass = {} ext_modules = [] includes = pysam.get_include() includes.append(numpy.get_include()) if use_cython: print('**********using cython*********') ext_modules += [ Extension("genda.transcripts.exon_utils", ["genda/transcripts/exon_utils.pyx"], include_dirs=includes), Extension("genda.pysam_callbacks.allele_counter", ["genda/pysam_callbacks/allele_counter.pyx"], include_dirs=includes, define_macros=pysam.get_defines()),
import numpy as np import pyximport import pysam pyximport.install(setup_args = {'include_dirs':[np.get_include() ]+pysam.get_include()}) from .bam_splitter import *
def __iter__(self): import pysam import numpy return iter(pysam.get_include() + [numpy.get_include()])
# # if os.getenv("PATH", None): # for i in os.environ["PATH"].split(":"): # if "htslib" in os.path.basename(i): # print(glob.glob(i)) # if any("libhts" in i for i in glob.glob(i + "/*")): # htslib = i # break if htslib is None: print("Using packaged htslib") htslib = os.path.join(root, "dysgu/htslib") libraries = [f"{htslib}/hts"] # Library name for libhts.so library_dirs = [htslib, numpy.get_include(), f"{htslib}/htslib"] + pysam.get_include() include_dirs = [numpy.get_include(), root, # htslib, f"{htslib}/htslib", f"{htslib}/cram"] + pysam.get_include() runtime_dirs = [htslib] # os.path.join(root, "dysgu/htslib") # extra_link_args = ["-L ./dysgu/htslib", "-L ./dysgu/htslib/htslib"] print("Libs", libraries) print("Library dirs", library_dirs) print("Include dirs", include_dirs) print("Runtime dirs", runtime_dirs) print("Extras compiler args", extras) for item in ["sv2bam", "io_funcs", "graph", "coverage", "assembler", "call_component", "map_set_utils", "cluster", "post_call_metrics"]:
def __iter__(self): import pysam import numpy return iter(pysam.get_include()+[numpy.get_include()])
_logger.info("# cython unavailable; using included .c sources") # ########################################################################### # extnsion setup # https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#configuring-the-c-build # http://docs.cython.org/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules glob_ext = "pyx" if has_cython else "c" src_glob = "uta_align/align/*." + glob_ext if has_cython: sources = [src_glob] else: sources = glob.glob(src_glob) extensions = [Extension("*", sources, include_dirs=pysam.get_include())] if has_cython: compiler_directives = { 'c_string_encoding': 'ascii', 'embedsignature': True, 'language_level': 3 } extensions = cythonize(extensions, compiler_directives=compiler_directives) setup( ext_modules=extensions, use_scm_version=True, ) ## <LICENSE>
extra_compile_args=compile_options, extra_link_args=link_options), Extension("epic2.src.statistics", ["epic2/src/statistics.pyx"], language="c++", extra_compile_args=compile_options, extra_link_args=link_options), # Extension("epic2.src.differential", # ["epic2/src/differential.pyx"], language="c++", # extra_compile_args=compile_options), Extension("epic2.src.find_islands", ["epic2/src/find_islands.pyx"], language="c++", extra_compile_args=compile_options, extra_link_args=link_options), Extension("epic2.src.read_bam", ["epic2/src/read_bam.pyx"], language="c++", include_dirs=conda_include + pysam.get_include(), library_dirs=conda_lib, extra_compile_args=compile_options, extra_link_args=link_options + pysam.get_libraries(), define_macros=pysam.get_defines(), libraries=["z"]), Extension("epic2.src.genome_info", ["epic2/src/genome_info.pyx"], language="c++", extra_compile_args=compile_options, extra_link_args=link_options) ] setup( name="epic2", packages=find_packages(), ext_modules=cythonize(extensions, annotate=True, language_level='2'),
""" from setuptools import setup, find_packages from Cython.Build import cythonize import pysam setup( name='svtools', version='0.1', description='Tools for manipulating structural variant files', author='Matthew Stone', author_email='*****@*****.**', packages=find_packages(), package_data={'svtools': ['data/standard_template.vcf', 'data/vcfcluster_template.vcf']}, scripts=['scripts/svtools'], ext_modules=cythonize('svtools/utils/helpers.pyx'), include_dirs=pysam.get_include(), install_requires=[ 'numpy', 'scipy', 'pysam>=0.11.2.2', 'pybedtools', 'cython', 'natsort', 'boto3', 'pandas', ] )
raise Exception( 'please upgrade pysam first, e.g.: pip install --upgrade pysam') from Cython.Distutils import build_ext # Cython should be installed via pysam except ImportError: raise Exception( 'please install pysam first, e.g.: pip install --upgrade pysam') try: import numpy as np except ImportError: raise Exception('please install numpy first') extensions = [ Extension('SomVarIUS_calling', sources=['SomVarIUS/SomVarIUS_calling.pyx'], include_dirs=[np.get_include()] + pysam.get_include(), define_macros=pysam.get_defines()) ] extensions.append( Extension('query_muts', sources=['SomVarIUS/query_muts.pyx'], include_dirs=[np.get_include()] + pysam.get_include(), define_macros=pysam.get_defines())) setup( name='SomVarIUS', version='1.2', author='Kyle S. Smith', author_email='*****@*****.**', license="MIT Licenses",
from setuptools import find_packages, setup, Extension #from distutils.core import setup, Extension import glob import numpy as np import pysam from Cython.Build import cythonize from Cython.Distutils import build_ext include_path = [np.get_include()] include_path.extend(pysam.get_include()) ext_modules = cythonize( [Extension('*', ['deep_cfNA/*.pyx'], include_dirs=include_path)]) setup( name='deep_cfNA', version='0.1', description= 'Using deep learning to classify fragments from TGIRT-seq libraries of cell-free genetic materials', url='', author='Douglas C. Wu', author_email='*****@*****.**', license='MIT', packages=find_packages(), scripts=glob.glob('bin/*'), zip_safe=False, data_files=[('model', glob.glob('model/deep_cfNA_*'))], ext_modules=ext_modules, cmdclass={'build_ext': build_ext})
"Requires cython to " "be installed before running setup.py (pip install cython)") try: import pysam except ImportError: raise ImportError( "Requires pysam to " "be installed before running setup.py (pip install pysam)") try: import numpy as np except ImportError: raise ImportError( "Requires numpy to " "be installed before running setup.py (pip install numpy)") include_directory = pysam.get_include() include_directory.extend([np.get_include()]) setup(name='filterBamClip', version='0.1', description= 'Remove clipped alignments from bam file by some fractions threshold', url='', author='Douglas Wu', author_email='*****@*****.**', license='MIT', packages=['filterBamClip'], zip_safe=False, scripts=['bin/filterSoftClip.py'], ext_modules=cythonize([ Extension( name='filterBamClip.bam_splitter',
Extension("epic2.src.SICER_stats2", ["epic2/src/SICER_stats2.pyx"], language="c++", extra_compile_args=compile_options), Extension("epic2.src.statistics", ["epic2/src/statistics.pyx"], language="c++", extra_compile_args=compile_options), # Extension("epic2.src.differential", # ["epic2/src/differential.pyx"], language="c++", # extra_compile_args=compile_options), Extension("epic2.src.find_islands", ["epic2/src/find_islands.pyx"], language="c++", extra_compile_args=compile_options), Extension("epic2.src.read_bam", ["epic2/src/read_bam.pyx"], language="c++", extra_compile_args=compile_options, include_dirs=pysam.get_include() + conda_include, library_dirs=conda_lib, define_macros=pysam.get_defines(), libraries=["z"]), Extension("epic2.src.genome_info", ["epic2/src/genome_info.pyx"], language="c++", extra_compile_args=compile_options) ] setup( name="epic2", packages=find_packages(), ext_modules=cythonize(extensions, annotate=True, language_level='2'), scripts=["bin/epic2", "bin/epic2-df", "bin/epic2-bw"], package_data={ 'epic2': [
if versiontuple(pysam.__version__) < versiontuple('0.8.1'): raise Exception('please upgrade pysam first, e.g.: pip install --upgrade pysam') from Cython.Distutils import build_ext # Cython should be installed via pysam except ImportError: raise Exception('please install pysam first, e.g.: pip install --upgrade pysam') try: import numpy as np except ImportError: raise Exception('please install numpy first') extensions = [Extension('SomVarIUS_calling', sources=['SomVarIUS/SomVarIUS_calling.pyx'], include_dirs=[np.get_include()] + pysam.get_include(), define_macros=pysam.get_defines())] extensions.append(Extension('query_muts', sources=['SomVarIUS/query_muts.pyx'], include_dirs=[np.get_include()] + pysam.get_include(), define_macros=pysam.get_defines())) setup( name='SomVarIUS', version='1.2', author='Kyle S. Smith', author_email='*****@*****.**', license="MIT Licenses", url='https://github.com/kylessmith/SomVarIUS',
# Nubiscan motif mapping #Nubiscan = Extension( # "CGAT.Nubiscan.cnubiscan", # [ 'CGAT/Nubiscan/cnubiscan.pyx'], # library_dirs=[], # libraries=[], # include_dirs = [numpy.get_include()], # language="c", # ) # Automatically build script extensions pyx_files = glob.glob( "scripts/*.pyx" ) script_extensions = [] pysam_dirname = os.path.dirname( pysam.__file__ ) include_dirs = [ numpy.get_include() ] + pysam.get_include() if IS_OSX: # linking against bundles does no work (and apparently is not needed) # within OS X extra_link_args = [] else: extra_link_args = [ os.path.join( pysam_dirname, "csamtools.so")] for pyx_file in pyx_files: script_name = os.path.basename( pyx_file ) script_prefix = script_name[:-4] script_extensions.append( Extension( "CGAT.%s" % (script_prefix), sources = [pyx_file], extra_link_args = extra_link_args,
def pysam_incl(cy_ext): import pysam cy_ext.extend_includes(pysam.get_include()) cy_ext.extend_macros(pysam.get_defines()) cy_ext.extend_extra_objects([pysam.libchtslib.__file__])
def get_version(): """Extract version number from source file.""" from ast import literal_eval with open('fusorsv/fusion_utils.pyx') as f: for line in f: if line.startswith('__version__'): return literal_eval(line.partition('=')[2].lstrip()) raise ValueError("__version__ not found") cythonize('fusorsv/fusion_utils.pyx') extensions = [ Extension('fusion_utils', sources=['fusorsv/fusion_utils.pyx'], include_dirs=pysam.get_include() + [numpy.get_include()], define_macros=pysam.get_defines(), extra_compile_args=['-ffast-math']) ] setup(name='fusorsv', version=get_version(), author='Timothy Becker', author_email='*****@*****.**', url='https://github.com/timothyjamesbecker/FusorSV', license='GPL 3 License', description='SV calling data fusion framework', classifiers=[ 'Intended Audience :: Developers', 'License :: GPL 3 License', 'Programming Language :: Python :: 2.7', 'Programming Language :: Cython', 'Programming Language :: C',
], library_dirs=[], libraries=[], language="c++", ), Extension( "cgat.NCL.cnestedlist", ["cgat/NCL/cnestedlist.pyx", "cgat/NCL/intervaldb.c"], library_dirs=[], libraries=[], language="c", ), Extension( "cgat.GeneModelAnalysis", ["cgat/GeneModelAnalysis.pyx"], include_dirs=conda_includes + pysam.get_include() + [numpy.get_include()], library_dirs=[], libraries=[], define_macros=pysam.get_defines(), language="c", ), Extension( "cgat.BamTools.bamtools", ["cgat/BamTools/bamtools.pyx"], include_dirs=conda_includes + pysam.get_include() + [numpy.get_include()], library_dirs=pysam_libdirs, libraries=pysam_libs, define_macros=pysam.get_defines(), language="c",
'eddlib.algorithm'], # installs into root dir (not what i want) #data_files=[('eddlib', ['eddlib/default_parameters.conf'])], package_data={'': ['*.conf']}, scripts=[ 'bin/edd', #'bin/edd-tools', ], install_requires=[ 'Logbook', 'pybedtools', 'statsmodels', 'patsy', # statsmodels dependency 'pandas', 'python-dateutil', # pandas dependency 'scipy', 'numpy', ], ext_modules=[ Extension('eddlib.read_bam', sources=['eddlib/read_bam.pyx'], include_dirs=pysam.get_include() + [np.get_include()], define_macros=pysam.get_defines(), ), Extension('eddlib.algorithm.chrom_max_segments', sources=['eddlib/algorithm/chrom_max_segments.pyx'], include_dirs=[np.get_include()]), ], cmdclass = {'build_ext': build_ext}, )