forked from deeptools/deepTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·149 lines (127 loc) · 5.01 KB
/
setup.py
File metadata and controls
executable file
·149 lines (127 loc) · 5.01 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
#-*- coding: utf-8 -*-
import os
import sys
import subprocess
import re
from setuptools import setup
from setuptools.command.sdist import sdist as _sdist
from setuptools.command.install import install as _install
VERSION_PY = """
# This file is originally generated from Git information by running 'setup.py
# version'. Distribution tarballs contain a pre-generated copy of this file.
__version__ = '%s'
"""
def update_version_py():
if not os.path.isdir(".git"):
print "This does not appear to be a Git repository."
return
try:
p = subprocess.Popen(["git", "describe",
"--tags", "--always"],
stdout=subprocess.PIPE)
except EnvironmentError:
print "unable to run git, leaving deeptools/_version.py alone"
return
stdout = p.communicate()[0]
if p.returncode != 0:
print "unable to run git, leaving deeptools/_version.py alone"
return
ver = stdout.strip()
f = open("deeptools/_version.py", "w")
f.write(VERSION_PY % ver)
f.close()
print "set deeptools/_version.py to '%s'" % ver
def get_version():
try:
f = open("deeptools/_version.py")
except EnvironmentError:
return None
for line in f.readlines():
mo = re.match("__version__ = '([^']+)'", line)
if mo:
ver = mo.group(1)
return ver
return None
class sdist(_sdist):
def run(self):
update_version_py()
self.distribution.metadata.version = get_version()
return _sdist.run(self)
class install(_install):
def run(self):
_install.run(self)
if os.environ.get('DEEP_TOOLS_NO_CONFIG', False):
return
self.config_file = self.install_platlib + \
"/deeptools/config/deeptools.cfg"
# check installation of several components
samtools_installed = self.checkProgramIsInstalled(
'samtools', 'view',
'http://samtools.sourceforge.net/',
'correctGCbias')
bedGraphToBigWig_installed = self.checkProgramIsInstalled(
'bedGraphToBigWig', '-h',
'http://hgdownload.cse.ucsc.edu/admin/exe/',
'bamCoverage, bamCompare, correctGCbias')
bigwigInfo_installed = self.checkProgramIsInstalled(
'bigWigInfo', '-h',
'http://hgdownload.cse.ucsc.edu/admin/exe/',
'bigwigCompare')
if not samtools_installed or not bedGraphToBigWig_installed \
or not bigwigInfo_installed:
msg = "\n##########\nSome tools were not fund.\n"\
"If you already have a copy of this programs installed\n"\
"please be sure that they are found in your PATH or\n"\
"that they referred in the configuration file of deepTools\n"\
"located at:\n\n {}\n\n".format(self.config_file)
sys.stderr.write(msg)
def checkProgramIsInstalled(self, program, args, where_to_download,
affected_tools):
try:
_out = subprocess.Popen([program, args], stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
return True
except EnvironmentError:
# handle file not found error.
# the config file is installed in:
msg = "\n**{0} not found. This " \
"program is needed for the following "\
"tools to work properly:\n"\
" {1}\n"\
"{0} can be downloaded from here:\n " \
" {2}\n".format(program, affected_tools,
where_to_download)
sys.stderr.write(msg)
except Exception as e:
sys.stderr.write("Error: {}".format(e))
########
setup(
name='deepTools',
version=get_version(),
author='Fidel Ramirez, Friederike Dündar, Björn Grüning, Sarah Diehl',
author_email='deeptools@googlegroups.com',
packages=['deeptools', 'deeptools.test'],
scripts=['bin/bamCompare', 'bin/bamCoverage', 'bin/bamCorrelate',
'bin/heatmapper', 'bin/bamFingerprint', 'bin/estimateScaleFactor',
'bin/bamPEFragmentSize', 'bin/computeMatrix', 'bin/profiler',
'bin/computeGCBias', 'bin/correctGCBias', 'bin/bigwigCorrelate',
'bin/bigwigCompare'],
include_package_data=True,
package_data={'': ['config/deeptools.cfg']},
# data_files=[('deepTools', ['./deepTools.cfg'])],
# ('galaxy', ['galaxy/bamCompare.xml','galaxy/bamCoverage.xml',
# 'galaxy/heatmapper.xml'])],
url='http://pypi.python.org/pypi/deepTools/',
license='LICENSE.txt',
description='Useful library to deal with mapped reads in sorted '
'BAM format.',
long_description=open('README.txt').read(),
install_requires=[
"numpy >= 1.6.2",
"scipy >= 0.10.0",
"matplotlib >= 1.2",
"pysam >= 0.7.7",
"bx-python >= 0.5.0",
],
cmdclass={'sdist': sdist, 'install': install}
)