Skip to content

Commit

Permalink
Merge pull request #97 from refgenie/bugfix
Browse files Browse the repository at this point in the history
v0.9.1
  • Loading branch information
stolarczyk authored Jul 29, 2020
2 parents a186c54 + 558203a commit bf42570
Show file tree
Hide file tree
Showing 14 changed files with 343 additions and 98 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: install macOS-specific dependancies
if: startsWith(matrix.os, 'macOS')
run: brew install md5sha1sum

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.9.1] - 2020-07-29

### Added
- `force_large` argument in the `pull` method, which can be used to handle large archive downloads
- `add` method

### Changed
- `getseq` method returns the sequence string instead of printing it to the screen

### Deprecated
- `get_remote_data_str` method. Use `listr` instead

## [0.9.0] - 2020-07-01

### Changed
Expand Down
9 changes: 5 additions & 4 deletions refgenconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from .helpers import *
from .refgenconf import *

__all__ = ["RefGenConf", "select_genome_config", "GenomeConfigFormatError",
"MissingAssetError", "MissingConfigDataError", "MissingGenomeError",
"RefgenconfError", "UnboundEnvironmentVariablesError"] + \
["DEFAULT_SERVER"] + CFG_KEY_NAMES
__all__ = ["RefGenConf", "select_genome_config", "get_dir_digest",
"GenomeConfigFormatError", "MissingAssetError",
"MissingConfigDataError", "MissingGenomeError", "RefgenconfError",
"UnboundEnvironmentVariablesError"] + ["DEFAULT_SERVER"] + \
CFG_KEY_NAMES
2 changes: 1 addition & 1 deletion refgenconf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = "0.9.1"
39 changes: 35 additions & 4 deletions refgenconf/helpers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
""" Helper functions """

import os
import yacman
from .const import CFG_ENV_VARS
from yacman import select_config
from .const import CFG_ENV_VARS, BUILD_STATS_DIR
from re import sub
from ubiquerg import is_command_callable


__all__ = ["select_genome_config"]
__all__ = ["select_genome_config", "get_dir_digest"]


def select_genome_config(filename=None, conf_env_vars=CFG_ENV_VARS, **kwargs):
Expand All @@ -17,7 +19,7 @@ def select_genome_config(filename=None, conf_env_vars=CFG_ENV_VARS, **kwargs):
consider; basically, a prioritized search list
:return str: path to genome configuration file
"""
return yacman.select_config(filename, conf_env_vars, **kwargs)
return select_config(filename, conf_env_vars, **kwargs)


def unbound_env_vars(path):
Expand All @@ -38,3 +40,32 @@ def unbound_env_vars(path):
def asciify_json_dict(json_dict):
from ubiquerg.collection import asciify_dict
return asciify_dict(json_dict)


def get_dir_digest(path, pm=None):
"""
Generate a MD5 digest that reflects just the contents of the
files in the selected directory.
:param str path: path to the directory to digest
:param pypiper.PipelineManager pm: a pipeline object, optional.
The subprocess module will be used if not provided
:return str: a digest, e.g. a3c46f201a3ce7831d85cf4a125aa334
"""
if not is_command_callable("md5sum"):
raise OSError("md5sum command line tool is required for asset digest "
"calculation. \n"
"Install and try again, e.g on macOS: 'brew install "
"md5sha1sum'")
cmd = "cd {}; find . -type f -not -path './" + BUILD_STATS_DIR + \
"*' -exec md5sum {{}} \; | sort -k 2 | awk '{{print $1}}' | md5sum"
try:
x = pm.checkprint(cmd.format(path))
except AttributeError:
try:
from subprocess import check_output
x = check_output(cmd.format(path), shell=True).decode("utf-8")
except Exception as e:

return
return str(sub(r'\W+', '', x)) # strips non-alphanumeric
Loading

0 comments on commit bf42570

Please sign in to comment.