rewrite CallPeakUnit.py
[MACS.git] / setup.py
blob7248fb2b21fb1bdebeb43ed0ed000a0dc337ebd9
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())
24 def main():
25 if sys.version_info < (3, 9):
26 sys.stderr.write("CRITICAL: Python version must >= 3.9!\n")
27 sys.exit(1)
29 # NumPy include dir
30 numpy_include_dir = [numpy.get_include()]
32 # CFLAG
33 extra_c_args = ["-w", "-O3", "-g0"]
34 # CFLAG for fermi-lite related codes
35 clang = False
36 icc = False
37 new_gcc = False
38 try:
39 if os.environ['CC'] == "clang":
40 clang = True
41 except KeyError:
42 pass
44 if not clang:
45 try:
46 gcc_version_check = subprocess.check_output([os.environ.get('CC', 'gcc'), "--version"], universal_newlines=True)
47 if gcc_version_check.find("clang") != -1:
48 clang = True
49 else:
50 gcc_version_check = gcc_version_check.split('\n')[0] # get the first line
51 m = re.search(r"\s+(\d+\.\d+)\.\d+", gcc_version_check)
52 if m:
53 gcc_version = float(m[1])
54 if gcc_version > 4.8:
55 new_gcc = True
56 except subprocess.CalledProcessError:
57 pass
59 try:
60 if os.environ['CC'] == "icc":
61 icc = True
62 except KeyError:
63 pass
65 extra_c_args_for_fermi = ["-std=gnu99", "-DUSE_SIMDE",
66 "-DSIMDE_ENABLE_NATIVE_ALIASES"]
68 if icc or sysconfig.get_config_vars()['CC'] == 'icc':
69 extra_c_args_for_fermi.extend(['-qopenmp-simd',
70 '-DSIMDE_ENABLE_OPENMP'])
71 elif new_gcc or clang or sysconfig.get_config_vars()['CC'] == 'clang':
72 extra_c_args_for_fermi.extend(['-fopenmp-simd',
73 '-DSIMDE_ENABLE_OPENMP'])
75 # extensions, those have to be processed by Cython
76 ext_modules = [Extension("MACS3.Signal.HMMR_EM",
77 ["MACS3/Signal/HMMR_EM.py"],
78 libraries=["m"],
79 include_dirs=numpy_include_dir,
80 extra_compile_args=extra_c_args),
81 Extension("MACS3.Signal.HMMR_Signal_Processing",
82 ["MACS3/Signal/HMMR_Signal_Processing.py"],
83 libraries=["m"],
84 extra_compile_args=extra_c_args),
85 Extension("MACS3.Signal.HMMR_HMM",
86 ["MACS3/Signal/HMMR_HMM.py"],
87 libraries=["m"],
88 include_dirs=numpy_include_dir,
89 extra_compile_args=extra_c_args),
90 Extension("MACS3.Signal.Prob",
91 ["MACS3/Signal/Prob.py"],
92 libraries=["m"],
93 include_dirs=numpy_include_dir,
94 extra_compile_args=extra_c_args),
95 Extension("MACS3.Signal.Region",
96 ["MACS3/Signal/Region.py"],
97 extra_compile_args=extra_c_args),
98 Extension("MACS3.Signal.Pileup",
99 ["MACS3/Signal/Pileup.py",
100 "MACS3/Signal/cPosValCalculation.c"],
101 include_dirs=numpy_include_dir,
102 extra_compile_args=extra_c_args),
103 Extension("MACS3.Signal.PileupV2",
104 ["MACS3/Signal/PileupV2.py"],
105 include_dirs=numpy_include_dir,
106 extra_compile_args=extra_c_args),
107 Extension("MACS3.Signal.PeakModel",
108 ["MACS3/Signal/PeakModel.py"],
109 include_dirs=numpy_include_dir,
110 extra_compile_args=extra_c_args),
111 Extension("MACS3.Signal.PeakDetect",
112 ["MACS3/Signal/PeakDetect.py"],
113 extra_compile_args=extra_c_args),
114 Extension("MACS3.Signal.SignalProcessing",
115 ["MACS3/Signal/SignalProcessing.py"],
116 include_dirs=numpy_include_dir,
117 extra_compile_args=extra_c_args),
118 Extension("MACS3.Signal.FixWidthTrack",
119 ["MACS3/Signal/FixWidthTrack.py"],
120 include_dirs=numpy_include_dir,
121 extra_compile_args=extra_c_args),
122 Extension("MACS3.Signal.PairedEndTrack",
123 ["MACS3/Signal/PairedEndTrack.py"],
124 include_dirs=numpy_include_dir,
125 extra_compile_args=extra_c_args),
126 Extension("MACS3.Signal.BedGraph",
127 ["MACS3/Signal/BedGraph.py"],
128 libraries=["m"],
129 include_dirs=numpy_include_dir,
130 extra_compile_args=extra_c_args),
131 Extension("MACS3.Signal.ScoreTrack",
132 ["MACS3/Signal/ScoreTrack.py"],
133 libraries=["m"],
134 include_dirs=numpy_include_dir,
135 extra_compile_args=extra_c_args),
136 Extension("MACS3.Signal.CallPeakUnit",
137 ["MACS3/Signal/CallPeakUnit.py"],
138 libraries=["m"],
139 include_dirs=numpy_include_dir,
140 extra_compile_args=extra_c_args),
141 Extension("MACS3.Signal.VariantStat",
142 ["MACS3/Signal/VariantStat.pyx"],
143 libraries=["m"],
144 include_dirs=numpy_include_dir,
145 extra_compile_args=extra_c_args),
146 Extension("MACS3.Signal.ReadAlignment",
147 ["MACS3/Signal/ReadAlignment.pyx"],
148 libraries=["m"],
149 include_dirs=numpy_include_dir,
150 extra_compile_args=extra_c_args),
151 Extension("MACS3.Signal.RACollection",
152 ["MACS3/Signal/RACollection.pyx",
153 "MACS3/fermi-lite/bfc.c",
154 "MACS3/fermi-lite/bseq.c",
155 "MACS3/fermi-lite/bubble.c",
156 "MACS3/fermi-lite/htab.c",
157 "MACS3/fermi-lite/ksw.c",
158 "MACS3/fermi-lite/kthread.c",
159 "MACS3/fermi-lite/mag.c",
160 "MACS3/fermi-lite/misc.c",
161 "MACS3/fermi-lite/mrope.c",
162 "MACS3/fermi-lite/rld0.c",
163 "MACS3/fermi-lite/rle.c",
164 "MACS3/fermi-lite/rope.c",
165 "MACS3/fermi-lite/unitig.c",
166 "MACS3/Signal/swalign.c"],
167 libraries=["m", "z"],
168 include_dirs=numpy_include_dir+["./",
169 "./MACS3/fermi-lite/",
170 "./MACS3/Signal/"],
171 extra_compile_args=extra_c_args+extra_c_args_for_fermi),
172 Extension("MACS3.Signal.UnitigRACollection",
173 ["MACS3/Signal/UnitigRACollection.pyx"],
174 libraries=["m"],
175 include_dirs=numpy_include_dir,
176 extra_compile_args=extra_c_args),
177 Extension("MACS3.Signal.PosReadsInfo",
178 ["MACS3/Signal/PosReadsInfo.pyx"],
179 libraries=["m"],
180 include_dirs=numpy_include_dir,
181 extra_compile_args=extra_c_args),
182 Extension("MACS3.Signal.PeakVariants",
183 ["MACS3/Signal/PeakVariants.pyx"],
184 libraries=["m"],
185 include_dirs=numpy_include_dir,
186 extra_compile_args=extra_c_args),
187 Extension("MACS3.IO.Parser",
188 ["MACS3/IO/Parser.py"],
189 extra_compile_args=extra_c_args),
190 Extension("MACS3.IO.PeakIO",
191 ["MACS3/IO/PeakIO.py"],
192 extra_compile_args=extra_c_args),
193 Extension("MACS3.IO.BedGraphIO",
194 ["MACS3/IO/BedGraphIO.py"],
195 extra_compile_args=extra_c_args),
196 Extension("MACS3.IO.BAM",
197 ["MACS3/IO/BAM.py",], libraries=["m"],
198 extra_compile_args=extra_c_args)]
200 setup(version=MACS_VERSION,
201 package_dir={'MACS3': 'MACS3'},
202 packages=['MACS3', 'MACS3.IO', 'MACS3.Signal', 'MACS3.Commands', 'MACS3.Utilities'],
203 package_data={'MACS3': ['*.pxd']},
204 scripts=['bin/macs3', ],
205 ext_modules=cythonize(ext_modules))
208 if __name__ == '__main__':
209 main()