Skip to content

Commit

Permalink
Adding tests and configuring tox.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
r78v10a07 committed Sep 17, 2020
1 parent 19832e7 commit dfe5396
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand Down
21 changes: 21 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
bioconda2biocontainer
biopython
cookiecutter
cwltool
docker
galaxy-tool-util
GitPython
goenrichment
jupyter
matplotlib
networkx
numpy
pandas
pdf2image
PyYAML
requests
scipy
seaborn
statsmodels
urllib3
xmltodict
149 changes: 128 additions & 21 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,128 @@
bioconda2biocontainer~=0.0.3
biopython~=1.77
cookiecutter~=1.7.2
cwltool~=3.0.20200710214758
docker~=4.2.2
galaxy-tool-util~=20.5.0
GitPython~=3.1.7
goenrichment~=0.0.10a3
jupyter~=1.0.0
matplotlib~=3.3.0
networkx~=2.4
numpy~=1.19.0
pandas~=1.0.5
pdf2image~=1.13.1
PyYAML~=5.3.1
requests~=2.24.0
scipy~=1.5.1
seaborn~=0.10.1
statsmodels~=0.11.1
urllib3~=1.25.9
xmltodict~=0.12.0
# SHA1:2016d815aabb3e67f3ea04ab7fed4def6fbdf0bf
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
appnope==0.1.0 # via ipykernel, ipython
argon2-cffi==20.1.0 # via notebook
arrow==0.16.0 # via jinja2-time
async-generator==1.10 # via nbclient
attrs==20.2.0 # via jsonschema
backcall==0.2.0 # via ipython
bagit==1.7.0 # via cwltool
binaryornot==0.4.4 # via cookiecutter
bioconda2biocontainer==0.0.4 # via -r requirements/base.in
biopython==1.78 # via -r requirements/base.in
bleach==3.2.0 # via galaxy-util, nbconvert
boltons==20.2.1 # via galaxy-util
cachecontrol==0.11.7 # via schema-salad
certifi==2020.6.20 # via matplotlib, requests
cffi==1.14.2 # via argon2-cffi
chardet==3.0.4 # via binaryornot, requests
click==7.1.2 # via cookiecutter
coloredlogs==14.0 # via cwltool
cookiecutter==1.7.2 # via -r requirements/base.in
cwltool==3.0.20200807132242 # via -r requirements/base.in
cycler==0.10.0 # via matplotlib
decorator==4.4.2 # via ipython, networkx
defusedxml==0.6.0 # via nbconvert
docker==4.3.1 # via -r requirements/base.in
docutils==0.16 # via galaxy-util
entrypoints==0.3 # via nbconvert
galaxy-containers==20.5.0 # via galaxy-tool-util
galaxy-tool-util==20.5.0 # via -r requirements/base.in
galaxy-util==20.5.0 # via galaxy-containers, galaxy-tool-util
gitdb==4.0.5 # via gitpython
gitpython==3.1.8 # via -r requirements/base.in
goenrichment==0.0.10a3 # via -r requirements/base.in
humanfriendly==8.2 # via coloredlogs
idna==2.10 # via requests
importlib-metadata==1.7.0 # via jsonschema
ipykernel==5.3.4 # via ipywidgets, jupyter, jupyter-console, notebook, qtconsole
ipython-genutils==0.2.0 # via nbformat, notebook, qtconsole, traitlets
ipython==7.18.1 # via ipykernel, ipywidgets, jupyter-console
ipywidgets==7.5.1 # via jupyter
isodate==0.6.0 # via rdflib
jedi==0.17.2 # via ipython
jinja2-time==0.2.0 # via cookiecutter
jinja2==2.11.2 # via cookiecutter, jinja2-time, nbconvert, notebook
jsonschema==3.2.0 # via nbformat
jupyter-client==6.1.7 # via ipykernel, jupyter-console, nbclient, notebook, qtconsole
jupyter-console==6.2.0 # via jupyter
jupyter-core==4.6.3 # via jupyter-client, nbconvert, nbformat, notebook, qtconsole
jupyter==1.0.0 # via -r requirements/base.in
jupyterlab-pygments==0.1.1 # via nbconvert
kiwisolver==1.2.0 # via matplotlib
lockfile==0.12.2 # via schema-salad
lxml==4.5.2 # via prov
markupsafe==1.1.1 # via cookiecutter, galaxy-util, jinja2
matplotlib==3.3.2 # via -r requirements/base.in, seaborn
mistune==0.8.4 # via nbconvert, schema-salad
mypy-extensions==0.4.3 # via cwltool
nbclient==0.5.0 # via nbconvert
nbconvert==6.0.3 # via jupyter, notebook
nbformat==5.0.7 # via ipywidgets, nbclient, nbconvert, notebook
nest-asyncio==1.4.0 # via nbclient
networkx==2.5 # via -r requirements/base.in, goenrichment, prov
notebook==6.1.4 # via jupyter, widgetsnbextension
numpy==1.19.2 # via -r requirements/base.in, biopython, goenrichment, matplotlib, pandas, patsy, scipy, seaborn, statsmodels
packaging==20.4 # via bleach, galaxy-util
pandas==1.1.2 # via -r requirements/base.in, goenrichment, seaborn, statsmodels
pandocfilters==1.4.2 # via nbconvert
parso==0.7.1 # via jedi
patsy==0.5.1 # via statsmodels
pdf2image==1.14.0 # via -r requirements/base.in
pexpect==4.8.0 # via ipython
pickleshare==0.7.5 # via ipython
pillow==7.2.0 # via matplotlib, pdf2image
poyo==0.5.0 # via cookiecutter
prometheus-client==0.8.0 # via notebook
prompt-toolkit==3.0.7 # via ipython, jupyter-console
prov==1.5.1 # via cwltool
psutil==5.7.2 # via cwltool
ptyprocess==0.6.0 # via pexpect, terminado
pycparser==2.20 # via cffi
pydot==1.4.1 # via cwltool
pygments==2.7.1 # via ipython, jupyter-console, jupyterlab-pygments, nbconvert, qtconsole
pyparsing==2.4.7 # via matplotlib, packaging, pydot, rdflib
pyrsistent==0.17.3 # via jsonschema
python-dateutil==2.8.1 # via arrow, jupyter-client, matplotlib, pandas, prov
python-slugify==4.0.1 # via cookiecutter
pytz==2020.1 # via pandas
pyyaml==5.3.1 # via -r requirements/base.in, bioconda2biocontainer, galaxy-util
pyzmq==19.0.2 # via jupyter-client, notebook, qtconsole
qtconsole==4.7.7 # via jupyter
qtpy==1.9.0 # via qtconsole
rdflib-jsonld==0.5.0 # via schema-salad
rdflib==4.2.2 # via cwltool, prov, rdflib-jsonld, schema-salad
repoze.lru==0.7 # via routes
requests==2.24.0 # via -r requirements/base.in, bioconda2biocontainer, cachecontrol, cookiecutter, cwltool, docker, galaxy-containers, galaxy-util, schema-salad
routes==2.4.1 # via galaxy-util
ruamel.yaml.clib==0.2.2 # via ruamel.yaml
ruamel.yaml==0.16.5 # via cwltool, schema-salad
schema-salad==7.0.20200811075006 # via cwltool
scipy==1.5.2 # via -r requirements/base.in, goenrichment, seaborn, statsmodels
seaborn==0.11.0 # via -r requirements/base.in
send2trash==1.5.0 # via notebook
shellescape==3.4.1 # via cwltool
six==1.15.0 # via argon2-cffi, bleach, cookiecutter, cycler, docker, galaxy-util, isodate, jsonschema, packaging, patsy, prov, python-dateutil, routes, websocket-client
smmap==3.0.4 # via gitdb
statsmodels==0.12.0 # via -r requirements/base.in, goenrichment
terminado==0.8.3 # via notebook
testpath==0.4.4 # via nbconvert
text-unidecode==1.3 # via python-slugify
tornado==6.0.4 # via ipykernel, jupyter-client, notebook, terminado
traitlets==5.0.4 # via ipykernel, ipython, ipywidgets, jupyter-client, jupyter-core, nbclient, nbconvert, nbformat, notebook, qtconsole
typing-extensions==3.7.4.3 # via cwltool, schema-salad
urllib3==1.25.10 # via -r requirements/base.in, requests
wcwidth==0.2.5 # via prompt-toolkit
webencodings==0.5.1 # via bleach
websocket-client==0.57.0 # via docker
widgetsnbextension==3.5.1 # via ipywidgets
xmltodict==0.12.0 # via -r requirements/base.in
zipp==3.1.0 # via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
8 changes: 8 additions & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-r base.txt

pytest
pytest-cov
sphinx-argparse
mock
sphinx-rtd-theme

33 changes: 31 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
# SHA1:6d4c9a6ffab8b2fa46a52aa17b0c622b8bdf93cd
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
-r base.txt
alabaster==0.7.12 # via sphinx
babel==2.8.0 # via sphinx
coverage==5.3 # via pytest-cov
imagesize==1.2.0 # via sphinx
iniconfig==1.0.1 # via pytest
mock==4.0.2 # via -r requirements/test.in
more-itertools==8.5.0 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pytest-cov==2.10.1 # via -r requirements/test.in
pytest==6.0.2 # via -r requirements/test.in, pytest-cov
snowballstemmer==2.0.0 # via sphinx
sphinx-argparse==0.2.5 # via -r requirements/test.in
sphinx-rtd-theme==0.5.0 # via -r requirements/test.in
sphinx==3.2.1 # via sphinx-argparse, sphinx-rtd-theme
sphinxcontrib-applehelp==1.0.2 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==1.0.3 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # via sphinx
toml==0.10.1 # via pytest

pytest~=3.7
pytest-cov~=2.5
# The following packages are considered to be unsafe in a requirements file:
# setuptools
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ def readme():
'Wand',
'xmltodict'],
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: Public Domain',
'Natural Language :: English',
'Operating System :: Unix',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering :: Bio-Informatics'
Expand Down
2 changes: 1 addition & 1 deletion src/pm4ngs/cookiecutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def execute_cookiecutter(template, config_file, sample_table, copy_rawdata):
no_input=no_input,
extra_context=extra_context['default_context'])
except FailedHookException as e:
print()
print(e)
else:
print('Sample table file {} not found.'.format(sample_table))
98 changes: 54 additions & 44 deletions src/pm4ngs/jupyterngsplugin/markdown/chipexo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

import pandas

from pm4ngs.jupyterngsplugin.markdown.utils import get_link_image
from pm4ngs.jupyterngsplugin.utils.count_lines import count_lines
from pm4ngs.jupyterngsplugin.markdown.utils import get_link_text
from pm4ngs.jupyterngsplugin.utils.count_lines import count_lines


def peak_calling_table_with_qc(factors, alignment_path, peak_calling_path, width, height):
Expand Down Expand Up @@ -57,6 +59,55 @@ def peak_calling_table_with_qc(factors, alignment_path, peak_calling_path, width
return str_msg


def meme_motif_table_condition(motif_path, c, d, width, height):
str_msg = ''
f = os.path.relpath(os.path.join(motif_path, c + '.border_pair_annot_' + d,
'summary.tsv'))
if os.path.exists(f) and os.path.getsize(f) != 0:
df = pandas.read_csv(f, sep='\t', comment='#')
if not df.empty:
n_motif = len(df)
source = df.iloc[0]['MOTIF_SOURCE']
consensus = df.iloc[0]['CONSENSUS']
w = df.iloc[0]['WIDTH']
sites = df.iloc[0]['SITES']
e_value = df.iloc[0]['E-VALUE']
lhtml = os.path.relpath(os.path.join(motif_path, c + '.border_pair_annot_' + d,
'meme-chip.html'))
str_msg += '| ' + get_link_text(lhtml, c, ' --- ')
str_msg += '|'

str_msg += " {} | {} | {} | {} | {} | {} | ".format(n_motif, source, consensus,
w, sites, e_value)
if source == 'MEME':
lpng = os.path.relpath(
os.path.join(motif_path, c + '.border_pair_annot_' + d, 'meme_out',
'logo1.png'))
if os.path.exists(lpng) and os.path.getsize(lpng) != 0:
str_msg += get_link_image(lpng, width, height, ' --- ')
str_msg += ' |'
else:
str_msg += ' --- |'
elif source == 'DREME':
lout = os.path.relpath(os.path.join(motif_path, c
+ '.border_pair_annot_'
+ d,
'dreme_out'))
dreme_files = [f for ds, dr, files in os.walk(lout)
for f in files if f.startswith('m01nc')]
for dm in dreme_files:
loutfile = os.path.relpath(
os.path.join(motif_path, c + '.border_pair_annot_' + d,
'dreme_out', dm))
if os.path.exists(loutfile) and os.path.getsize(loutfile) != 0:
str_msg += get_link_image(loutfile, width, height, ' --- ')
str_msg += ' |'
else:
str_msg += ' --- |'
str_msg += '\n'
return str_msg


def meme_motif_table(factors, motif_path, width, height):
"""
Create a table for the MEME motif find results
Expand All @@ -68,7 +119,7 @@ def meme_motif_table(factors, motif_path, width, height):
"""
conditions = factors['condition'].unique()
memedbs = []
dirs = [ d for d in os.listdir(motif_path) if os.path.isdir(os.path.join(motif_path, d))]
dirs = [d for d in os.listdir(motif_path) if os.path.isdir(os.path.join(motif_path, d))]
for d in dirs:
if '.border_pair_annot_' in d:
d = d.split('.border_pair_annot_')[1]
Expand All @@ -82,47 +133,6 @@ def meme_motif_table(factors, motif_path, width, height):
str_msg += "| 1st motif<br>E-Value | 1st motif |\n"
str_msg += "| --- | --- | --- | --- | --- | --- | --- | --- |\n"
for c in conditions:
f = os.path.relpath(os.path.join(motif_path, c + '.border_pair_annot_' + d,
'summary.tsv'))
if os.path.exists(f) and os.path.getsize(f) != 0:
df = pandas.read_csv(f, sep='\t', comment='#')
if not df.empty:
n_motif = len(df)
source = df.iloc[0]['MOTIF_SOURCE']
consensus = df.iloc[0]['CONSENSUS']
w = df.iloc[0]['WIDTH']
sites = df.iloc[0]['SITES']
e_value = df.iloc[0]['E-VALUE']
lhtml = os.path.relpath(os.path.join(motif_path, c + '.border_pair_annot_' + d,
'meme-chip.html'))
str_msg += '| ' + get_link_text(lhtml, c, ' --- ')
str_msg += '|'

str_msg += " {} | {} | {} | {} | {} | {} | ".format(n_motif, source, consensus,
w, sites, e_value)
if source == 'MEME':
lpng = os.path.relpath(
os.path.join(motif_path, c + '.border_pair_annot_' + d, 'meme_out',
'logo1.png'))
if os.path.exists(lpng) and os.path.getsize(lpng) != 0:
str_msg += get_link_image(lpng, width, height, ' --- ')
str_msg += ' |'
else:
str_msg += ' --- |'
elif source == 'DREME':
lout = os.path.relpath(os.path.join(motif_path, c + '.border_pair_annot_' + d,
'dreme_out'))
dreme_files = [f for ds, dr, files in os.walk(lout)
for f in files if f.startswith('m01nc')]
for dm in dreme_files:
loutfile = os.path.relpath(
os.path.join(motif_path, c + '.border_pair_annot_' + d,
'dreme_out', dm))
if os.path.exists(loutfile) and os.path.getsize(loutfile) != 0:
str_msg += get_link_image(loutfile, width, height, ' --- ')
str_msg += ' |'
else:
str_msg += ' --- |'
str_msg += '\n'
str_msg += meme_motif_table_condition(motif_path, c, d, width, height)
str_msg += '\n\n\n'
return str_msg
Loading

0 comments on commit dfe5396

Please sign in to comment.