Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct dependency to snakemake #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"""The setup script."""

from setuptools import setup, find_packages
import sys

if sys.version_info < (3, 5):
print("At least Python 3.5 is required.\n", file=sys.stderr)
exit(1)

with open('README.rst') as readme_file:
readme = readme_file.read()
Expand All @@ -15,8 +20,7 @@
'Click>=6.0',
'click-log',
'PyYAML>=4.2b1',
'snakemake>=3.13.2',
# TODO: put package requirements here
'snakemake>=5.5.1',
]

setup_requirements = [
Expand Down Expand Up @@ -54,12 +58,6 @@
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Natural Language :: English',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
test_suite='tests',
Expand Down
11 changes: 6 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[tox]
envlist = py26, py27, py33, py34, py35, flake8
envlist = py35, flake8
# py26, py27, py33, py3i4

[travis]
python =
3.5: py35
3.4: py34
3.3: py33
2.7: py27
2.6: py26
# 3.4: py34
# 3.3: py33
# 2.7: py27
# 2.6: py26

[testenv:flake8]
basepython=python
Expand Down
18 changes: 11 additions & 7 deletions wbuild/.wBuild/wBuildParser.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
for(p in c("stringr", "yaml", "magrittr", "gsubfn"))
if(!requireNamespace(p, quietly=TRUE))
install.packages(p)
library(stringr)
library(methods)
library(yaml)
library(magrittr)
library(gsubfn)

parseWBHeader = function(filename, ...)
{
addWildCards = list(...)
Expand All @@ -6,7 +15,6 @@ parseWBHeader = function(filename, ...)
filename = snakemake@input[['RScript']]
}

library(stringr)
wbPD = 'Output/ProcessedData'
wildcards = list(
`wbPD` = 'Output/ProcessedData',
Expand All @@ -17,11 +25,7 @@ parseWBHeader = function(filename, ...)
wildcards = c(wildcards,addWildCards)
if(!exists('snakemake') || snakemake@rule == 'WB')
{
library(methods)
library(yaml)
library(magrittr)
library(gsubfn)


wb = readLines(filename)%>%str_subset("^#'")%>%str_replace("^#'",'')%>%paste0(collapse='\n')%>%
str_replace("\\n---(.|\\n)*",'')%>%yaml.load%>%`[[`('wb')

Expand Down Expand Up @@ -120,4 +124,4 @@ wbRead = function(name)
return(wbReadRDS(name))
}
stop('Could not determine format of ', snakemake@input[[name]])
}
}
47 changes: 32 additions & 15 deletions wbuild/.wBuild/wBuildParser2.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
for(p in c("stringr", "gsubfn"))
if(!requireNamespace(p, quietly=TRUE))
install.packages(p)
library(stringr)
library(gsubfn)
parseWBHeader2 = function(file, wildcards = list(), debug = T)
{

parseWBHeader2 <- function(file, wildcards=list(), debug=TRUE, options=c(),
rerun=FALSE){

# Are we interactive or in real snakemake run?
if(exists('snakemake')&&is.null(snakemake@config[['wbDump']]))
{
if(exists('snakemake') && is.null(snakemake@config[['wbDump']]) &&
!isTRUE(rerun)){
return (snakemake)
}

#' Create dependency file
system2('python',c('.wBuild/wbParse.py',file))
system2('python', c('.wBuild/wbParse.py',file))

#' Replace wildcards if necessary
if(length(wildcards)>0)
{
names(wildcards) = paste0('{',names(wildcards),'}')
dependencyfile = readLines('.wBuild.depend')
dependencyfile_wild <- gsubfn('\\{[^\\}]+\\}', wildcards,dependencyfile)
if(length(wildcards) > 0){
wildcards2rep <- rep(wildcards, each=2)
names(wildcards2rep) <- paste0(
c('{', '{{'), names(wildcards2rep), c('}', '}}'))
dependencyfile <- readLines('.wBuild.depend')
dependencyfile_wild <- gsubfn(
'\\{+[^\\}]+\\}+', wildcards2rep, dependencyfile)
writeLines(dependencyfile_wild, con=".wBuild.depend")
}

#' Extract rule name (1st in file)
dependencyfile = readLines('.wBuild.depend')
rule_name = str_extract(dependencyfile,'(?<=rule )[A-z0-9_]*')
rule_name = rule_name[!is.na(rule_name)][1]

if(debug==T)
{

if(isTRUE(debug)){
writeLines(dependencyfile)
}

#' Run snakemake to dump snakemake object, dumps some error yet
system2('snakemake',c(rule_name,'--config','wbDump=T','--nolock','--latency-wait','0','-q','-F','--allowed-rules',rule_name,'--mode','2'))
system2('snakemake', c(rule_name, '--config', 'wbDump=T', '--nolock',
'--latency-wait', '0', '-q', '-F', '--allowed-rules', rule_name,
'--mode', '2', options))
#' Read snakemake object in
snakemake <<- readRDS('.wBuild/snakemake.dump')
ans <- readRDS('.wBuild/snakemake.dump')
slot(ans, "wildcards", check=FALSE) <- wildcards

snakemake <<- ans
}


#
#parseWBHeader2('Scripts/Analysis1/010_BasicInput/020_BasicInput.R',debug=F)
#parseWBHeader2(file ='Scripts/Analysis1/050_PythonCode/030_AnalysisTemplate.R',list(id='anton'))
Expand Down
2 changes: 2 additions & 0 deletions wbuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def __init__(self):
self.path = p
break
else:
if type(self.path) is list:
self.path=self.path[0]
self.path=os.path.abspath(self.path)

# this is taken from the snakemake main file
Expand Down