Skip to content

Commit

Permalink
Merge pull request #70 from databio/dev
Browse files Browse the repository at this point in the history
minor update for pypi
  • Loading branch information
nsheff committed Feb 27, 2018
2 parents 3097266 + fb276d4 commit 140b7c6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Ignore Python build-related directories.
.eggs/
build/
dist/

# Keep everything in data.
!metadata/*
Expand All @@ -30,6 +31,7 @@ pipeline_output/
!*README.md*
!*.rst
!*.xlsx
!*.in

# Make sure to track .gitignore.
!.gitignore
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include requirements/*
include README.md
include logo_pypiper.svg
3 changes: 3 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changelog
******************************
- **v0.7.1** (*2018-02-27*):

- Package cleanup for Pypi.

- **v0.7.0** (*2017-12-12*):

Expand Down
2 changes: 1 addition & 1 deletion pypiper/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.0"
__version__ = "0.7.1"
4 changes: 2 additions & 2 deletions pypiper/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def checkprint(self, cmd, shell="guess", nofail=False, errmsg=None):

try:
return subprocess.check_output(cmd, shell=shell)
except (OSError, subprocess.CalledProcessError) as e:
except Exception as e:
self._triage_error(e, nofail, errmsg)


Expand Down Expand Up @@ -863,7 +863,7 @@ def callprint(self, cmd, shell="guess", nofail=False, container=None, lock_name=
if p.returncode != 0:
raise OSError("Subprocess returned nonzero result.")

except (OSError, subprocess.CalledProcessError) as e:
except Exception as e:
self._triage_error(e, nofail, errmsg)

return [returncode, local_maxmem]
Expand Down
4 changes: 2 additions & 2 deletions pypiper/ngstk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ def macs2_call_peaks(
cmd += " -c {0}".format(control_bams if type(control_bams) is str else " ".join(control_bams))

if paired:
cmd += "-f BAMPE "
cmd += " -f BAMPE "

# Additional settings based on whether the marks is associated with
# broad peaks
Expand Down Expand Up @@ -1604,7 +1604,7 @@ def zinba_call_peaks(self, treatment_bed, control_bed, cpus, tagmented=False):

def filter_peaks_mappability(self, peaks, alignability, filtered_peaks):
cmd = self.tools.bedtools + " intersect -wa -u -f 1"
cmd += " -a {0} -b {1} > {2} ".format(peaks, alignability, filteredPeaks)
cmd += " -a {0} -b {1} > {2} ".format(peaks, alignability, filtered_peaks)
return cmd

def homer_find_motifs(self, peak_file, genome, output_dir, size=150, length="8,10,12,14,16", n_motifs=12):
Expand Down
51 changes: 50 additions & 1 deletion pypiper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# What to export/attach to pypiper package namespace.
# Conceptually, reserve this for functions expected to be used in other
# packages, and import from utils within pypiper for other functions.
__all__ = ["add_pypiper_args", "build_command"]
__all__ = ["add_pypiper_args", "build_command", "get_parameter"]



Expand Down Expand Up @@ -259,6 +259,55 @@ def flag_name(status):



def get_parameter(param, param_pools, on_missing=None, error=True):
"""
Get the value for a particular parameter.
Other than the parameter name itself, the other critical
:param str param: Name of parameter for which to determine/fetch value.
:param Sequence[Mapping[str, object]] param_pools: Ordered (priority)
collection of mapping from parameter name to value; this should be
ordered according to descending priority.
:param object | function(str) -> object on_missing: default value or
action to take if the requested parameter is missing from all of the
pools. If a callable, it should return a value when passed the
requested parameter as the one and only argument.
:param bool error: Whether to raise an error if the requested parameter
is not mapped to a value AND there's no value or strategy provided
with 'on_missing' with which to handle the case of a request for an
unmapped parameter.
:return object: Value to which the requested parameter first mapped in
the (descending) priority collection of parameter 'pools,' or
a value explicitly defined or derived with 'on_missing.'
:raise KeyError: If the requested parameter is unmapped in all of the
provided pools, and the argument to the 'error' parameter evaluates
to True.
"""

# Search for the requested parameter.
for pool in param_pools:
if param in pool:
return pool[param]

# Raise error if unfound and no strategy or value is provided or handling
# unmapped parameter requests.
if error and on_missing is None:
raise KeyError("Unmapped parameter: '{}'".format(param))

# Use the value or strategy for handling unmapped parameter case.
try:
return on_missing(param)
except TypeError:
if hasattr(on_missing, "__call__"):
raise TypeError(
"Any callable passed as the action to take when a requested "
"parameter is missing should accept that parameter and return "
"a value.")
return on_missing



def is_in_file_tree(fpath, folder):
"""
Determine whether a file is in a folder.
Expand Down
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ def read_reqs_file(reqs_name):
# Dev installation is full user + test.
addl_reqs["dev"] = list(set(test_reqs + addl_reqs["all"]))

# Handle the pypi README formatting.
try:
import pypandoc
long_description = pypandoc.convert_file('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()

setup(
name='pypiper',
packages=['pypiper'],
version=version,
description='A lightweight python toolkit for gluing together restartable, robust command line pipelines',
description=long_description,
author='Nathan Sheffield, Johanna Klughammer, Andre Rendeiro',
author_email='nathan@code.databio.org, jklughammer@cemm.oeaw.ac.at, arendeiro@cemm.oeaw.ac.at',
url='https://github.com/epigen/pypiper/',
url='https://github.com/databio/pypiper/',
test_suite="tests", # python setup.py test
tests_require=test_reqs, # Test-specific package dependencies
# Extra package if doing `python setup.py test`
Expand Down

0 comments on commit 140b7c6

Please sign in to comment.