Skip to content

Instantly share code, notes, and snippets.

@mpkocher
Created March 5, 2017 11:16
Show Gist options
  • Save mpkocher/8bb57339a69b9807f30e04fdde0a66aa to your computer and use it in GitHub Desktop.
Save mpkocher/8bb57339a69b9807f30e04fdde0a66aa to your computer and use it in GitHub Desktop.
Possible Pure Python SnakeMake API
from snakemake.core import SnakeMakeShellRule, SnakeMakePyRule, AllRule
class CollectReferences(SnakeMakeShellRule):
ID = "collect_references"
THREADS = 8
DESCRIPTION = "Does some stuff"
def inputs():
return dict(alpha="f1.fasta")
def resolve_params(config):
return dict(a=1, b=2)
def outputs():
return dict(gamma="out1.txt", delta="out2.txt")
def shell(inputs, outputs, config):
return "run-my-exe {config.nthreads} {inputs.alpha} {outs.gamma}"
class SubreadSetSummary(SnakeMakePyRule):
ID = "subreads_summary"
DESCRIPTION = "Create a txt summary of SubreadSet XML"
def inputs():
return dict(s1="/path/to/subreadset.xml")
def outputs():
return dict(summary="summary.txt")
def run(inputs, outputs, config):
from pbcore.dataset.io import SubreadSet
s = SubreadSet(inputs.s1)
with open(outputs.summary, 'w+') as f:
f.write(repr(s))
return 0
class CustomSummaryWorkflow(AllRule):
INPUTS = dict(
s1="summary.txt",
gamma="out1.txt",
delta="outs2.txt")
DEFAULT_PARAMS = dict(a=1, b=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment