repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
recurly/recurly-client-python | recurly/resource.py | Resource.http_request | def http_request(cls, url, method='GET', body=None, headers=None):
"""Make an HTTP request with the given method to the given URL,
returning the resulting `http_client.HTTPResponse` instance.
If the `body` argument is a `Resource` instance, it is serialized
to XML by calling its `to_ele... | python | def http_request(cls, url, method='GET', body=None, headers=None):
"""Make an HTTP request with the given method to the given URL,
returning the resulting `http_client.HTTPResponse` instance.
If the `body` argument is a `Resource` instance, it is serialized
to XML by calling its `to_ele... | Make an HTTP request with the given method to the given URL,
returning the resulting `http_client.HTTPResponse` instance.
If the `body` argument is a `Resource` instance, it is serialized
to XML by calling its `to_element()` method before submitting it.
Requests are authenticated per th... | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L222-L306 |
recurly/recurly-client-python | recurly/resource.py | Resource.headers_as_dict | def headers_as_dict(cls, resp):
"""Turns an array of response headers into a dictionary"""
if six.PY2:
pairs = [header.split(':', 1) for header in resp.msg.headers]
return dict([(k, v.strip()) for k, v in pairs])
else:
return dict([(k, v.strip()) for k, v in r... | python | def headers_as_dict(cls, resp):
"""Turns an array of response headers into a dictionary"""
if six.PY2:
pairs = [header.split(':', 1) for header in resp.msg.headers]
return dict([(k, v.strip()) for k, v in pairs])
else:
return dict([(k, v.strip()) for k, v in r... | Turns an array of response headers into a dictionary | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L309-L315 |
recurly/recurly-client-python | recurly/resource.py | Resource.as_log_output | def as_log_output(self):
"""Returns an XML string containing a serialization of this
instance suitable for logging.
Attributes named in the instance's `sensitive_attributes` are
redacted.
"""
elem = self.to_element()
for attrname in self.sensitive_attributes:
... | python | def as_log_output(self):
"""Returns an XML string containing a serialization of this
instance suitable for logging.
Attributes named in the instance's `sensitive_attributes` are
redacted.
"""
elem = self.to_element()
for attrname in self.sensitive_attributes:
... | Returns an XML string containing a serialization of this
instance suitable for logging.
Attributes named in the instance's `sensitive_attributes` are
redacted. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L317-L329 |
recurly/recurly-client-python | recurly/resource.py | Resource.get | def get(cls, uuid):
"""Return a `Resource` instance of this class identified by
the given code or UUID.
Only `Resource` classes with specified `member_path` attributes
can be directly requested with this method.
"""
if not uuid:
raise ValueError("get must ha... | python | def get(cls, uuid):
"""Return a `Resource` instance of this class identified by
the given code or UUID.
Only `Resource` classes with specified `member_path` attributes
can be directly requested with this method.
"""
if not uuid:
raise ValueError("get must ha... | Return a `Resource` instance of this class identified by
the given code or UUID.
Only `Resource` classes with specified `member_path` attributes
can be directly requested with this method. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L347-L360 |
recurly/recurly-client-python | recurly/resource.py | Resource.headers_for_url | def headers_for_url(cls, url):
"""Return the headers only for the given URL as a dict"""
response = cls.http_request(url, method='HEAD')
if response.status != 200:
cls.raise_http_error(response)
return Resource.headers_as_dict(response) | python | def headers_for_url(cls, url):
"""Return the headers only for the given URL as a dict"""
response = cls.http_request(url, method='HEAD')
if response.status != 200:
cls.raise_http_error(response)
return Resource.headers_as_dict(response) | Return the headers only for the given URL as a dict | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L363-L369 |
recurly/recurly-client-python | recurly/resource.py | Resource.element_for_url | def element_for_url(cls, url):
"""Return the resource at the given URL, as a
(`http_client.HTTPResponse`, `xml.etree.ElementTree.Element`) tuple
resulting from a ``GET`` request to that URL."""
response = cls.http_request(url)
if response.status != 200:
cls.raise_http... | python | def element_for_url(cls, url):
"""Return the resource at the given URL, as a
(`http_client.HTTPResponse`, `xml.etree.ElementTree.Element`) tuple
resulting from a ``GET`` request to that URL."""
response = cls.http_request(url)
if response.status != 200:
cls.raise_http... | Return the resource at the given URL, as a
(`http_client.HTTPResponse`, `xml.etree.ElementTree.Element`) tuple
resulting from a ``GET`` request to that URL. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L372-L386 |
recurly/recurly-client-python | recurly/resource.py | Resource.value_for_element | def value_for_element(cls, elem):
"""Deserialize the given XML `Element` into its representative
value.
Depending on the content of the element, the returned value may be:
* a string, integer, or boolean value
* a `datetime.datetime` instance
* a list of `Resource` insta... | python | def value_for_element(cls, elem):
"""Deserialize the given XML `Element` into its representative
value.
Depending on the content of the element, the returned value may be:
* a string, integer, or boolean value
* a `datetime.datetime` instance
* a list of `Resource` insta... | Deserialize the given XML `Element` into its representative
value.
Depending on the content of the element, the returned value may be:
* a string, integer, or boolean value
* a `datetime.datetime` instance
* a list of `Resource` instances
* a single `Resource` instance
... | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L397-L454 |
recurly/recurly-client-python | recurly/resource.py | Resource.element_for_value | def element_for_value(cls, attrname, value):
"""Serialize the given value into an XML `Element` with the
given tag name, returning it.
The value argument may be:
* a `Resource` instance
* a `Money` instance
* a `datetime.datetime` instance
* a string, integer, or... | python | def element_for_value(cls, attrname, value):
"""Serialize the given value into an XML `Element` with the
given tag name, returning it.
The value argument may be:
* a `Resource` instance
* a `Money` instance
* a `datetime.datetime` instance
* a string, integer, or... | Serialize the given value into an XML `Element` with the
given tag name, returning it.
The value argument may be:
* a `Resource` instance
* a `Money` instance
* a `datetime.datetime` instance
* a string, integer, or boolean value
* ``None``
* a list or tu... | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L457-L501 |
recurly/recurly-client-python | recurly/resource.py | Resource.update_from_element | def update_from_element(self, elem):
"""Reset this `Resource` instance to represent the values in
the given XML element."""
self._elem = elem
for attrname in self.attributes:
try:
delattr(self, attrname)
except AttributeError:
pass... | python | def update_from_element(self, elem):
"""Reset this `Resource` instance to represent the values in
the given XML element."""
self._elem = elem
for attrname in self.attributes:
try:
delattr(self, attrname)
except AttributeError:
pass... | Reset this `Resource` instance to represent the values in
the given XML element. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L514-L529 |
recurly/recurly-client-python | recurly/resource.py | Resource.all | def all(cls, **kwargs):
"""Return a `Page` of instances of this `Resource` class from
its general collection endpoint.
Only `Resource` classes with specified `collection_path`
endpoints can be requested with this method. Any provided
keyword arguments are passed to the API endpo... | python | def all(cls, **kwargs):
"""Return a `Page` of instances of this `Resource` class from
its general collection endpoint.
Only `Resource` classes with specified `collection_path`
endpoints can be requested with this method. Any provided
keyword arguments are passed to the API endpo... | Return a `Page` of instances of this `Resource` class from
its general collection endpoint.
Only `Resource` classes with specified `collection_path`
endpoints can be requested with this method. Any provided
keyword arguments are passed to the API endpoint as query
parameters. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L617-L630 |
recurly/recurly-client-python | recurly/resource.py | Resource.count | def count(cls, **kwargs):
"""Return a count of server side resources given
filtering arguments in kwargs.
"""
url = recurly.base_uri() + cls.collection_path
if kwargs:
url = '%s?%s' % (url, urlencode_params(kwargs))
return Page.count_for_url(url) | python | def count(cls, **kwargs):
"""Return a count of server side resources given
filtering arguments in kwargs.
"""
url = recurly.base_uri() + cls.collection_path
if kwargs:
url = '%s?%s' % (url, urlencode_params(kwargs))
return Page.count_for_url(url) | Return a count of server side resources given
filtering arguments in kwargs. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L633-L640 |
recurly/recurly-client-python | recurly/resource.py | Resource.put | def put(self, url):
"""Sends this `Resource` instance to the service with a
``PUT`` request to the given URL."""
response = self.http_request(url, 'PUT', self, {'Content-Type': 'application/xml; charset=utf-8'})
if response.status != 200:
self.raise_http_error(response)
... | python | def put(self, url):
"""Sends this `Resource` instance to the service with a
``PUT`` request to the given URL."""
response = self.http_request(url, 'PUT', self, {'Content-Type': 'application/xml; charset=utf-8'})
if response.status != 200:
self.raise_http_error(response)
... | Sends this `Resource` instance to the service with a
``PUT`` request to the given URL. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L662-L671 |
recurly/recurly-client-python | recurly/resource.py | Resource.post | def post(self, url, body=None):
"""Sends this `Resource` instance to the service with a
``POST`` request to the given URL. Takes an optional body"""
response = self.http_request(url, 'POST', body or self, {'Content-Type': 'application/xml; charset=utf-8'})
if response.status not in (200,... | python | def post(self, url, body=None):
"""Sends this `Resource` instance to the service with a
``POST`` request to the given URL. Takes an optional body"""
response = self.http_request(url, 'POST', body or self, {'Content-Type': 'application/xml; charset=utf-8'})
if response.status not in (200,... | Sends this `Resource` instance to the service with a
``POST`` request to the given URL. Takes an optional body | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L673-L685 |
recurly/recurly-client-python | recurly/resource.py | Resource.delete | def delete(self):
"""Submits a deletion request for this `Resource` instance as
a ``DELETE`` request to its URL."""
response = self.http_request(self._url, 'DELETE')
if response.status != 204:
self.raise_http_error(response) | python | def delete(self):
"""Submits a deletion request for this `Resource` instance as
a ``DELETE`` request to its URL."""
response = self.http_request(self._url, 'DELETE')
if response.status != 204:
self.raise_http_error(response) | Submits a deletion request for this `Resource` instance as
a ``DELETE`` request to its URL. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L687-L692 |
recurly/recurly-client-python | recurly/resource.py | Resource.raise_http_error | def raise_http_error(cls, response):
"""Raise a `ResponseError` of the appropriate subclass in
reaction to the given `http_client.HTTPResponse`."""
response_xml = response.read()
logging.getLogger('recurly.http.response').debug(response_xml)
exc_class = recurly.errors.error_class... | python | def raise_http_error(cls, response):
"""Raise a `ResponseError` of the appropriate subclass in
reaction to the given `http_client.HTTPResponse`."""
response_xml = response.read()
logging.getLogger('recurly.http.response').debug(response_xml)
exc_class = recurly.errors.error_class... | Raise a `ResponseError` of the appropriate subclass in
reaction to the given `http_client.HTTPResponse`. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L695-L701 |
recurly/recurly-client-python | recurly/resource.py | Resource.to_element | def to_element(self, root_name=None):
"""Serialize this `Resource` instance to an XML element."""
if not root_name:
root_name = self.nodename
elem = ElementTreeBuilder.Element(root_name)
for attrname in self.serializable_attributes():
# Only use values that have b... | python | def to_element(self, root_name=None):
"""Serialize this `Resource` instance to an XML element."""
if not root_name:
root_name = self.nodename
elem = ElementTreeBuilder.Element(root_name)
for attrname in self.serializable_attributes():
# Only use values that have b... | Serialize this `Resource` instance to an XML element. | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L703-L724 |
sigsep/sigsep-mus-eval | museval/metrics.py | bss_eval | def bss_eval(reference_sources, estimated_sources,
window=2 * 44100, hop=1.5 * 44100,
compute_permutation=False,
filters_len=512,
framewise_filters=False,
bsseval_sources_version=False
):
"""BSS_EVAL version 4.
Measurement of the sep... | python | def bss_eval(reference_sources, estimated_sources,
window=2 * 44100, hop=1.5 * 44100,
compute_permutation=False,
filters_len=512,
framewise_filters=False,
bsseval_sources_version=False
):
"""BSS_EVAL version 4.
Measurement of the sep... | BSS_EVAL version 4.
Measurement of the separation quality for estimated source signals
in terms of source to distortion, interference and artifacts ratios,
(SDR, SIR, SAR) as well as the image to spatial ratio (ISR), as defined
in [#vincent2005bssevalv3]_.
The metrics are computed on a framewise b... | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L127-L349 |
sigsep/sigsep-mus-eval | museval/metrics.py | bss_eval_sources | def bss_eval_sources(reference_sources, estimated_sources,
compute_permutation=True):
"""
BSS Eval v3 bss_eval_sources
Wrapper to ``bss_eval`` with the right parameters.
The call to this function is not recommended. See the description for the
``bsseval_sources`` parameter of `... | python | def bss_eval_sources(reference_sources, estimated_sources,
compute_permutation=True):
"""
BSS Eval v3 bss_eval_sources
Wrapper to ``bss_eval`` with the right parameters.
The call to this function is not recommended. See the description for the
``bsseval_sources`` parameter of `... | BSS Eval v3 bss_eval_sources
Wrapper to ``bss_eval`` with the right parameters.
The call to this function is not recommended. See the description for the
``bsseval_sources`` parameter of ``bss_eval``. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L352-L370 |
sigsep/sigsep-mus-eval | museval/metrics.py | bss_eval_sources_framewise | def bss_eval_sources_framewise(reference_sources, estimated_sources,
window=30 * 44100, hop=15 * 44100,
compute_permutation=False):
"""
BSS Eval v3 bss_eval_sources_framewise
Wrapper to ``bss_eval`` with the right parameters.
The call to thi... | python | def bss_eval_sources_framewise(reference_sources, estimated_sources,
window=30 * 44100, hop=15 * 44100,
compute_permutation=False):
"""
BSS Eval v3 bss_eval_sources_framewise
Wrapper to ``bss_eval`` with the right parameters.
The call to thi... | BSS Eval v3 bss_eval_sources_framewise
Wrapper to ``bss_eval`` with the right parameters.
The call to this function is not recommended. See the description for the
``bsseval_sources`` parameter of ``bss_eval``. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L373-L391 |
sigsep/sigsep-mus-eval | museval/metrics.py | bss_eval_images | def bss_eval_images(reference_sources, estimated_sources,
compute_permutation=True):
"""
BSS Eval v3 bss_eval_images
Wrapper to ``bss_eval`` with the right parameters.
"""
return bss_eval(
reference_sources, estimated_sources,
window=np.inf, hop=np.inf,
... | python | def bss_eval_images(reference_sources, estimated_sources,
compute_permutation=True):
"""
BSS Eval v3 bss_eval_images
Wrapper to ``bss_eval`` with the right parameters.
"""
return bss_eval(
reference_sources, estimated_sources,
window=np.inf, hop=np.inf,
... | BSS Eval v3 bss_eval_images
Wrapper to ``bss_eval`` with the right parameters. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L394-L407 |
sigsep/sigsep-mus-eval | museval/metrics.py | bss_eval_images_framewise | def bss_eval_images_framewise(reference_sources, estimated_sources,
window=30 * 44100, hop=15 * 44100,
compute_permutation=False):
"""
BSS Eval v3 bss_eval_images_framewise
Framewise computation of bss_eval_images.
Wrapper to ``bss_eval`` with... | python | def bss_eval_images_framewise(reference_sources, estimated_sources,
window=30 * 44100, hop=15 * 44100,
compute_permutation=False):
"""
BSS Eval v3 bss_eval_images_framewise
Framewise computation of bss_eval_images.
Wrapper to ``bss_eval`` with... | BSS Eval v3 bss_eval_images_framewise
Framewise computation of bss_eval_images.
Wrapper to ``bss_eval`` with the right parameters. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L410-L426 |
sigsep/sigsep-mus-eval | museval/metrics.py | _bss_decomp_mtifilt | def _bss_decomp_mtifilt(reference_sources, estimated_source, j, C, Cj):
"""Decomposition of an estimated source image into four components
representing respectively the true source image, spatial (or filtering)
distortion, interference and artifacts, derived from the true source
images using multichanne... | python | def _bss_decomp_mtifilt(reference_sources, estimated_source, j, C, Cj):
"""Decomposition of an estimated source image into four components
representing respectively the true source image, spatial (or filtering)
distortion, interference and artifacts, derived from the true source
images using multichanne... | Decomposition of an estimated source image into four components
representing respectively the true source image, spatial (or filtering)
distortion, interference and artifacts, derived from the true source
images using multichannel time-invariant filters. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L469-L485 |
sigsep/sigsep-mus-eval | museval/metrics.py | _zeropad | def _zeropad(sig, N, axis=0):
"""pads with N zeros at the end of the signal, along given axis"""
# ensures concatenation dimension is the first
sig = np.moveaxis(sig, axis, 0)
# zero pad
out = np.zeros((sig.shape[0] + N,) + sig.shape[1:])
out[:sig.shape[0], ...] = sig
# put back axis in plac... | python | def _zeropad(sig, N, axis=0):
"""pads with N zeros at the end of the signal, along given axis"""
# ensures concatenation dimension is the first
sig = np.moveaxis(sig, axis, 0)
# zero pad
out = np.zeros((sig.shape[0] + N,) + sig.shape[1:])
out[:sig.shape[0], ...] = sig
# put back axis in plac... | pads with N zeros at the end of the signal, along given axis | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L488-L497 |
sigsep/sigsep-mus-eval | museval/metrics.py | _reshape_G | def _reshape_G(G):
"""From a correlation matrix of size
nsrc X nsrc X nchan X nchan X filters_len X filters_len,
creates a new one of size
nsrc*nchan*filters_len X nsrc*nchan*filters_len"""
G = np.moveaxis(G, (1, 3), (3, 4))
(nsrc, nchan, filters_len) = G.shape[0:3]
G = np.reshape(
G... | python | def _reshape_G(G):
"""From a correlation matrix of size
nsrc X nsrc X nchan X nchan X filters_len X filters_len,
creates a new one of size
nsrc*nchan*filters_len X nsrc*nchan*filters_len"""
G = np.moveaxis(G, (1, 3), (3, 4))
(nsrc, nchan, filters_len) = G.shape[0:3]
G = np.reshape(
G... | From a correlation matrix of size
nsrc X nsrc X nchan X nchan X filters_len X filters_len,
creates a new one of size
nsrc*nchan*filters_len X nsrc*nchan*filters_len | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L500-L510 |
sigsep/sigsep-mus-eval | museval/metrics.py | _compute_reference_correlations | def _compute_reference_correlations(reference_sources, filters_len):
"""Compute the inner products between delayed versions of reference_sources
reference is nsrc X nsamp X nchan.
Returns
* G, matrix : nsrc X nsrc X nchan X nchan X filters_len X filters_len
* sf, reference spectra: nsrc X nchan X fi... | python | def _compute_reference_correlations(reference_sources, filters_len):
"""Compute the inner products between delayed versions of reference_sources
reference is nsrc X nsamp X nchan.
Returns
* G, matrix : nsrc X nsrc X nchan X nchan X filters_len X filters_len
* sf, reference spectra: nsrc X nchan X fi... | Compute the inner products between delayed versions of reference_sources
reference is nsrc X nsamp X nchan.
Returns
* G, matrix : nsrc X nsrc X nchan X nchan X filters_len X filters_len
* sf, reference spectra: nsrc X nchan X filters_len | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L513-L546 |
sigsep/sigsep-mus-eval | museval/metrics.py | _compute_projection_filters | def _compute_projection_filters(G, sf, estimated_source):
"""Least-squares projection of estimated source on the subspace spanned by
delayed versions of reference sources, with delays between 0 and
filters_len-1
"""
# epsilon
eps = np.finfo(np.float).eps
# shapes
(nsampl, nchan) = estim... | python | def _compute_projection_filters(G, sf, estimated_source):
"""Least-squares projection of estimated source on the subspace spanned by
delayed versions of reference sources, with delays between 0 and
filters_len-1
"""
# epsilon
eps = np.finfo(np.float).eps
# shapes
(nsampl, nchan) = estim... | Least-squares projection of estimated source on the subspace spanned by
delayed versions of reference sources, with delays between 0 and
filters_len-1 | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L549-L602 |
sigsep/sigsep-mus-eval | museval/metrics.py | _project | def _project(reference_sources, C):
"""Project images using pre-computed filters C
reference_sources are nsrc X nsampl X nchan
C is nsrc X nchan X filters_len X nchan
"""
# shapes: ensure that input is 3d (comprising the source index)
if len(reference_sources.shape) == 2:
reference_sourc... | python | def _project(reference_sources, C):
"""Project images using pre-computed filters C
reference_sources are nsrc X nsampl X nchan
C is nsrc X nchan X filters_len X nchan
"""
# shapes: ensure that input is 3d (comprising the source index)
if len(reference_sources.shape) == 2:
reference_sourc... | Project images using pre-computed filters C
reference_sources are nsrc X nsampl X nchan
C is nsrc X nchan X filters_len X nchan | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L605-L629 |
sigsep/sigsep-mus-eval | museval/metrics.py | _bss_crit | def _bss_crit(s_true, e_spat, e_interf, e_artif, bsseval_sources_version):
"""Measurement of the separation quality for a given source in terms of
filtered true source, interference and artifacts.
"""
# energy ratios
if bsseval_sources_version:
s_filt = s_true + e_spat
energy_s_filt... | python | def _bss_crit(s_true, e_spat, e_interf, e_artif, bsseval_sources_version):
"""Measurement of the separation quality for a given source in terms of
filtered true source, interference and artifacts.
"""
# energy ratios
if bsseval_sources_version:
s_filt = s_true + e_spat
energy_s_filt... | Measurement of the separation quality for a given source in terms of
filtered true source, interference and artifacts. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L632-L656 |
sigsep/sigsep-mus-eval | museval/metrics.py | _safe_db | def _safe_db(num, den):
"""Properly handle the potential +Inf db SIR instead of raising a
RuntimeWarning.
"""
if den == 0:
return np.inf
return 10 * np.log10(num / den) | python | def _safe_db(num, den):
"""Properly handle the potential +Inf db SIR instead of raising a
RuntimeWarning.
"""
if den == 0:
return np.inf
return 10 * np.log10(num / den) | Properly handle the potential +Inf db SIR instead of raising a
RuntimeWarning. | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L659-L665 |
recurly/recurly-client-python | recurly/link_header.py | parse_link_value | def parse_link_value(instr):
"""
Given a link-value (i.e., after separating the header-value on commas),
return a dictionary whose keys are link URLs and values are dictionaries
of the parameters for their associated links.
Note that internationalised parameters (e.g., title*) are
NOT per... | python | def parse_link_value(instr):
"""
Given a link-value (i.e., after separating the header-value on commas),
return a dictionary whose keys are link URLs and values are dictionaries
of the parameters for their associated links.
Note that internationalised parameters (e.g., title*) are
NOT per... | Given a link-value (i.e., after separating the header-value on commas),
return a dictionary whose keys are link URLs and values are dictionaries
of the parameters for their associated links.
Note that internationalised parameters (e.g., title*) are
NOT percent-decoded.
Also, only the las... | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/link_header.py#L58-L89 |
mcs07/CIRpy | cirpy.py | construct_api_url | def construct_api_url(input, representation, resolvers=None, get3d=False, tautomers=False, xml=True, **kwargs):
"""Return the URL for the desired API endpoint.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(str) resolvers: (Op... | python | def construct_api_url(input, representation, resolvers=None, get3d=False, tautomers=False, xml=True, **kwargs):
"""Return the URL for the desired API endpoint.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(str) resolvers: (Op... | Return the URL for the desired API endpoint.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(str) resolvers: (Optional) Ordered list of resolvers to use
:param bool get3d: (Optional) Whether to return 3D coordinates (where appl... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L49-L77 |
mcs07/CIRpy | cirpy.py | request | def request(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs):
"""Make a request to CIR and return the XML response.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ord... | python | def request(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs):
"""Make a request to CIR and return the XML response.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ord... | Make a request to CIR and return the XML response.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ordered list of resolvers to use
:param bool get3d: (Optional) Whether to return 3D coordinates (w... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L80-L96 |
mcs07/CIRpy | cirpy.py | query | def query(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs):
"""Get all results for resolving input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) re... | python | def query(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs):
"""Get all results for resolving input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) re... | Get all results for resolving input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ordered list of resolvers to use
:param bool get3d: (Optional) Whether to... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L149-L176 |
mcs07/CIRpy | cirpy.py | resolve | def resolve(input, representation, resolvers=None, get3d=False, **kwargs):
"""Resolve input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ordered list of r... | python | def resolve(input, representation, resolvers=None, get3d=False, **kwargs):
"""Resolve input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ordered list of r... | Resolve input to the specified output representation.
:param string input: Chemical identifier to resolve
:param string representation: Desired output representation
:param list(string) resolvers: (Optional) Ordered list of resolvers to use
:param bool get3d: (Optional) Whether to return 3D coordinates... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L179-L194 |
mcs07/CIRpy | cirpy.py | resolve_image | def resolve_image(input, resolvers=None, fmt='png', width=300, height=300, frame=False, crop=None, bgcolor=None,
atomcolor=None, hcolor=None, bondcolor=None, framecolor=None, symbolfontsize=11, linewidth=2,
hsymbol='special', csymbol='special', stereolabels=False, stereowedges=True, ... | python | def resolve_image(input, resolvers=None, fmt='png', width=300, height=300, frame=False, crop=None, bgcolor=None,
atomcolor=None, hcolor=None, bondcolor=None, framecolor=None, symbolfontsize=11, linewidth=2,
hsymbol='special', csymbol='special', stereolabels=False, stereowedges=True, ... | Resolve input to a 2D image depiction.
:param string input: Chemical identifier to resolve
:param list(string) resolvers: (Optional) Ordered list of resolvers to use
:param string fmt: (Optional) gif or png image format (default png)
:param int width: (Optional) Image width in pixels (default 300)
... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L197-L251 |
mcs07/CIRpy | cirpy.py | download | def download(input, filename, representation, overwrite=False, resolvers=None, get3d=False, **kwargs):
"""Convenience function to save a CIR response as a file.
This is just a simple wrapper around the resolve function.
:param string input: Chemical identifier to resolve
:param string filename: File p... | python | def download(input, filename, representation, overwrite=False, resolvers=None, get3d=False, **kwargs):
"""Convenience function to save a CIR response as a file.
This is just a simple wrapper around the resolve function.
:param string input: Chemical identifier to resolve
:param string filename: File p... | Convenience function to save a CIR response as a file.
This is just a simple wrapper around the resolve function.
:param string input: Chemical identifier to resolve
:param string filename: File path to save to
:param string representation: Desired output representation
:param bool overwrite: (Opt... | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L259-L286 |
mcs07/CIRpy | cirpy.py | Molecule.image_url | def image_url(self):
"""URL of a GIF image."""
return construct_api_url(self.input, 'image', self.resolvers, False, self.get3d, False, **self.kwargs) | python | def image_url(self):
"""URL of a GIF image."""
return construct_api_url(self.input, 'image', self.resolvers, False, self.get3d, False, **self.kwargs) | URL of a GIF image. | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L432-L434 |
mcs07/CIRpy | cirpy.py | Molecule.twirl_url | def twirl_url(self):
"""Url of a TwirlyMol 3D viewer."""
return construct_api_url(self.input, 'twirl', self.resolvers, False, self.get3d, False, **self.kwargs) | python | def twirl_url(self):
"""Url of a TwirlyMol 3D viewer."""
return construct_api_url(self.input, 'twirl', self.resolvers, False, self.get3d, False, **self.kwargs) | Url of a TwirlyMol 3D viewer. | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L437-L439 |
mcs07/CIRpy | cirpy.py | Molecule.download | def download(self, filename, representation, overwrite=False):
"""Download the resolved structure as a file.
:param string filename: File path to save to
:param string representation: Desired output representation
:param bool overwrite: (Optional) Whether to allow overwriting of an exis... | python | def download(self, filename, representation, overwrite=False):
"""Download the resolved structure as a file.
:param string filename: File path to save to
:param string representation: Desired output representation
:param bool overwrite: (Optional) Whether to allow overwriting of an exis... | Download the resolved structure as a file.
:param string filename: File path to save to
:param string representation: Desired output representation
:param bool overwrite: (Optional) Whether to allow overwriting of an existing file | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L441-L448 |
panoplyio/panoply-python-sdk | panoply/datasource.py | validate_token | def validate_token(refresh_url, exceptions=(), callback=None,
access_key='access_token', refresh_key='refresh_token'):
''' a decorator used to validate the access_token for oauth based
data sources.
This decorator should be used on every method in the data source that
fetches data fro... | python | def validate_token(refresh_url, exceptions=(), callback=None,
access_key='access_token', refresh_key='refresh_token'):
''' a decorator used to validate the access_token for oauth based
data sources.
This decorator should be used on every method in the data source that
fetches data fro... | a decorator used to validate the access_token for oauth based
data sources.
This decorator should be used on every method in the data source that
fetches data from the oauth controlled resource, and that relies on a
valid access_token in order to operate properly.
If the token is valid, the normal f... | https://github.com/panoplyio/panoply-python-sdk/blob/f73aba40ad8f6c116c93ec4f43364be898ec91aa/panoply/datasource.py#L54-L135 |
panoplyio/panoply-python-sdk | panoply/datasource.py | DataSource.log | def log(self, *msgs):
""" Log a message """
if 'logger' in self.options:
self.options['logger'](msgs)
else:
print(msgs) | python | def log(self, *msgs):
""" Log a message """
if 'logger' in self.options:
self.options['logger'](msgs)
else:
print(msgs) | Log a message | https://github.com/panoplyio/panoply-python-sdk/blob/f73aba40ad8f6c116c93ec4f43364be898ec91aa/panoply/datasource.py#L18-L24 |
panoplyio/panoply-python-sdk | panoply/datasource.py | DataSource.progress | def progress(self, loaded, total, msg=''):
""" Notify on a progress change """
self.fire('progress', {
'loaded': loaded,
'total': total,
'msg': msg
}) | python | def progress(self, loaded, total, msg=''):
""" Notify on a progress change """
self.fire('progress', {
'loaded': loaded,
'total': total,
'msg': msg
}) | Notify on a progress change | https://github.com/panoplyio/panoply-python-sdk/blob/f73aba40ad8f6c116c93ec4f43364be898ec91aa/panoply/datasource.py#L34-L41 |
panoplyio/panoply-python-sdk | panoply/datasource.py | DataSource.raw | def raw(self, tag, raw, metadata):
""" Create a raw response object """
raw = base64.b64encode(raw)
return {
'type': 'raw',
'tag': tag,
'raw': raw,
'metadata': metadata
} | python | def raw(self, tag, raw, metadata):
""" Create a raw response object """
raw = base64.b64encode(raw)
return {
'type': 'raw',
'tag': tag,
'raw': raw,
'metadata': metadata
} | Create a raw response object | https://github.com/panoplyio/panoply-python-sdk/blob/f73aba40ad8f6c116c93ec4f43364be898ec91aa/panoply/datasource.py#L43-L51 |
rlisagor/freshen | freshen/checks.py | assert_looks_like | def assert_looks_like(first, second, msg=None):
""" Compare two strings if all contiguous whitespace is coalesced. """
first = _re.sub("\s+", " ", first.strip())
second = _re.sub("\s+", " ", second.strip())
if first != second:
raise AssertionError(msg or "%r does not look like %r" % (first, seco... | python | def assert_looks_like(first, second, msg=None):
""" Compare two strings if all contiguous whitespace is coalesced. """
first = _re.sub("\s+", " ", first.strip())
second = _re.sub("\s+", " ", second.strip())
if first != second:
raise AssertionError(msg or "%r does not look like %r" % (first, seco... | Compare two strings if all contiguous whitespace is coalesced. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/checks.py#L9-L14 |
rlisagor/freshen | freshen/core.py | load_feature | def load_feature(fname, language):
""" Load and parse a feature file. """
fname = os.path.abspath(fname)
feat = parse_file(fname, language)
return feat | python | def load_feature(fname, language):
""" Load and parse a feature file. """
fname = os.path.abspath(fname)
feat = parse_file(fname, language)
return feat | Load and parse a feature file. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/core.py#L68-L73 |
rlisagor/freshen | freshen/core.py | run_steps | def run_steps(spec, language="en"):
""" Can be called by the user from within a step definition to execute other steps. """
# The way this works is a little exotic, but I couldn't think of a better way to work around
# the fact that this has to be a global function and therefore cannot know about which ste... | python | def run_steps(spec, language="en"):
""" Can be called by the user from within a step definition to execute other steps. """
# The way this works is a little exotic, but I couldn't think of a better way to work around
# the fact that this has to be a global function and therefore cannot know about which ste... | Can be called by the user from within a step definition to execute other steps. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/core.py#L83-L97 |
rlisagor/freshen | freshen/core.py | StepsRunner.run_steps_from_string | def run_steps_from_string(self, spec, language_name='en'):
""" Called from within step definitions to run other steps. """
caller = inspect.currentframe().f_back
line = caller.f_lineno - 1
fname = caller.f_code.co_filename
steps = parse_steps(spec, fname, line, ... | python | def run_steps_from_string(self, spec, language_name='en'):
""" Called from within step definitions to run other steps. """
caller = inspect.currentframe().f_back
line = caller.f_lineno - 1
fname = caller.f_code.co_filename
steps = parse_steps(spec, fname, line, ... | Called from within step definitions to run other steps. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/core.py#L19-L28 |
rlisagor/freshen | freshen/core.py | Language.words | def words(self, key):
"""
Give all the synonymns of a word in the requested language
(or the default language if no word is available).
"""
if self.default_mappings is not None and key not in self.mappings:
return self.default_mappings[key].encode('utf').split("|")
... | python | def words(self, key):
"""
Give all the synonymns of a word in the requested language
(or the default language if no word is available).
"""
if self.default_mappings is not None and key not in self.mappings:
return self.default_mappings[key].encode('utf').split("|")
... | Give all the synonymns of a word in the requested language
(or the default language if no word is available). | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/core.py#L57-L65 |
rlisagor/freshen | examples/twisted/features/steps.py | simulate_async_event | def simulate_async_event():
"""Simulate an asynchronous event."""
scc.state = 'executing'
def async_event(result):
"""All other asynchronous events or function calls
returned from later steps will wait until this
callback fires."""
scc.state = result
return 'some even... | python | def simulate_async_event():
"""Simulate an asynchronous event."""
scc.state = 'executing'
def async_event(result):
"""All other asynchronous events or function calls
returned from later steps will wait until this
callback fires."""
scc.state = result
return 'some even... | Simulate an asynchronous event. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/examples/twisted/features/steps.py#L10-L22 |
rlisagor/freshen | freshen/stepregistry.py | hook_decorator | def hook_decorator(cb_type):
""" Decorator to wrap hook definitions in. Registers hook. """
def decorator_wrapper(*tags_or_func):
if len(tags_or_func) == 1 and callable(tags_or_func[0]):
# No tags were passed to this decorator
func = tags_or_func[0]
return HookImpl(cb... | python | def hook_decorator(cb_type):
""" Decorator to wrap hook definitions in. Registers hook. """
def decorator_wrapper(*tags_or_func):
if len(tags_or_func) == 1 and callable(tags_or_func[0]):
# No tags were passed to this decorator
func = tags_or_func[0]
return HookImpl(cb... | Decorator to wrap hook definitions in. Registers hook. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/stepregistry.py#L250-L263 |
rlisagor/freshen | freshen/stepregistry.py | StepImplLoader.load_steps_impl | def load_steps_impl(self, registry, path, module_names=None):
"""
Load the step implementations at the given path, with the given module names. If
module_names is None then the module 'steps' is searched by default.
"""
if not module_names:
module_names = ['steps']
... | python | def load_steps_impl(self, registry, path, module_names=None):
"""
Load the step implementations at the given path, with the given module names. If
module_names is None then the module 'steps' is searched by default.
"""
if not module_names:
module_names = ['steps']
... | Load the step implementations at the given path, with the given module names. If
module_names is None then the module 'steps' is searched by default. | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/stepregistry.py#L122-L169 |
rlisagor/freshen | freshen/stepregistry.py | StepImplRegistry.find_step_impl | def find_step_impl(self, step):
"""
Find the implementation of the step for the given match string. Returns the StepImpl object
corresponding to the implementation, and the arguments to the step implementation. If no
implementation is found, raises UndefinedStepImpl. If more than one imp... | python | def find_step_impl(self, step):
"""
Find the implementation of the step for the given match string. Returns the StepImpl object
corresponding to the implementation, and the arguments to the step implementation. If no
implementation is found, raises UndefinedStepImpl. If more than one imp... | Find the implementation of the step for the given match string. Returns the StepImpl object
corresponding to the implementation, and the arguments to the step implementation. If no
implementation is found, raises UndefinedStepImpl. If more than one implementation is
found, raises AmbiguousStepIm... | https://github.com/rlisagor/freshen/blob/5578f7368e8d53b4cf51c589fb192090d3524968/freshen/stepregistry.py#L212-L234 |
dfm/python-fsps | fsps/__init__.py | run_command | def run_command(cmd):
"""
Open a child process, and return its exit status and stdout.
"""
child = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out = [s.decode("utf-8").strip() for s in child.stdout]
err = ... | python | def run_command(cmd):
"""
Open a child process, and return its exit status and stdout.
"""
child = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out = [s.decode("utf-8").strip() for s in child.stdout]
err = ... | Open a child process, and return its exit status and stdout. | https://github.com/dfm/python-fsps/blob/29b81d0ff317532919451ca60b9d36aa1743bd21/fsps/__init__.py#L11-L21 |
dfm/python-fsps | scripts/fsps_filter_table.py | make_filter_list | def make_filter_list(filters):
"""Transform filters into list of table rows."""
filter_list = []
filter_ids = []
for f in filters:
filter_ids.append(f.index)
fullname = URL_P.sub(r'`<\1>`_', f.fullname)
filter_list.append((str(f.index + 1),
f.name,
... | python | def make_filter_list(filters):
"""Transform filters into list of table rows."""
filter_list = []
filter_ids = []
for f in filters:
filter_ids.append(f.index)
fullname = URL_P.sub(r'`<\1>`_', f.fullname)
filter_list.append((str(f.index + 1),
f.name,
... | Transform filters into list of table rows. | https://github.com/dfm/python-fsps/blob/29b81d0ff317532919451ca60b9d36aa1743bd21/scripts/fsps_filter_table.py#L28-L43 |
dfm/python-fsps | scripts/fsps_filter_table.py | make_table | def make_table(data, col_names):
"""Code for this RST-formatted table generator comes from
http://stackoverflow.com/a/11350643
"""
n_cols = len(data[0])
assert n_cols == len(col_names)
col_sizes = [max(len(r[i]) for r in data) for i in range(n_cols)]
for i, cname in enumerate(col_names):
... | python | def make_table(data, col_names):
"""Code for this RST-formatted table generator comes from
http://stackoverflow.com/a/11350643
"""
n_cols = len(data[0])
assert n_cols == len(col_names)
col_sizes = [max(len(r[i]) for r in data) for i in range(n_cols)]
for i, cname in enumerate(col_names):
... | Code for this RST-formatted table generator comes from
http://stackoverflow.com/a/11350643 | https://github.com/dfm/python-fsps/blob/29b81d0ff317532919451ca60b9d36aa1743bd21/scripts/fsps_filter_table.py#L46-L61 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_merge | def pdf_merge(inputs: [str], output: str, delete: bool = False):
"""
Merge multiple Pdf input files in one output file.
:param inputs: input files
:param output: output file
:param delete: delete input files after completion if true
"""
writer = PdfFileWriter()
if os.path.isfile(output)... | python | def pdf_merge(inputs: [str], output: str, delete: bool = False):
"""
Merge multiple Pdf input files in one output file.
:param inputs: input files
:param output: output file
:param delete: delete input files after completion if true
"""
writer = PdfFileWriter()
if os.path.isfile(output)... | Merge multiple Pdf input files in one output file.
:param inputs: input files
:param output: output file
:param delete: delete input files after completion if true | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L16-L51 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_rotate | def pdf_rotate(
input: str,
counter_clockwise: bool = False,
pages: [str] = None,
output: str = None,
):
"""
Rotate the given Pdf files clockwise or counter clockwise.
:param inputs: pdf files
:param counter_clockwise: rotate counter clockwise if true else clockwise
:param pages: lis... | python | def pdf_rotate(
input: str,
counter_clockwise: bool = False,
pages: [str] = None,
output: str = None,
):
"""
Rotate the given Pdf files clockwise or counter clockwise.
:param inputs: pdf files
:param counter_clockwise: rotate counter clockwise if true else clockwise
:param pages: lis... | Rotate the given Pdf files clockwise or counter clockwise.
:param inputs: pdf files
:param counter_clockwise: rotate counter clockwise if true else clockwise
:param pages: list of page numbers to rotate, if None all pages will be
rotated | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L54-L108 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_copy | def pdf_copy(input: str, output: str, pages: [int], yes_to_all=False):
"""
Copy pages from the input file in a new output file.
:param input: name of the input pdf file
:param output: name of the output pdf file
:param pages: list containing the page numbers to copy in the new file
"""
if n... | python | def pdf_copy(input: str, output: str, pages: [int], yes_to_all=False):
"""
Copy pages from the input file in a new output file.
:param input: name of the input pdf file
:param output: name of the output pdf file
:param pages: list containing the page numbers to copy in the new file
"""
if n... | Copy pages from the input file in a new output file.
:param input: name of the input pdf file
:param output: name of the output pdf file
:param pages: list containing the page numbers to copy in the new file | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L111-L138 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_split | def pdf_split(
input: str, output: str, stepsize: int = 1, sequence: [int] = None
):
"""
Split the input file in multiple output files
:param input: name of the input file
:param output: name of the output files
:param stepsize: how many pages per file, only if sequence is None
:param sequen... | python | def pdf_split(
input: str, output: str, stepsize: int = 1, sequence: [int] = None
):
"""
Split the input file in multiple output files
:param input: name of the input file
:param output: name of the output files
:param stepsize: how many pages per file, only if sequence is None
:param sequen... | Split the input file in multiple output files
:param input: name of the input file
:param output: name of the output files
:param stepsize: how many pages per file, only if sequence is None
:param sequence: list with number of pages per file | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L141-L191 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_zip | def pdf_zip(
input1: str,
input2: str,
output: str,
delete: bool = False,
revert: bool = False,
):
"""
Zip pages of input1 and input2 in one output file. Useful for putting
even and odd pages together in one document.
:param input1: first input file
:param input2: second input fi... | python | def pdf_zip(
input1: str,
input2: str,
output: str,
delete: bool = False,
revert: bool = False,
):
"""
Zip pages of input1 and input2 in one output file. Useful for putting
even and odd pages together in one document.
:param input1: first input file
:param input2: second input fi... | Zip pages of input1 and input2 in one output file. Useful for putting
even and odd pages together in one document.
:param input1: first input file
:param input2: second input file
:param output: output file
:param delete: if true the input files will be deleted after zipping | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L194-L243 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_insert | def pdf_insert(
dest: str,
source: str,
pages: [str] = None,
index: int = None,
output: str = None,
):
"""
Insert pages from one file into another.
:param dest: Destination file
:param source: Source file
:param pages: list of page numbers to insert
:param index: index in des... | python | def pdf_insert(
dest: str,
source: str,
pages: [str] = None,
index: int = None,
output: str = None,
):
"""
Insert pages from one file into another.
:param dest: Destination file
:param source: Source file
:param pages: list of page numbers to insert
:param index: index in des... | Insert pages from one file into another.
:param dest: Destination file
:param source: Source file
:param pages: list of page numbers to insert
:param index: index in destination file where to insert the pages
:param output: output file | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L246-L312 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_remove | def pdf_remove(source: str, pages: [str], output: str = None):
"""
Remove pages from a PDF source file.
:param source: pdf source file
:param pages: list of page numbers or range expressions
:param output: pdf output file
"""
if output is not None and os.path.isfile(output):
if over... | python | def pdf_remove(source: str, pages: [str], output: str = None):
"""
Remove pages from a PDF source file.
:param source: pdf source file
:param pages: list of page numbers or range expressions
:param output: pdf output file
"""
if output is not None and os.path.isfile(output):
if over... | Remove pages from a PDF source file.
:param source: pdf source file
:param pages: list of page numbers or range expressions
:param output: pdf output file | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L315-L354 |
stlehmann/pdftools | pdftools/pdftools.py | pdf_add | def pdf_add(dest: str, source: str, pages: [str], output: str):
"""
Add pages from a source pdf file to an output file. If the output
file does not exist a new file will be created.
:param source: source pdf file
:param dest: destination pdf file
:param pages: list of page numbers or range expre... | python | def pdf_add(dest: str, source: str, pages: [str], output: str):
"""
Add pages from a source pdf file to an output file. If the output
file does not exist a new file will be created.
:param source: source pdf file
:param dest: destination pdf file
:param pages: list of page numbers or range expre... | Add pages from a source pdf file to an output file. If the output
file does not exist a new file will be created.
:param source: source pdf file
:param dest: destination pdf file
:param pages: list of page numbers or range expressions
:param output: output pdf file | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/pdftools/pdftools.py#L357-L407 |
stlehmann/pdftools | setup.py | extract_version | def extract_version():
"""Extract the version from the package."""
with open('pdftools/__init__.py', 'r') as f:
content = f.read()
version_match = _version_re.search(content)
version = str(ast.literal_eval(version_match.group(1)))
return version | python | def extract_version():
"""Extract the version from the package."""
with open('pdftools/__init__.py', 'r') as f:
content = f.read()
version_match = _version_re.search(content)
version = str(ast.literal_eval(version_match.group(1)))
return version | Extract the version from the package. | https://github.com/stlehmann/pdftools/blob/d83cc1ecd8d4ea0165bce56a07d377004e1c69c2/setup.py#L22-L29 |
databio/pypiper | pypiper/utils.py | add_pypiper_args | def add_pypiper_args(parser, groups=("pypiper", ), args=None,
required=None, all_args=False):
"""
Use this to add standardized pypiper arguments to your python pipeline.
There are two ways to use `add_pypiper_args`: by specifying argument groups,
or by specifying individual argumen... | python | def add_pypiper_args(parser, groups=("pypiper", ), args=None,
required=None, all_args=False):
"""
Use this to add standardized pypiper arguments to your python pipeline.
There are two ways to use `add_pypiper_args`: by specifying argument groups,
or by specifying individual argumen... | Use this to add standardized pypiper arguments to your python pipeline.
There are two ways to use `add_pypiper_args`: by specifying argument groups,
or by specifying individual arguments. Specifying argument groups will add
multiple arguments to your parser; these convenient argument groupings
make it ... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L31-L54 |
databio/pypiper | pypiper/utils.py | build_command | def build_command(chunks):
"""
Create a command from various parts.
The parts provided may include a base, flags, option-bound arguments, and
positional arguments. Each element must be either a string or a two-tuple.
Raw strings are interpreted as either the command base, a pre-joined
pair (or ... | python | def build_command(chunks):
"""
Create a command from various parts.
The parts provided may include a base, flags, option-bound arguments, and
positional arguments. Each element must be either a string or a two-tuple.
Raw strings are interpreted as either the command base, a pre-joined
pair (or ... | Create a command from various parts.
The parts provided may include a base, flags, option-bound arguments, and
positional arguments. Each element must be either a string or a two-tuple.
Raw strings are interpreted as either the command base, a pre-joined
pair (or multiple pairs) of option and argument,... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L57-L99 |
databio/pypiper | pypiper/utils.py | build_sample_paths | def build_sample_paths(sample):
"""
Ensure existence of folders for a Sample.
:param looper.models.Sample sample: Sample (or instance supporting get()
that stores folders paths in a 'paths' key, in which the value is a
mapping from path name to actual folder path)
"""
for path_name,... | python | def build_sample_paths(sample):
"""
Ensure existence of folders for a Sample.
:param looper.models.Sample sample: Sample (or instance supporting get()
that stores folders paths in a 'paths' key, in which the value is a
mapping from path name to actual folder path)
"""
for path_name,... | Ensure existence of folders for a Sample.
:param looper.models.Sample sample: Sample (or instance supporting get()
that stores folders paths in a 'paths' key, in which the value is a
mapping from path name to actual folder path) | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L102-L116 |
databio/pypiper | pypiper/utils.py | checkpoint_filename | def checkpoint_filename(checkpoint, pipeline_name=None):
"""
Translate a checkpoint to a filename.
This not only adds the checkpoint file extension but also standardizes the
way in which checkpoint names are mapped to filenames.
:param str | pypiper.Stage checkpoint: name of a pipeline phase/stage... | python | def checkpoint_filename(checkpoint, pipeline_name=None):
"""
Translate a checkpoint to a filename.
This not only adds the checkpoint file extension but also standardizes the
way in which checkpoint names are mapped to filenames.
:param str | pypiper.Stage checkpoint: name of a pipeline phase/stage... | Translate a checkpoint to a filename.
This not only adds the checkpoint file extension but also standardizes the
way in which checkpoint names are mapped to filenames.
:param str | pypiper.Stage checkpoint: name of a pipeline phase/stage
:param str pipeline_name: name of pipeline to prepend to the che... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L119-L146 |
databio/pypiper | pypiper/utils.py | checkpoint_filepath | def checkpoint_filepath(checkpoint, pm):
"""
Create filepath for indicated checkpoint.
:param str | pypiper.Stage checkpoint: Pipeline phase/stage or one's name
:param pypiper.PipelineManager | pypiper.Pipeline pm: manager of a pipeline
instance, relevant for output folder path.
:return str... | python | def checkpoint_filepath(checkpoint, pm):
"""
Create filepath for indicated checkpoint.
:param str | pypiper.Stage checkpoint: Pipeline phase/stage or one's name
:param pypiper.PipelineManager | pypiper.Pipeline pm: manager of a pipeline
instance, relevant for output folder path.
:return str... | Create filepath for indicated checkpoint.
:param str | pypiper.Stage checkpoint: Pipeline phase/stage or one's name
:param pypiper.PipelineManager | pypiper.Pipeline pm: manager of a pipeline
instance, relevant for output folder path.
:return str: standardized checkpoint name for file, plus extensi... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L149-L193 |
databio/pypiper | pypiper/utils.py | check_shell | def check_shell(cmd, shell=None):
"""
Determine whether a command appears to involve shell process(es).
The shell argument can be used to override the result of the check.
:param str cmd: Command to investigate.
:param bool shell: override the result of the check with this value.
:return bool: ... | python | def check_shell(cmd, shell=None):
"""
Determine whether a command appears to involve shell process(es).
The shell argument can be used to override the result of the check.
:param str cmd: Command to investigate.
:param bool shell: override the result of the check with this value.
:return bool: ... | Determine whether a command appears to involve shell process(es).
The shell argument can be used to override the result of the check.
:param str cmd: Command to investigate.
:param bool shell: override the result of the check with this value.
:return bool: Whether the command appears to involve shell p... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L196-L207 |
databio/pypiper | pypiper/utils.py | check_shell_redirection | def check_shell_redirection(cmd):
"""
Determine whether a command appears to contain shell redirection symbol outside of curly brackets
:param str cmd: Command to investigate.
:return bool: Whether the command appears to contain shell redirection.
"""
curly_brackets = True
while curly_brack... | python | def check_shell_redirection(cmd):
"""
Determine whether a command appears to contain shell redirection symbol outside of curly brackets
:param str cmd: Command to investigate.
:return bool: Whether the command appears to contain shell redirection.
"""
curly_brackets = True
while curly_brack... | Determine whether a command appears to contain shell redirection symbol outside of curly brackets
:param str cmd: Command to investigate.
:return bool: Whether the command appears to contain shell redirection. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L239-L255 |
databio/pypiper | pypiper/utils.py | get_proc_name | def get_proc_name(cmd):
"""
Get the representative process name from complex command
:param str | list[str] cmd: a command to be processed
:return str: the basename representative command
"""
if isinstance(cmd, Iterable) and not isinstance(cmd, str):
cmd = " ".join(cmd)
return cmd.... | python | def get_proc_name(cmd):
"""
Get the representative process name from complex command
:param str | list[str] cmd: a command to be processed
:return str: the basename representative command
"""
if isinstance(cmd, Iterable) and not isinstance(cmd, str):
cmd = " ".join(cmd)
return cmd.... | Get the representative process name from complex command
:param str | list[str] cmd: a command to be processed
:return str: the basename representative command | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L300-L310 |
databio/pypiper | pypiper/utils.py | get_first_value | def get_first_value(param, param_pools, on_missing=None, error=True):
"""
Get the value for a particular parameter from the first pool in the provided
priority list of parameter pools.
:param str param: Name of parameter for which to determine/fetch value.
:param Sequence[Mapping[str, object]] para... | python | def get_first_value(param, param_pools, on_missing=None, error=True):
"""
Get the value for a particular parameter from the first pool in the provided
priority list of parameter pools.
:param str param: Name of parameter for which to determine/fetch value.
:param Sequence[Mapping[str, object]] para... | Get the value for a particular parameter from the first pool in the provided
priority list of parameter pools.
: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 v... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L313-L357 |
databio/pypiper | pypiper/utils.py | is_in_file_tree | def is_in_file_tree(fpath, folder):
"""
Determine whether a file is in a folder.
:param str fpath: filepath to investigate
:param folder: path to folder to query
:return bool: whether the path indicated is in the folder indicated
"""
file_folder, _ = os.path.split(fpath)
other_folder = ... | python | def is_in_file_tree(fpath, folder):
"""
Determine whether a file is in a folder.
:param str fpath: filepath to investigate
:param folder: path to folder to query
:return bool: whether the path indicated is in the folder indicated
"""
file_folder, _ = os.path.split(fpath)
other_folder = ... | Determine whether a file is in a folder.
:param str fpath: filepath to investigate
:param folder: path to folder to query
:return bool: whether the path indicated is in the folder indicated | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L360-L370 |
databio/pypiper | pypiper/utils.py | is_gzipped_fastq | def is_gzipped_fastq(file_name):
"""
Determine whether indicated file appears to be a gzipped FASTQ.
:param str file_name: Name/path of file to check as gzipped FASTQ.
:return bool: Whether indicated file appears to be in gzipped FASTQ format.
"""
_, ext = os.path.splitext(file_name)
return... | python | def is_gzipped_fastq(file_name):
"""
Determine whether indicated file appears to be a gzipped FASTQ.
:param str file_name: Name/path of file to check as gzipped FASTQ.
:return bool: Whether indicated file appears to be in gzipped FASTQ format.
"""
_, ext = os.path.splitext(file_name)
return... | Determine whether indicated file appears to be a gzipped FASTQ.
:param str file_name: Name/path of file to check as gzipped FASTQ.
:return bool: Whether indicated file appears to be in gzipped FASTQ format. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L384-L392 |
databio/pypiper | pypiper/utils.py | make_lock_name | def make_lock_name(original_path, path_base_folder):
"""
Create name for lock file from an absolute path.
The original path must be absolute, and it should point to a location
within the location indicated by the base folder path provided. This is
particularly useful for deleting a sample's output ... | python | def make_lock_name(original_path, path_base_folder):
"""
Create name for lock file from an absolute path.
The original path must be absolute, and it should point to a location
within the location indicated by the base folder path provided. This is
particularly useful for deleting a sample's output ... | Create name for lock file from an absolute path.
The original path must be absolute, and it should point to a location
within the location indicated by the base folder path provided. This is
particularly useful for deleting a sample's output folder path from
within the path of a target file to generate... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L417-L439 |
databio/pypiper | pypiper/utils.py | is_multi_target | def is_multi_target(target):
"""
Determine if pipeline manager's run target is multiple.
:param None or str or Sequence of str target: 0, 1, or multiple targets
:return bool: Whether there are multiple targets
:raise TypeError: if the argument is neither None nor string nor Sequence
"""
if ... | python | def is_multi_target(target):
"""
Determine if pipeline manager's run target is multiple.
:param None or str or Sequence of str target: 0, 1, or multiple targets
:return bool: Whether there are multiple targets
:raise TypeError: if the argument is neither None nor string nor Sequence
"""
if ... | Determine if pipeline manager's run target is multiple.
:param None or str or Sequence of str target: 0, 1, or multiple targets
:return bool: Whether there are multiple targets
:raise TypeError: if the argument is neither None nor string nor Sequence | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L442-L456 |
databio/pypiper | pypiper/utils.py | parse_cores | def parse_cores(cores, pm, default):
"""
Framework to finalize number of cores for an operation.
Some calls to a function may directly provide a desired number of cores,
others may not. Similarly, some pipeline managers may define a cores count
while others will not. This utility provides a single ... | python | def parse_cores(cores, pm, default):
"""
Framework to finalize number of cores for an operation.
Some calls to a function may directly provide a desired number of cores,
others may not. Similarly, some pipeline managers may define a cores count
while others will not. This utility provides a single ... | Framework to finalize number of cores for an operation.
Some calls to a function may directly provide a desired number of cores,
others may not. Similarly, some pipeline managers may define a cores count
while others will not. This utility provides a single via which the
count of cores to use for an op... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L459-L480 |
databio/pypiper | pypiper/utils.py | parse_stage_name | def parse_stage_name(stage):
"""
Determine the name of a stage.
The stage may be provided already as a name, as a Stage object, or as a
callable with __name__ (e.g., function).
:param str | pypiper.Stage | function stage: Object representing a stage,
from which to obtain name.
:return ... | python | def parse_stage_name(stage):
"""
Determine the name of a stage.
The stage may be provided already as a name, as a Stage object, or as a
callable with __name__ (e.g., function).
:param str | pypiper.Stage | function stage: Object representing a stage,
from which to obtain name.
:return ... | Determine the name of a stage.
The stage may be provided already as a name, as a Stage object, or as a
callable with __name__ (e.g., function).
:param str | pypiper.Stage | function stage: Object representing a stage,
from which to obtain name.
:return str: Name of putative pipeline Stage. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L483-L502 |
databio/pypiper | pypiper/utils.py | pipeline_filepath | def pipeline_filepath(pm, filename=None, suffix=None):
"""
Derive path to file for managed pipeline.
:param pypiper.PipelineManager | pypiper.Pipeline pm: Manager of a
particular pipeline instance.
:param str filename: Name of file for which to create full path based
on pipeline's outpu... | python | def pipeline_filepath(pm, filename=None, suffix=None):
"""
Derive path to file for managed pipeline.
:param pypiper.PipelineManager | pypiper.Pipeline pm: Manager of a
particular pipeline instance.
:param str filename: Name of file for which to create full path based
on pipeline's outpu... | Derive path to file for managed pipeline.
:param pypiper.PipelineManager | pypiper.Pipeline pm: Manager of a
particular pipeline instance.
:param str filename: Name of file for which to create full path based
on pipeline's output folder.
:param str suffix: Suffix for the file; this can be a... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L505-L533 |
databio/pypiper | pypiper/utils.py | translate_stage_name | def translate_stage_name(stage):
"""
Account for potential variability in stage/phase name definition.
Since a pipeline author is free to name his/her processing phases/stages
as desired, but these choices influence file names, enforce some
standardization. Specifically, prohibit potentially proble... | python | def translate_stage_name(stage):
"""
Account for potential variability in stage/phase name definition.
Since a pipeline author is free to name his/her processing phases/stages
as desired, but these choices influence file names, enforce some
standardization. Specifically, prohibit potentially proble... | Account for potential variability in stage/phase name definition.
Since a pipeline author is free to name his/her processing phases/stages
as desired, but these choices influence file names, enforce some
standardization. Specifically, prohibit potentially problematic spaces.
:param str | pypiper.Stage... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L536-L551 |
databio/pypiper | pypiper/utils.py | _determine_args | def _determine_args(argument_groups, arguments, use_all_args=False):
"""
Determine the arguments to add to a parser (for a pipeline).
:param Iterable[str] | str argument_groups: Collection of names of groups
of arguments to add to an argument parser.
:param Iterable[str] | str arguments: Collec... | python | def _determine_args(argument_groups, arguments, use_all_args=False):
"""
Determine the arguments to add to a parser (for a pipeline).
:param Iterable[str] | str argument_groups: Collection of names of groups
of arguments to add to an argument parser.
:param Iterable[str] | str arguments: Collec... | Determine the arguments to add to a parser (for a pipeline).
:param Iterable[str] | str argument_groups: Collection of names of groups
of arguments to add to an argument parser.
:param Iterable[str] | str arguments: Collection of specific arguments to
add to the parser.
:param bool use_all_... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L581-L641 |
databio/pypiper | pypiper/utils.py | _add_args | def _add_args(parser, args, required):
"""
Add new arguments to an ArgumentParser.
:param argparse.ArgumentParser parser: instance to update with new arguments
:param Iterable[str] args: Collection of names of arguments to add.
:param Iterable[str] required: Collection of arguments to designate as ... | python | def _add_args(parser, args, required):
"""
Add new arguments to an ArgumentParser.
:param argparse.ArgumentParser parser: instance to update with new arguments
:param Iterable[str] args: Collection of names of arguments to add.
:param Iterable[str] required: Collection of arguments to designate as ... | Add new arguments to an ArgumentParser.
:param argparse.ArgumentParser parser: instance to update with new arguments
:param Iterable[str] args: Collection of names of arguments to add.
:param Iterable[str] required: Collection of arguments to designate as required
:return argparse.ArgumentParser: Updat... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L644-L749 |
databio/pypiper | pypiper/ngstk.py | NGSTk._ensure_folders | def _ensure_folders(self, *paths):
"""
Ensure that paths to folder(s) exist.
Some command-line tools will not attempt to create folder(s) needed
for output path to exist. They instead assume that they already are
present and will fail if that assumption does not hold.
:... | python | def _ensure_folders(self, *paths):
"""
Ensure that paths to folder(s) exist.
Some command-line tools will not attempt to create folder(s) needed
for output path to exist. They instead assume that they already are
present and will fail if that assumption does not hold.
:... | Ensure that paths to folder(s) exist.
Some command-line tools will not attempt to create folder(s) needed
for output path to exist. They instead assume that they already are
present and will fail if that assumption does not hold.
:param Iterable[str] paths: Collection of path for which | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L78-L97 |
databio/pypiper | pypiper/ngstk.py | NGSTk.check_command | def check_command(self, command):
"""
Check if command can be called.
"""
# Use `command` to see if command is callable, store exit code
code = os.system("command -v {0} >/dev/null 2>&1 || {{ exit 1; }}".format(command))
# If exit code is not 0, report which command fai... | python | def check_command(self, command):
"""
Check if command can be called.
"""
# Use `command` to see if command is callable, store exit code
code = os.system("command -v {0} >/dev/null 2>&1 || {{ exit 1; }}".format(command))
# If exit code is not 0, report which command fai... | Check if command can be called. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L129-L142 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_file_size | def get_file_size(self, filenames):
"""
Get size of all files in string (space-separated) in megabytes (Mb).
:param str filenames: a space-separated string of filenames
"""
# use (1024 ** 3) for gigabytes
# equivalent to: stat -Lc '%s' filename
# If given a list... | python | def get_file_size(self, filenames):
"""
Get size of all files in string (space-separated) in megabytes (Mb).
:param str filenames: a space-separated string of filenames
"""
# use (1024 ** 3) for gigabytes
# equivalent to: stat -Lc '%s' filename
# If given a list... | Get size of all files in string (space-separated) in megabytes (Mb).
:param str filenames: a space-separated string of filenames | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L145-L158 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam2fastq | def bam2fastq(self, input_bam, output_fastq,
output_fastq2=None, unpaired_fastq=None):
"""
Create command to convert BAM(s) to FASTQ(s).
:param str input_bam: Path to sequencing reads file to convert
:param output_fastq: Path to FASTQ to write
:param output_fas... | python | def bam2fastq(self, input_bam, output_fastq,
output_fastq2=None, unpaired_fastq=None):
"""
Create command to convert BAM(s) to FASTQ(s).
:param str input_bam: Path to sequencing reads file to convert
:param output_fastq: Path to FASTQ to write
:param output_fas... | Create command to convert BAM(s) to FASTQ(s).
:param str input_bam: Path to sequencing reads file to convert
:param output_fastq: Path to FASTQ to write
:param output_fastq2: Path to (R2) FASTQ to write
:param unpaired_fastq: Path to unpaired FASTQ to write
:return str: Command ... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L173-L192 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam_to_fastq | def bam_to_fastq(self, bam_file, out_fastq_pre, paired_end):
"""
Build command to convert BAM file to FASTQ file(s) (R1/R2).
:param str bam_file: path to BAM file with sequencing reads
:param str out_fastq_pre: path prefix for output FASTQ file(s)
:param bool paired_end: whether... | python | def bam_to_fastq(self, bam_file, out_fastq_pre, paired_end):
"""
Build command to convert BAM file to FASTQ file(s) (R1/R2).
:param str bam_file: path to BAM file with sequencing reads
:param str out_fastq_pre: path prefix for output FASTQ file(s)
:param bool paired_end: whether... | Build command to convert BAM file to FASTQ file(s) (R1/R2).
:param str bam_file: path to BAM file with sequencing reads
:param str out_fastq_pre: path prefix for output FASTQ file(s)
:param bool paired_end: whether the given file contains paired-end
or single-end sequencing reads
... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L195-L216 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam_to_fastq_awk | def bam_to_fastq_awk(self, bam_file, out_fastq_pre, paired_end):
"""
This converts bam file to fastq files, but using awk. As of 2016, this is much faster
than the standard way of doing this using Picard, and also much faster than the
bedtools implementation as well; however, it does n... | python | def bam_to_fastq_awk(self, bam_file, out_fastq_pre, paired_end):
"""
This converts bam file to fastq files, but using awk. As of 2016, this is much faster
than the standard way of doing this using Picard, and also much faster than the
bedtools implementation as well; however, it does n... | This converts bam file to fastq files, but using awk. As of 2016, this is much faster
than the standard way of doing this using Picard, and also much faster than the
bedtools implementation as well; however, it does no sanity checks and assumes the reads
(for paired data) are all paired (no si... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L219-L240 |
databio/pypiper | pypiper/ngstk.py | NGSTk.bam_to_fastq_bedtools | def bam_to_fastq_bedtools(self, bam_file, out_fastq_pre, paired_end):
"""
Converts bam to fastq; A version using bedtools
"""
self.make_sure_path_exists(os.path.dirname(out_fastq_pre))
fq1 = out_fastq_pre + "_R1.fastq"
fq2 = None
cmd = self.tools.bedtools + " bamt... | python | def bam_to_fastq_bedtools(self, bam_file, out_fastq_pre, paired_end):
"""
Converts bam to fastq; A version using bedtools
"""
self.make_sure_path_exists(os.path.dirname(out_fastq_pre))
fq1 = out_fastq_pre + "_R1.fastq"
fq2 = None
cmd = self.tools.bedtools + " bamt... | Converts bam to fastq; A version using bedtools | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L243-L255 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_input_ext | def get_input_ext(self, input_file):
"""
Get the extension of the input_file. Assumes you're using either
.bam or .fastq/.fq or .fastq.gz/.fq.gz.
"""
if input_file.endswith(".bam"):
input_ext = ".bam"
elif input_file.endswith(".fastq.gz") or input_file.endswit... | python | def get_input_ext(self, input_file):
"""
Get the extension of the input_file. Assumes you're using either
.bam or .fastq/.fq or .fastq.gz/.fq.gz.
"""
if input_file.endswith(".bam"):
input_ext = ".bam"
elif input_file.endswith(".fastq.gz") or input_file.endswit... | Get the extension of the input_file. Assumes you're using either
.bam or .fastq/.fq or .fastq.gz/.fq.gz. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L258-L273 |
databio/pypiper | pypiper/ngstk.py | NGSTk.merge_or_link | def merge_or_link(self, input_args, raw_folder, local_base="sample"):
"""
This function standardizes various input possibilities by converting
either .bam, .fastq, or .fastq.gz files into a local file; merging those
if multiple files given.
:param list input_args: This is a list... | python | def merge_or_link(self, input_args, raw_folder, local_base="sample"):
"""
This function standardizes various input possibilities by converting
either .bam, .fastq, or .fastq.gz files into a local file; merging those
if multiple files given.
:param list input_args: This is a list... | This function standardizes various input possibilities by converting
either .bam, .fastq, or .fastq.gz files into a local file; merging those
if multiple files given.
:param list input_args: This is a list of arguments, each one is a
class of inputs (which can in turn be a string or... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L276-L381 |
databio/pypiper | pypiper/ngstk.py | NGSTk.input_to_fastq | def input_to_fastq(
self, input_file, sample_name,
paired_end, fastq_folder, output_file=None, multiclass=False):
"""
Builds a command to convert input file to fastq, for various inputs.
Takes either .bam, .fastq.gz, or .fastq input and returns
commands that will create ... | python | def input_to_fastq(
self, input_file, sample_name,
paired_end, fastq_folder, output_file=None, multiclass=False):
"""
Builds a command to convert input file to fastq, for various inputs.
Takes either .bam, .fastq.gz, or .fastq input and returns
commands that will create ... | Builds a command to convert input file to fastq, for various inputs.
Takes either .bam, .fastq.gz, or .fastq input and returns
commands that will create the .fastq file, regardless of input type.
This is useful to made your pipeline easily accept any of these input
types seamlessly, sta... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L384-L457 |
databio/pypiper | pypiper/ngstk.py | NGSTk.check_fastq | def check_fastq(self, input_files, output_files, paired_end):
"""
Returns a follow sanity-check function to be run after a fastq conversion.
Run following a command that will produce the fastq files.
This function will make sure any input files have the same number of reads as the
... | python | def check_fastq(self, input_files, output_files, paired_end):
"""
Returns a follow sanity-check function to be run after a fastq conversion.
Run following a command that will produce the fastq files.
This function will make sure any input files have the same number of reads as the
... | Returns a follow sanity-check function to be run after a fastq conversion.
Run following a command that will produce the fastq files.
This function will make sure any input files have the same number of reads as the
output files. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L460-L516 |
databio/pypiper | pypiper/ngstk.py | NGSTk.check_trim | def check_trim(self, trimmed_fastq, paired_end, trimmed_fastq_R2=None, fastqc_folder=None):
"""
Build function to evaluate read trimming, and optionally run fastqc.
This is useful to construct an argument for the 'follow' parameter of
a PipelineManager's 'run' method.
:param st... | python | def check_trim(self, trimmed_fastq, paired_end, trimmed_fastq_R2=None, fastqc_folder=None):
"""
Build function to evaluate read trimming, and optionally run fastqc.
This is useful to construct an argument for the 'follow' parameter of
a PipelineManager's 'run' method.
:param st... | Build function to evaluate read trimming, and optionally run fastqc.
This is useful to construct an argument for the 'follow' parameter of
a PipelineManager's 'run' method.
:param str trimmed_fastq: Path to trimmed reads file.
:param bool paired_end: Whether the processing is being don... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L519-L570 |
databio/pypiper | pypiper/ngstk.py | NGSTk.validate_bam | def validate_bam(self, input_bam):
"""
Wrapper for Picard's ValidateSamFile.
:param str input_bam: Path to file to validate.
:return str: Command to run for the validation.
"""
cmd = self.tools.java + " -Xmx" + self.pm.javamem
cmd += " -jar " + self.tools.picard ... | python | def validate_bam(self, input_bam):
"""
Wrapper for Picard's ValidateSamFile.
:param str input_bam: Path to file to validate.
:return str: Command to run for the validation.
"""
cmd = self.tools.java + " -Xmx" + self.pm.javamem
cmd += " -jar " + self.tools.picard ... | Wrapper for Picard's ValidateSamFile.
:param str input_bam: Path to file to validate.
:return str: Command to run for the validation. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L573-L583 |
databio/pypiper | pypiper/ngstk.py | NGSTk.merge_bams | def merge_bams(self, input_bams, merged_bam, in_sorted="TRUE", tmp_dir=None):
"""
Combine multiple files into one.
The tmp_dir parameter is important because on poorly configured
systems, the default can sometimes fill up.
:param Iterable[str] input_bams: Paths to files to comb... | python | def merge_bams(self, input_bams, merged_bam, in_sorted="TRUE", tmp_dir=None):
"""
Combine multiple files into one.
The tmp_dir parameter is important because on poorly configured
systems, the default can sometimes fill up.
:param Iterable[str] input_bams: Paths to files to comb... | Combine multiple files into one.
The tmp_dir parameter is important because on poorly configured
systems, the default can sometimes fill up.
:param Iterable[str] input_bams: Paths to files to combine
:param str merged_bam: Path to which to write combined result.
:param bool | s... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L586-L621 |
databio/pypiper | pypiper/ngstk.py | NGSTk.merge_fastq | def merge_fastq(self, inputs, output, run=False, remove_inputs=False):
"""
Merge FASTQ files (zipped or not) into one.
:param Iterable[str] inputs: Collection of paths to files to merge.
:param str output: Path to single output file.
:param bool run: Whether to run the c... | python | def merge_fastq(self, inputs, output, run=False, remove_inputs=False):
"""
Merge FASTQ files (zipped or not) into one.
:param Iterable[str] inputs: Collection of paths to files to merge.
:param str output: Path to single output file.
:param bool run: Whether to run the c... | Merge FASTQ files (zipped or not) into one.
:param Iterable[str] inputs: Collection of paths to files to merge.
:param str output: Path to single output file.
:param bool run: Whether to run the command.
:param bool remove_inputs: Whether to keep the original files.
:ret... | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L624-L646 |
databio/pypiper | pypiper/ngstk.py | NGSTk.count_lines | def count_lines(self, file_name):
"""
Uses the command-line utility wc to count the number of lines in a file. For MacOS, must strip leading whitespace from wc.
:param str file_name: name of file whose lines are to be counted
"""
x = subprocess.check_output("wc -l " + file_name ... | python | def count_lines(self, file_name):
"""
Uses the command-line utility wc to count the number of lines in a file. For MacOS, must strip leading whitespace from wc.
:param str file_name: name of file whose lines are to be counted
"""
x = subprocess.check_output("wc -l " + file_name ... | Uses the command-line utility wc to count the number of lines in a file. For MacOS, must strip leading whitespace from wc.
:param str file_name: name of file whose lines are to be counted | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L649-L656 |
databio/pypiper | pypiper/ngstk.py | NGSTk.get_chrs_from_bam | def get_chrs_from_bam(self, file_name):
"""
Uses samtools to grab the chromosomes from the header that are contained
in this bam file.
"""
x = subprocess.check_output(self.tools.samtools + " view -H " + file_name + " | grep '^@SQ' | cut -f2| sed s'/SN://'", shell=True)
# ... | python | def get_chrs_from_bam(self, file_name):
"""
Uses samtools to grab the chromosomes from the header that are contained
in this bam file.
"""
x = subprocess.check_output(self.tools.samtools + " view -H " + file_name + " | grep '^@SQ' | cut -f2| sed s'/SN://'", shell=True)
# ... | Uses samtools to grab the chromosomes from the header that are contained
in this bam file. | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L667-L674 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.