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