Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merged from master
Browse files Browse the repository at this point in the history
  • Loading branch information
msbentsen committed Apr 28, 2019
2 parents ea51ea9 + 5b3e2a6 commit b7c05c4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
## 0.3.2 (2019-04-26)
- Added --add_region_columns to TFBScan

## 0.3.1 (2019-04-10)
- Split motif ids between name/motif_id/output_prefix
41 changes: 15 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
import os
import sys
import re
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools import setup, Extension, dist

included_dirs = []
#Test if numpy is installed
try:
import numpy as np
included_dirs.append(np.get_include())
except:
pass

"""
#Test if numpy is installed
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy as np
self.include_dirs.append(np.get_include())
included_dirs.append(np.get_include())
"""
#Else, fetch numpy if needed
dist.Distribution().fetch_build_eggs(['numpy'])
import numpy as np

#Add cython modules depending on the availability of cython
cmdclass = {}
Expand All @@ -33,15 +21,16 @@ def finalize_options(self):
else:
use_cython = True

#To compile or not to compile
if use_cython:
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.pyx"], include_dirs=included_dirs), #,sinclude[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.pyx"], include_dirs=included_dirs), #include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.pyx"], include_dirs=included_dirs)] #, include_dirs=[np.get_include()])]
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.pyx"], include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.pyx"], include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.pyx"], include_dirs=[np.get_include()])]

else:
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.c"], include_dirs=included_dirs), #, include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.c"], include_dirs=included_dirs), #, include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.c"], include_dirs=included_dirs)] #, include_dirs=[np.get_include()])]
ext_modules = [Extension("tobias.utils.ngs", ["tobias/utils/ngs.c"], include_dirs=[np.get_include()]),
Extension("tobias.utils.sequences", ["tobias/utils/sequences.c"], include_dirs=[np.get_include()]),
Extension("tobias.utils.signals", ["tobias/utils/signals.c"], include_dirs=[np.get_include()])]

#Path of setup file to establish version
setupdir = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -54,6 +43,7 @@ def find_version(init_file):
else:
raise RuntimeError("Unable to find version string.")

#Readme from git
def readme():
with open('README.md') as f:
return f.read()
Expand All @@ -73,8 +63,6 @@ def readme():
ext_modules=ext_modules,
cmdclass=cmdclass,
setup_requires=["numpy"],
include_dirs=included_dirs,
#dependency_links=['https://github.com/jhkorhonen/MOODS/releases/download/v1.9.3/MOODS-python-1.9.3.tar.gz#egg=MOODS-python-1.9.3'],
install_requires=[
'numpy',
'scipy',
Expand All @@ -87,6 +75,7 @@ def readme():
'xlsxwriter',
'adjustText',
'pyBigWig',
'MOODS-python',
],
scripts = ["tobias/utils/filter_important_factors.py"],
classifiers=[
Expand All @@ -95,5 +84,5 @@ def readme():
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Programming Language :: Python :: 3'
],
zip_safe=True,
zip_safe=True
)
11 changes: 7 additions & 4 deletions tobias/TOBIAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
try:
import MOODS
except:
sys.exit("ERROR: Package MOODS is not installed and is needed by TOBIAS. You can install it using:\n" +
"$ wget https://github.com/jhkorhonen/MOODS/releases/download/v1.9.3/MOODS-python-1.9.3.tar.gz\n" +
"$ tar xzvf MOODS-python-1.9.3.tar.gz\n" +
sys.exit("ERROR: Package MOODS is not installed and is needed by TOBIAS. You can install it via conds using:\n"
"$ conda install moods -c bioconda\n\n"
"Or directly from source:\n"
"$ wget https://github.com/jhkorhonen/MOODS/releases/download/v1.9.3/MOODS-python-1.9.3.tar.gz\n"
"$ tar xzvf MOODS-python-1.9.3.tar.gz\n"
"$ cd MOODS-python-1.9.3\n"
"$ python setup.py install")
"$ python setup.py install"
)

#Import general
import argparse
Expand Down
2 changes: 1 addition & 1 deletion tobias/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1"
__version__ = "0.3.2"
10 changes: 8 additions & 2 deletions tobias/motifs/tfbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def add_tfbscan_arguments(parser):
optional_arguments.add_argument('--gc', metavar="", type=lambda x: restricted_float(x,0,1), help='Set the gc content for background regions (default: will be estimated from fasta)')
optional_arguments.add_argument('--pvalue', metavar="", type=lambda x: restricted_float(x,0,1), help='Set p-value for motif matches (default: 0.0001)', default=0.0001)
optional_arguments.add_argument('--keep-overlaps', action='store_true', help='Keep overlaps of same motifs (default: overlaps are resolved by keeping best-scoring site)')

optional_arguments.add_argument('--add-region-columns', action='store_true', help="Add extra information columns (from 4th column) from --regions to the output .bed-file(s) (default: off)")

RUN = parser.add_argument_group('Run arguments')
RUN.add_argument('--split', metavar="<int>", type=int, help="Split of multiprocessing jobs (default: 100)", default=100)
RUN.add_argument('--cores', metavar="", type=int, help='Number of cores to use (default: 1)', default=1)
Expand All @@ -72,8 +73,13 @@ def motif_scanning(regions, args, motifs_obj):
for region in regions:

seq = fasta_obj.fetch(region.chrom, region.start, region.end)
region_TFBS = motifs_obj.scan_sequence(seq, region) #Scan sequence
region_TFBS = motifs_obj.scan_sequence(seq, region) #Scan sequence, returns list of OneRegion TFBS

#Add region columns if chosen
if args.add_region_columns:
for TFBS in region_TFBS:
TFBS.extend(region[3:])

#Check format of region chromosome and convert sites if needed
m = re.match(r"(.+)\:([0-9]+)\-([0-9]+)\s+.+", region.chrom)
if m:
Expand Down

0 comments on commit b7c05c4

Please sign in to comment.