-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
141 lines (125 loc) · 5.38 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python
"""Description
Setup script for "SELMA: a computational framework for modeling intrinsic biases in chromatin accessibility sequencing data"
Copyright (c) 2022 Shengen Hu <[email protected]>
This code is free software; you can redistribute it and/or modify it
under the terms of the Artistic License (see the file COPYING included
with the distribution).
"""
import os
import sys
import subprocess
import platform
from distutils.core import setup#, Extension
import distutils.command.install_lib
#from setuptools import setup, find_packages
def sp(cmd):
'''
Call shell cmd or software and return its stdout
'''
a=subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell='TRUE')
ac = a.communicate()
return ac
def check_bedtools():
checkhandle = sp('which bedtools')
if checkhandle[0].strip() == "":
return 0
else:
return 1
def check_R():
checkhandle = sp('which Rscript')
if checkhandle[0].strip() == "":
return 0
else:
return 1
class my_install_lib(distutils.command.install_lib.install_lib):
def run(self):
distutils.command.install_lib.install_lib.run(self)
mode = 755
# here we start with doing our overriding and private magic ..
for filepath in self.get_outputs():
if "bigWigSummary" in filepath or "bedtools" in filepath or "bedGraphToBigWig" in filepath or "twoBitToFa" in filepath or "twoBitInfo" in filepath:
#if self.install_scripts in filepath:
# log.info("Overriding setuptools mode of scripts ...")
# log.info("Changing ownership of %s to uid:%s gid %s" %
# (filepath, uid, gid))
# os.chown(filepath, uid, gid)
# log.info("Changing permissions of %s to %s" %
# (filepath, oct(mode)))
os.chmod(filepath, mode)
def main():
# if sys.version_info[0] != 2 or sys.version_info[1] < 7:
# print >> sys.stderr, "ERROR: ncHMR_detector requires Python 2.7"
# sys.exit()
has_R = check_R()
if has_R == 0:
print("ERROR: SELMA requires R & Rscript under default PATH", file=sys.stderr)
sys.exit()
OS = platform.system()
if OS == "Linux":
bwsum_software = "bigWigSummary_linux"
elif OS == "Darwin":
bwsum_software = "bigWigSummary_mac"
else:
wlog("detected system is nither linux nor mac, try linux version of bigWigSummary",logfile)
bwsum_software = "bigWigSummary_linux"
OS = platform.system()
if OS == "Linux":
bwsum_software = "bigWigSummary_linux"
bedtools_software = "bedtools_linux"
bdg2bw_software = "bedGraphToBigWig_linux"
twobit_software = "twoBitToFa_linux"
twobitI_software = "twoBitInfo_linux"
elif OS == "Darwin":
bwsum_software = "bigWigSummary_mac"
bedtools_software = "bedtools_mac"
bdg2bw_software = "bedGraphToBigWig_mac"
twobit_software = "twoBitToFa_mac"
twobitI_software = "twoBitInfo_mac"
else:
wlog("detected system is nither linux nor mac, try linux version",logfile)
bwsum_software = "bigWigSummary_linux"
bedtools_software = "bedtools_linux"
bdg2bw_software = "bedGraphToBigWig_linux"
twobit_software = "twoBitToFa_linux"
twobitI_software = "twoBitInfo_linux"
setup(name="SELMA",
version="1.0",
description="SELMA: a computational framework for modeling intrinsic biases in chromatin accessibility sequencing data",
author='Shengen Shawn Hu',
author_email='[email protected]',
url='https://github.com/Tarela/SELMA.git',
package_dir={'SELMApipe' : 'lib'},
packages=['SELMApipe'],
#package_data={}
package_data={'SELMApipe': ['external_script/%s'%bwsum_software,
'external_script/%s'%bedtools_software,
'external_script/%s'%bdg2bw_software,
'external_script/%s'%twobit_software,
'external_script/%s'%twobitI_software,
'refdata/ATAC_SELMAbias_10mer.txt.gz',
'refdata/DNase_SELMAbias_10mer.txt.gz'
]},#,#'Config/template.conf',
#'Rscript/analysis.r',
#'Rscript/individual_qc.r',
#'Rscript/readsbulkQC.r',
#'Rscript/detectNonCanonical.r'
# ]},
#scripts=['bin/ncHMR_detector_py3','refpackage/bwsummary/%s'%bwsum_software],
scripts=['bin/SELMA'],#,'refpackage/bwsummary/%s'%bwsum_software],
#data_files=[('/Users/sh8tv/bin',['refpackage/bwsummary/%s'%bwsum_software])],
classifiers=[
'Development Status :: version1.0 finish',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Artistic License',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: pipeline',
],
requires=[],
cmdclass={'install_lib':my_install_lib}
)
print('Installation of SELMA is DONE')
if __name__ == '__main__':
main()