-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding base scaffold and boilerplate for pipeline
- Loading branch information
1 parent
2c823f1
commit 8b8f3a4
Showing
20 changed files
with
818 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.smk linguist-language=Python | ||
Snakefile linguist-language=Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
site/ | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# DS_Store | ||
.DS_Store | ||
._* | ||
**/.DS_Store | ||
**/._* | ||
|
||
.snakemake* | ||
**/.snakemake* | ||
.venv | ||
.venv/* | ||
|
||
# Pipeline Results or Output | ||
results/ | ||
output/ | ||
tmp/ | ||
scratch/ | ||
|
||
# mkdocs documentation | ||
site/ | ||
|
||
# Pipeline generated files or directories | ||
.tests/*/ | ||
.snakemake/ | ||
|
||
# Cached Java directories | ||
.oracle_jre_usage/ | ||
.java/ | ||
|
||
# GNU Parallel | ||
.parallel/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0-beta] - 2022-02-18 | ||
### Added | ||
- Recommended scaffold for building a snakemake pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 OpenOmics | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0-beta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"__default__": { | ||
"threads": "4", | ||
"mem": "8g", | ||
"partition": "norm", | ||
"time": "0-04:00:00" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"inputs": { | ||
}, | ||
"options": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"images": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"references": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tools": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## Steps for Building Docker Images | ||
|
||
Directly below are instructions for building an image using the provided Dockerfile: | ||
|
||
```bash | ||
# See listing of images on computer | ||
docker image ls | ||
|
||
# Build from Dockerfile | ||
docker build --no-cache -f example.dockerfile --tag=example:v0.1.0 . | ||
|
||
# Testing, take a peek inside | ||
docker run -ti example:v0.1.0 /bin/bash | ||
|
||
# Updating Tag before pushing to DockerHub | ||
docker tag example:v0.1.0 skchronicles/example:v0.1.0 | ||
docker tag example:v0.1.0 skchronicles/example # latest | ||
|
||
# Check out new tag(s) | ||
docker image ls | ||
|
||
# Push new tagged image to DockerHub | ||
docker push skchronicles/example:v0.1.0 | ||
docker push skchronicles/example:latest | ||
``` | ||
|
||
### Other Recommended Steps | ||
|
||
Scan your image for known vulnerabilities: | ||
|
||
```bash | ||
docker scan example:v0.1.0 | ||
``` | ||
|
||
> **Please Note**: Any references to `skchronicles` should be replaced your username if you would also like to push the image to a non-org account. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Resources | ||
|
||
This folder, `resources/`, is meant to contain all resources necessary for running the workflow. This can be small reference files, such as reference sequences or small databases. This directory also contains utility scripts or wrappers to help facilitate running the pipeline. | ||
|
||
Whenever feasible, they can also be downloaded programmatically via rules defined in the pipeline. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os, sys | ||
# Makes relative imports to work in Python 3.6 | ||
# without the need of '.' before the name of the | ||
# package or py file. | ||
# Allows for consistent syntax of relative imports | ||
# across python2 and python3. | ||
sys.path.append(os.path.dirname(os.path.realpath(__file__))) | ||
|
||
# Ground source of truth for version information | ||
version = open('../VERSION', 'r').readlines()[0].strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Python standard library | ||
from __future__ import print_function | ||
from subprocess import CalledProcessError | ||
import os, subprocess | ||
|
||
# Local imports | ||
from utils import fatal, err | ||
|
||
|
||
def set_options(strict): | ||
""" | ||
Changes behavior of default shell and get overrides options | ||
to run bash in a strict mode. | ||
@param strict <bool>: | ||
Overrides default shell options and runs shell in strict or | ||
less permissive mode. | ||
@return prefix <int>: | ||
Returns overrides options to run bash in a strict mode | ||
""" | ||
prefix = '' # permissive shell option | ||
if strict: | ||
# Changes behavior of default shell | ||
# set -e: exit immediately upon error | ||
# set -u: treats unset variables as an error | ||
# set -o pipefail: exits if a error occurs in any point of a pipeline | ||
prefix = 'set -euo pipefail; ' | ||
|
||
return prefix | ||
|
||
|
||
def bash(cmd, interpreter='/bin/bash', strict=set_options(True), cwd=os.getcwd(), **kwargs): | ||
""" | ||
Interface to run a process or bash command. Using subprocess.call_check() | ||
due to portability across most python versions. It was introduced in python 2.5 | ||
and it is also interoperabie across all python 3 versions. | ||
@param cmd <str>: | ||
Shell command to run | ||
@param interpreter <str>: | ||
Interpreter for command to run [default: bash] | ||
@pararm strict <bool>: | ||
Prefixes any command with 'set -euo pipefail' to ensure process fail with | ||
the expected exit-code | ||
@params kwargs <check_call()>: | ||
Keyword arguments to modify subprocess.check_call() behavior | ||
@return exitcode <int>: | ||
Returns the exit code of the run command, failures return non-zero exit codes | ||
""" | ||
try: | ||
exitcode = subprocess.check_call(strict + cmd, | ||
shell=True, | ||
executable=interpreter, | ||
cwd=cwd, | ||
**kwargs | ||
) | ||
except CalledProcessError as e: | ||
exitcode = e.returncode | ||
err("""WARNING: Failed to run '{}' command! | ||
└── Command returned a non-zero exitcode of '{}'.""".format(strict + cmd, exitcode) | ||
) | ||
|
||
return exitcode | ||
|
||
|
||
if __name__ == '__main__': | ||
# Tests | ||
bash('ls -la /home/') | ||
bash('ls -la /fake/dne/path') |
Oops, something went wrong.