fix a missing url
[MACS.git] / setup.py
blobe70280225fa5fd9300fb1bf4a9c968c499a30cb3
1 #!/usr/bin/env python3
2 """Description:
4 Setup script for MACS -- Model Based Analysis for ChIP-Seq data
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the BSD License (see the file LICENSE included with
8 the distribution).
9 """
11 import sys
12 import os
13 import re
14 from setuptools import setup, Extension
15 from Cython.Build import cythonize
16 import subprocess
17 import sysconfig
18 import numpy
20 # get MACS version
21 exec(open("MACS3/Utilities/Constants.py").read())
23 # classifiers
24 classifiers =[\
25 'Development Status :: 5 - Production/Stable',
26 'Environment :: Console',
27 'Intended Audience :: Developers',
28 'Intended Audience :: Science/Research',
29 'License :: OSI Approved :: BSD License',
30 'Operating System :: MacOS :: MacOS X',
31 'Operating System :: POSIX',
32 'Operating System :: Unix',
33 'Topic :: Scientific/Engineering :: Bio-Informatics',
34 'Programming Language :: Python :: 3.9',
35 'Programming Language :: Python :: 3.10',
36 'Programming Language :: Python :: 3.11',
37 'Programming Language :: Python :: 3.12',
38 'Programming Language :: Cython', ]
40 install_requires = [ "numpy>=1.25",
41 "scipy>=1.12",
42 "hmmlearn>=0.3.2",
43 "scikit-learn>=1.3",
44 "cykhash>=2.0,<3.0"]
48 def main():
49 if sys.version_info < (3,9):
50 sys.stderr.write("CRITICAL: Python version must >= 3.9!\n")
51 sys.exit(1)
53 # NumPy include dir
54 numpy_include_dir = [ numpy.get_include() ]
56 # CFLAG
57 # I intend to use -Ofast, however if gcc version < 4.6, this option is unavailable so...
58 # should I care about old gcc compiler?...
59 extra_c_args = ["-w","-Ofast", "-g0"] # for C, -Ofast implies -O3 and -ffast-math
61 # CFLAG for fermi-lite related codes
62 clang = False
63 icc = False
64 new_gcc = False
65 try:
66 if os.environ['CC'] == "clang":
67 clang = True
68 except KeyError:
69 pass
71 if not clang:
72 try:
73 gcc_version_check = subprocess.check_output( [os.environ.get('CC', 'gcc'), "--version"], universal_newlines=True)
74 if gcc_version_check.find("clang") != -1:
75 clang = True
76 else:
77 gcc_version_check = gcc_version_check.split('\n')[0] # get the first line
78 m = re.search(r"\s+(\d+\.\d+)\.\d+", gcc_version_check )
79 if m:
80 gcc_version = float( m[1] )
81 if gcc_version > 4.8:
82 new_gcc = True
83 except subprocess.CalledProcessError:
84 pass
86 try:
87 if os.environ['CC'] == "icc":
88 icc = True
89 except KeyError:
90 pass
92 extra_c_args_for_fermi = ["-std=gnu99","-DUSE_SIMDE", "-DSIMDE_ENABLE_NATIVE_ALIASES"]
93 if icc or sysconfig.get_config_vars()['CC'] == 'icc':
94 extra_c_args_for_fermi.extend(['-qopenmp-simd', '-DSIMDE_ENABLE_OPENMP'])
95 elif new_gcc or clang or sysconfig.get_config_vars()['CC'] == 'clang':
96 extra_c_args_for_fermi.extend(['-fopenmp-simd', '-DSIMDE_ENABLE_OPENMP'])
98 # extensions, those have to be processed by Cython
99 ext_modules = [ \
100 Extension("MACS3.Signal.HMMR_EM", ["MACS3/Signal/HMMR_EM.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
101 Extension("MACS3.Signal.HMMR_Signal_Processing", ["MACS3/Signal/HMMR_Signal_Processing.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
102 Extension("MACS3.Signal.HMMR_HMM", ["MACS3/Signal/HMMR_HMM.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
103 Extension("MACS3.Signal.Prob", ["MACS3/Signal/Prob.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
104 Extension("MACS3.Signal.Region", ["MACS3/Signal/Region.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
105 Extension("MACS3.Signal.Pileup", ["MACS3/Signal/Pileup.pyx","MACS3/Signal/cPosValCalculation.c"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
106 Extension("MACS3.Signal.PileupV2", ["MACS3/Signal/PileupV2.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
107 Extension("MACS3.Signal.PeakModel", ["MACS3/Signal/PeakModel.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
108 Extension("MACS3.Signal.PeakDetect", ["MACS3/Signal/PeakDetect.pyx"], extra_compile_args=extra_c_args),
109 Extension("MACS3.Signal.SignalProcessing", ["MACS3/Signal/SignalProcessing.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
110 Extension("MACS3.Signal.FixWidthTrack", ["MACS3/Signal/FixWidthTrack.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
111 Extension("MACS3.Signal.PairedEndTrack", ["MACS3/Signal/PairedEndTrack.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
112 Extension("MACS3.Signal.BedGraph", ["MACS3/Signal/BedGraph.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
113 #Extension("MACS3.Signal.BedGraphV2", ["MACS3/Signal/BedGraphV2.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
114 Extension("MACS3.Signal.ScoreTrack", ["MACS3/Signal/ScoreTrack.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args ),
115 Extension("MACS3.Signal.CallPeakUnit", ["MACS3/Signal/CallPeakUnit.pyx"], libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
116 Extension("MACS3.Signal.VariantStat",["MACS3/Signal/VariantStat.pyx",],libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
117 Extension("MACS3.Signal.ReadAlignment",["MACS3/Signal/ReadAlignment.pyx",],libraries=["m"],include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
118 Extension("MACS3.Signal.RACollection",["MACS3/Signal/RACollection.pyx","MACS3/fermi-lite/bfc.c","MACS3/fermi-lite/bseq.c",\
119 "MACS3/fermi-lite/bubble.c","MACS3/fermi-lite/htab.c","MACS3/fermi-lite/ksw.c","MACS3/fermi-lite/kthread.c",\
120 "MACS3/fermi-lite/mag.c","MACS3/fermi-lite/misc.c","MACS3/fermi-lite/mrope.c","MACS3/fermi-lite/rld0.c",\
121 "MACS3/fermi-lite/rle.c","MACS3/fermi-lite/rope.c","MACS3/fermi-lite/unitig.c", "MACS3/Signal/swalign.c" ], \
122 libraries=["m","z"], include_dirs=numpy_include_dir+["./","./MACS3/fermi-lite/","./MACS3/Signal/"], extra_compile_args=extra_c_args+extra_c_args_for_fermi),
123 Extension("MACS3.Signal.UnitigRACollection",["MACS3/Signal/UnitigRACollection.pyx"],libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
124 Extension("MACS3.Signal.PosReadsInfo",["MACS3/Signal/PosReadsInfo.pyx",],libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
125 Extension("MACS3.Signal.PeakVariants",["MACS3/Signal/PeakVariants.pyx",],libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
126 # IO
127 Extension("MACS3.IO.Parser",["MACS3/IO/Parser.pyx"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args),
128 Extension("MACS3.IO.PeakIO", ["MACS3/IO/PeakIO.pyx"], extra_compile_args=extra_c_args),
129 Extension("MACS3.IO.BedGraphIO", ["MACS3/IO/BedGraphIO.pyx"], extra_compile_args=extra_c_args),
130 Extension("MACS3.IO.BAM",["MACS3/IO/BAM.pyx",],libraries=["m"], include_dirs=numpy_include_dir, extra_compile_args=extra_c_args) ]
133 with open("README.md", "r") as fh:
134 long_description = fh.read()
136 setup( name = "MACS3",
137 version = MACS_VERSION,
138 description = "Model Based Analysis for ChIP-Seq data",
139 long_description = long_description,
140 long_description_content_type = "text/markdown",
141 author = 'Tao Liu',
142 author_email = 'vladimir.liu@gmail.com',
143 url = 'http://github.com/macs3-project/MACS/',
144 package_dir = {'MACS3' : 'MACS3'},
145 packages = ['MACS3', 'MACS3.IO', 'MACS3.Signal', 'MACS3.Commands','MACS3.Utilities'],
146 package_data = {'MACS3':['*.pxd']},
147 scripts = ['bin/macs3', ],
148 classifiers = classifiers,
149 install_requires = install_requires,
150 python_requires = '>=3.9',
151 ext_modules=cythonize( ext_modules ) ),
152 # compiler_directives={'linetrace': True, 'binding': True}) )
154 if __name__ == '__main__':
155 main()