Mercurial > repos > youngkim > ezbamqc
comparison ezBAMQC/setup.py @ 0:dfa3745e5fd8
Uploaded
| author | youngkim |
|---|---|
| date | Thu, 24 Mar 2016 17:12:52 -0400 |
| parents | |
| children | 6610eedd9fae |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:dfa3745e5fd8 |
|---|---|
| 1 #!/usr/bin/env python2.7 | |
| 2 # Setup for ezBAMQC, utilities for the Sequence Alignment/Map format. | |
| 3 # | |
| 4 # Copyright (C) 2015 Bioinformatics Shared Resource, CSHL. | |
| 5 # Portions copyright (C) 2015 Cold Spring Harbor Laboratory. | |
| 6 # | |
| 7 # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 8 # of this software and associated documentation files (the "Software"), to deal | |
| 9 # in the Software without restriction, including without limitation the rights | |
| 10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 # copies of the Software, and to permit persons to whom the Software is | |
| 12 # furnished to do so, subject to the following conditions: | |
| 13 # | |
| 14 # The above copyright notice and this permission notice shall be included in | |
| 15 # all copies or substantial portions of the Software. | |
| 16 # | |
| 17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
| 20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 23 # DEALINGS IN THE SOFTWARE. | |
| 24 | |
| 25 import argparse | |
| 26 import sys, os, glob, fnmatch | |
| 27 | |
| 28 ## Added 10 Jan 2008 | |
| 29 from distutils.core import setup, Extension | |
| 30 import distutils.command.install_data | |
| 31 | |
| 32 ## Code borrowed from wxPython's setup and config files | |
| 33 ## Thanks to Robin Dunn for the suggestion. | |
| 34 ## I am not 100% sure what's going on, but it works! | |
| 35 def opj(*args): | |
| 36 path = os.path.join(*args) | |
| 37 return os.path.normpath(path) | |
| 38 | |
| 39 ## Added 10 Jan 2008 | |
| 40 # Specializations of some distutils command classes | |
| 41 class wx_smart_install_data(distutils.command.install_data.install_data): | |
| 42 """need to change self.install_dir to the actual library dir""" | |
| 43 def run(self): | |
| 44 install_cmd = self.get_finalized_command('install') | |
| 45 self.install_dir = getattr(install_cmd, 'install_lib') | |
| 46 return distutils.command.install_data.install_data.run(self) | |
| 47 | |
| 48 def find_data_files(srcdir, *wildcards, **kw): | |
| 49 # get a list of all files under the srcdir matching wildcards, | |
| 50 # returned in a format to be used for install_data | |
| 51 def walk_helper(arg, dirname, files): | |
| 52 if '.svn' in dirname: | |
| 53 return | |
| 54 names = [] | |
| 55 lst, wildcards = arg | |
| 56 for wc in wildcards: | |
| 57 wc_name = opj(dirname, wc) | |
| 58 for f in files: | |
| 59 filename = opj(dirname, f) | |
| 60 | |
| 61 if fnmatch.fnmatch(filename, wc_name) and not os.path.isdir(filename): | |
| 62 names.append(filename) | |
| 63 if names: | |
| 64 lst.append( (dirname, names ) ) | |
| 65 | |
| 66 file_list = [] | |
| 67 recursive = kw.get('recursive', True) | |
| 68 if recursive: | |
| 69 os.path.walk(srcdir, walk_helper, (file_list, wildcards)) | |
| 70 else: | |
| 71 walk_helper((file_list, wildcards), | |
| 72 srcdir, | |
| 73 [os.path.basename(f) for f in glob.glob(opj(srcdir, '*'))]) | |
| 74 return file_list | |
| 75 | |
| 76 ## This is a list of files to install, and where: | |
| 77 ## Make sure the MANIFEST.in file points to all the right | |
| 78 ## directories too. | |
| 79 files = find_data_files('ezBAMQC/', '*.*') | |
| 80 | |
| 81 from distutils.core import setup | |
| 82 | |
| 83 def readme(): | |
| 84 with open('README.rst') as f: | |
| 85 return f.read() | |
| 86 | |
| 87 if sys.version_info[0] != 2 or sys.version_info[1] < 7: | |
| 88 print >> sys.stderr, "ERROR: ezBAMQC requires Python 2.7" | |
| 89 sys.exit() | |
| 90 | |
| 91 BAMQC_HEADER = [ | |
| 92 'src/bamqc/Constants.h', | |
| 93 'src/bamqc/Coverage_prof.h', | |
| 94 'src/bamqc/GeneFeatures.h', | |
| 95 'src/bamqc/InnerDist_prof.h', | |
| 96 'src/bamqc/IntervalTree.h', | |
| 97 'src/bamqc/Mappability.h', | |
| 98 'src/bamqc/parseBAM.h', | |
| 99 'src/bamqc/ReadDup_prof.h', | |
| 100 'src/bamqc/Results.h', | |
| 101 'src/bamqc/rRNA.h' | |
| 102 ] | |
| 103 | |
| 104 BAMQC_SOURCE = [ | |
| 105 'src/bamqc/Coverage_prof.cpp', | |
| 106 'src/bamqc/GeneFeatures.cpp', | |
| 107 'src/bamqc/InnerDist_prof.cpp', | |
| 108 'src/bamqc/IntervalTree.cpp', | |
| 109 'src/bamqc/Mappability.cpp', | |
| 110 'src/bamqc/parseBAM.cpp', | |
| 111 'src/bamqc/ReadDup_prof.cpp', | |
| 112 'src/bamqc/Results.cpp', | |
| 113 'src/bamqc/rRNA.cpp' | |
| 114 ] | |
| 115 | |
| 116 ###TODO HAVE TO SPLIT INTO TWO AND MAKE THE A FILE | |
| 117 HTSLIB_PUBLIC_HEADERS = [ | |
| 118 'src/htslib/bgzf.h', | |
| 119 'src/htslib/faidx.h', | |
| 120 'src/htslib/hfile.h', | |
| 121 'src/htslib/hts.h', | |
| 122 'src/htslib/hts_defs.h', | |
| 123 'src/htslib/khash.h', | |
| 124 'src/htslib/klist.h', | |
| 125 'src/htslib/knetfile.h', | |
| 126 'src/htslib/kseq.h', | |
| 127 'src/htslib/ksort.h', | |
| 128 'src/htslib/kstring.h', | |
| 129 'src/htslib/regidx.h', | |
| 130 'src/htslib/sam.h', | |
| 131 'src/htslib/synced_bcf_reader.h', | |
| 132 'src/htslib/tbx.h', | |
| 133 'src/htslib/vcf.h', | |
| 134 'src/htslib/vcf_sweep.h', | |
| 135 'src/htslib/vcfutils.h' | |
| 136 ] | |
| 137 | |
| 138 | |
| 139 HTSLIB = [ | |
| 140 'src/htslib/bgzf.c', | |
| 141 'src/htslib/faidx.c', | |
| 142 'src/htslib/hfile.c', | |
| 143 'src/htslib/hfile_net.c', | |
| 144 'src/htslib/hts.c', | |
| 145 'src/htslib/kfunc.c', | |
| 146 'src/htslib/knetfile.c', | |
| 147 'src/htslib/kstring.c', | |
| 148 'src/htslib/regidx.c', | |
| 149 'src/htslib/sam.c', | |
| 150 'src/htslib/synced_bcf_reader.c', | |
| 151 'src/htslib/tbx.c', | |
| 152 'src/htslib/vcf.c', | |
| 153 'src/htslib/vcfutils.c', | |
| 154 'src/htslib/cram/cram_codecs.c', | |
| 155 'src/htslib/cram/cram_decode.c', | |
| 156 'src/htslib/cram/cram_encode.c', | |
| 157 'src/htslib/cram/cram_index.c', | |
| 158 'src/htslib/cram/cram_io.c', | |
| 159 'src/htslib/cram/cram_samtools.c', | |
| 160 'src/htslib/cram/cram_stats.c', | |
| 161 'src/htslib/cram/files.c', | |
| 162 'src/htslib/cram/mFILE.c', | |
| 163 'src/htslib/cram/md5.c', | |
| 164 'src/htslib/cram/open_trace_file.c', | |
| 165 'src/htslib/cram/pooled_alloc.c', | |
| 166 'src/htslib/cram/rANS_static.c', | |
| 167 'src/htslib/cram/sam_header.c', | |
| 168 'src/htslib/cram/string_alloc.c', | |
| 169 'src/htslib/cram/thread_pool.c', | |
| 170 'src/htslib/cram/vlen.c', | |
| 171 'src/htslib/cram/zfio.c' | |
| 172 ] | |
| 173 | |
| 174 BAMqc_CFLAGS = ['-fpermissive','-O3','-std=c++11','-Wno-error=declaration-after-statement'] | |
| 175 BAMqc_DFLAGS = [('_FILE_OFFSET_BITS','64'),('_LARGEFILE64_SOURCE',''),('_CURSES_LIB','1')] | |
| 176 BAMqc_INCLUDES = ['./src/htslib'] | |
| 177 BAMqc_HEADERS = ['./src/bamqc'] | |
| 178 BAMqc_EXTRA = ['build/lib.linux-x86_64-2.7/htslib.so'] | |
| 179 | |
| 180 htslib_CFLAGS = ['-Wno-error=declaration-after-statement'] | |
| 181 htslib_HEADERS = ['./src/htslib','./src/htslib/htslib','./src/htslib/cram'] | |
| 182 htslib_DFLAGS = [('_FILE_OFFSET_BITS','64'),('_USE_KNETFILE','')] | |
| 183 | |
| 184 setup(name = "ezBAMQC", | |
| 185 version = "0.6.5", | |
| 186 description = 'Quality control tools for NGS alignment file', | |
| 187 keywords = 'Quality control BAM file', | |
| 188 # make sure to add all the nessacary requires | |
| 189 dependency_links=['https://gcc.gnu.org/gcc-4.8/','https://www.r-project.org/','https://cran.r-project.org/web/packages/corrplot/'], | |
| 190 cmdclass = { 'install_data': wx_smart_install_data }, | |
| 191 scripts = ["ezBAMQC"], | |
| 192 author = "Ying Jin", | |
| 193 author_email ="yjin@cshl.edu", | |
| 194 license='GPLv3', | |
| 195 platforms = ['Linux'], | |
| 196 url='http://hammelllab.labsites.cshl.edu/software#BAMqc', | |
| 197 long_description=readme(), | |
| 198 classifiers=[ | |
| 199 'Development Status :: 4 - Beta', | |
| 200 'Natural Language :: English', | |
| 201 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', | |
| 202 'Topic :: Scientific/Engineering :: Bio-Informatics', | |
| 203 'Intended Audience :: Science/Research', | |
| 204 'Programming Language :: Python :: 2.7', | |
| 205 'Programming Language :: C++', | |
| 206 'Operating System :: Unix', | |
| 207 ], | |
| 208 zip_safe = False, | |
| 209 include_package_data=True, | |
| 210 ext_modules = [ | |
| 211 Extension('htslib', | |
| 212 sources = HTSLIB, | |
| 213 include_dirs = htslib_HEADERS, | |
| 214 extra_compile_args = htslib_CFLAGS, | |
| 215 define_macros = htslib_DFLAGS, | |
| 216 libraries=['z'] | |
| 217 ), | |
| 218 Extension('libBAMqc', | |
| 219 sources = BAMQC_SOURCE, | |
| 220 extra_compile_args = BAMqc_CFLAGS, | |
| 221 include_dirs = BAMqc_HEADERS + htslib_HEADERS, | |
| 222 extra_objects = BAMqc_EXTRA, | |
| 223 define_macros = BAMqc_DFLAGS | |
| 224 ) | |
| 225 ] | |
| 226 ) |
