Welcome to SnakeTools’s documentation!¶
Contents:
SnakeTools¶
Small library of helper tools for setting up, graphing, and working with Snakemake rules.
- Free software: MIT license
- Documentation: https://snaketools.readthedocs.io.
Features¶
SnakeRun
object to initialize and manage information common to the whole run, such as:- a copy of the config values from the config file provided to
snakemake
. - a place to store global variables needed throughout the run.
- more
- a copy of the config values from the config file provided to
SnakeRule
object to manage the initialization and deployment of rule-specific information including:- the rule name
- a default out directory deduced from the SnakeRun object
- a default log file path
- a “pretty name” for the rule to be displayed in the DAG graphs.
- attributes that store the input, output, and params values for later use.
- a copy of the values specific to this rule from the original configuration file.
- more
recode_graph
function that cleans up the default output ofsnakemake --dag
and allows the use of pretty names stored in theSnakeRule
objects.
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install SnakeTools, run this command in your terminal:
$ pip install snaketools
This is the preferred method to install SnakeTools, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for SnakeTools can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/xguse/snaketools
Or download the tarball:
$ curl -OL https://github.com/xguse/snaketools/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Source Code Documentation¶
snaketools package¶
Submodules¶
snaketools.errors module¶
Provide error classes for snaketools.
-
exception
snaketools.errors.
NotImplementedYet
(msg=None)[source]¶ Bases:
NotImplementedError
,snaketools.errors.SnaketoolsError
Raise when a section of code that has been left for another time is asked to execute.
-
exception
snaketools.errors.
SnaketoolsError
[source]¶ Bases:
Exception
Base error class for veoibd-synapse-data-manager.
-
exception
snaketools.errors.
ValidationError
[source]¶ Bases:
snaketools.errors.SnaketoolsError
Raise when a validation/sanity check comes back with unexpected value.
snaketools.snaketools module¶
Provide code supporting the running and automating of Snakemake rules.
-
snaketools.snaketools.
apply_template
(template, keywords)[source]¶ Return a list of strings of form
template
with values inkeywords
inserted.Parameters: - template (
str
) – a string containing keywords ({kw_name}
). - keywords (
dict
-like) – dict with keys of appropriate keyword names and values as equal length ORDERED lists with the correct values to be inserted.
- template (
-
snaketools.snaketools.
pathify_by_key_ends
(dictionary)[source]¶ Return a dict that has had all values with keys containing the suffixes: ‘_FILE’, ‘_PATH’ or ‘_DIR’ converted to Path() instances.
Parameters: dictionary (dict-like) – Usually the loaded, processed config file as a dict. Returns: Modified version of the input. Return type: dict-like
-
class
snaketools.snaketools.
SnakeRun
(cfg, snakefile)[source]¶ Bases:
object
Initialize and manage information common to the whole run.
-
class
snaketools.snaketools.
SnakeRule
(run, name, pretty_name=None)[source]¶ Bases:
object
Manage the initialization and deployment of rule-specific information.
Module contents¶
Top-level package for SnakeTools.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/xguse/snaketools/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
SnakeTools could always use more documentation, whether as part of the official SnakeTools docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/xguse/snaketools/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up snaketools for local development.
Fork the snaketools repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/snaketools.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv snaketools $ cd snaketools/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 snaketools tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/xguse/snaketools/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Gus Dunn <w.gus.dunn@gmail.com>
Contributors¶
None yet. Why not be the first?
Change Log¶
v0.0.7 / 2017-12-18¶
- change pyup check to monthly
- update reqs from PYUP
- snaketools: SnakeRule now registers with SnakeRun
- snaketools: added attr SnakeRule.extra for more params
- snaketools: added attr SnakeRun.rules
- snaketools: use __all__ for importing from file
- update makefile
- update reqs
v0.0.6 / 2017-10-26¶
- added rewrite_snakefile_no_rules()
- flake8
- requirements.txt: removed dev-reqs
- requirements.txt: pinned flake8
- setup.py: upgraded to read from req files
- MANIFEST.in: include req files
- upgraded Makefile
- tox.ini: set line-length etc
- setup.cfg: ignore W292
- setup.cfg: exclude lib & bin from flake8
- updated .gitignore
- added coveralls badge
- HISTORY.rst: replaced header text
v0.0.5 / 2017-10-10¶
- requirements_dev.txt: update and pin reqs
- flake8 fixes
- tox.ini: simplified config
- added flake8 to reqs
v0.0.4 / 2017-10-10¶
- added preliminary test suite
- Makefile: changed install to use pip install -e .
- added example files for testing
- requirements.txt: created with pipreqs
- snaketools.py: reorder functions
- snaketools.py: formatting
- ignore .vscode/
- pin all reqs since pyup now manages
v0.0.3 / 2017-09-15¶
- Configure pyup
- SnakeRun.d -> SnakeRune.interim_dir
v0.0.2 / 2017-09-06¶
- fixed bumpversion artifact
- errors.py: pulls metadata from top module
- updated dev reqs for doc building
- activated travis ci
- Set up flake8 configuration
- Docs build corrected
v0.0.1 / 2017-09-06¶
- README.rst: added prelim description of features.
- snaketools.py: fixed typo
- Initial commit