Skip to content
Snippets Groups Projects
Commit 5fb90d0f authored by Blaise Li's avatar Blaise Li
Browse files

Attempts to include rules from package.

parent dbf90e52
No related branches found
No related tags found
No related merge requests found
......@@ -47,11 +47,13 @@ import seaborn as sns
import husl
from libhts import do_deseq2, median_ratio_to_pseudo_ref_size_factors, status_setter, plot_lfc_distribution, plot_MA
from libworkflows import ensure_relative
from libworkflows import get_chrom_sizes, column_converter
from libworkflows import strip_split, last_lines, save_plot, test_na_file
from libworkflows import make_id_list_getter, filter_combinator, SHELL_FUNCTIONS, warn_context
from libworkflows import read_htseq_counts, sum_htseq_counts
from libworkflows import read_feature_counts, sum_feature_counts
from smincludes import rules as irules
#TRIMMERS = ["cutadapt", "fastx_clipper"]
TRIMMERS = ["cutadapt"]
......@@ -257,22 +259,8 @@ rule all:
expand(OPJ(output_dir, "{trimmer}", "figures", aligner, "{lib}_by_{norm_type}_mean", "{orientation}_on_merged_isolated_%d_{biotype}_min_%d_meta_profile.{fig_format}" % (MIN_DIST, META_MIN_LEN)), trimmer=TRIMMERS, lib=LIBS, norm_type=NORM_TYPES, orientation=["all"], biotype=METAGENE_BIOTYPES, fig_format=FIG_FORMATS),
include: "../snakemake_wrappers/includes/link_raw_data.snakefile"
# def lib2data(wildcards):
# return lib2raw[wildcards.lib][wildcards.rep]
#
#
# rule link_raw_data:
# """This rule installs the raw data in a local directory using symlinks.
# The location of the original files is taken from the configuration."""
# input:
# raw = lib2data,
# output:
# link = OPJ(data_dir, "{lib}_{rep}.fastq.gz"),
# message:
# "Making link {output.link} to raw data {input.raw}."
# run:
# os.symlink(os.path.abspath(input.raw), output.link)
include: ensure_relative(irules["link_raw_data"], workflow.basedir)
#include: "../snakemake_wrappers/includes/link_raw_data.rules"
rule trim_and_dedup:
......
......@@ -53,11 +53,13 @@ import pyBigWig
from rpy2.robjects import Formula, StrVector
from libhts import do_deseq2, status_setter, plot_lfc_distribution, plot_MA
from libhts import median_ratio_to_pseudo_ref_size_factors, size_factor_correlations, plot_norm_correlations, plot_counts_distribution
from libworkflows import ensure_relative
from libworkflows import get_chrom_sizes, column_converter, make_id_list_getter
from libworkflows import strip_split, save_plot, test_na_file, SHELL_FUNCTIONS, warn_context
from libworkflows import read_htseq_counts, sum_htseq_counts
from libworkflows import read_intersect_counts, sum_intersect_counts
from libworkflows import read_feature_counts, sum_feature_counts
from smincludes import rules as irules
# Possible feature ID conversions
......@@ -184,25 +186,8 @@ rule all:
counts_files,
include: "../snakemake_wrappers/includes/link_raw_data.snakefile"
# def lib2data(wildcards):
# return lib2raw[wildcards.lib][wildcards.rep]
#
#
# rule link_raw_data:
# """This rule installs the raw data in a local directory using symlinks.
# The location of the original files is taken from the configuration."""
# input:
# raw = lib2data,
# output:
# link = OPJ(data_dir, "{lib}_{rep}.fastq.gz"),
# params:
# directory = data_dir,
# shell_command = lib2data,
# message:
# "Making link {output.link} to raw data {input.raw}."
# run:
# os.symlink(os.path.abspath(input.raw), output.link)
include: ensure_relative(irules["link_raw_data"], workflow.basedir)
#include: "../snakemake_wrappers/includes/link_raw_data.rules"
def mapping_command(aligner):
......
from .libworkflows import SHELL_FUNCTIONS, column_converter, file_len, filter_combinator, get_chrom_sizes, last_lines, make_id_list_getter, read_int_from_file, read_feature_counts, read_htseq_counts, read_intersect_counts, save_plot, strip_split, sum_feature_counts, sum_htseq_counts, sum_intersect_counts, test_na_file, warn_context
from .libworkflows import SHELL_FUNCTIONS, column_converter, ensure_relative, file_len, filter_combinator, get_chrom_sizes, last_lines, make_id_list_getter, read_int_from_file, read_feature_counts, read_htseq_counts, read_intersect_counts, save_plot, strip_split, sum_feature_counts, sum_htseq_counts, sum_intersect_counts, test_na_file, warn_context
......@@ -78,6 +78,14 @@ def strip_split(text):
return split(strip(text), "\t")
def ensure_relative(path, basedir):
"""Returns the relative path to *path* from *basedir*.
That way, a snakefile can be included using its absolute path."""
if os.path.isabs(path):
return os.path.relpath(path, basedir)
else:
return path
def read_int_from_file(filename):
"""Just reads a single integer from a file."""
with open(filename, "r") as f:
......
......@@ -121,9 +121,11 @@ sns.set_context("talk")
from libhts import do_deseq2, status_setter
from libhts import median_ratio_to_pseudo_ref_size_factors, size_factor_correlations
from libhts import plot_norm_correlations, plot_counts_distribution, plot_boxplots
from libworkflows import ensure_relative
from libworkflows import get_chrom_sizes, column_converter, make_id_list_getter
from libworkflows import read_int_from_file, strip_split, file_len, last_lines, save_plot, SHELL_FUNCTIONS
from libworkflows import filter_combinator, sum_feature_counts, sum_htseq_counts, warn_context
from smincludes import rules as irules
strip = str.strip
......@@ -580,25 +582,12 @@ rule all:
OPJ(output_dir, "figures", "{small_type}_norm_counts_distrib.{fig_format}"),
small_type=["mi", "prot_si", "te_si", "pseu_si", "satel_si", "simrep_si", "prot_siu", "te_siu", "pseu_siu", "pisimi"], fig_format=FIG_FORMATS),
relative_include_path = "../snakemake_wrappers/includes/link_raw_data.snakefile"
absolute_include_path = os.path.join(workflow.basedir, relative_include_path)
assert os.path.exists(absolute_include_path)
include: relative_include_path
# def lib2data(wildcards):
# return lib2raw[wildcards.lib][wildcards.rep]
#
#
# rule link_raw_data:
# """This rule installs the raw data in a local directory using symlinks.
# The location of the original files is taken from the configuration."""
# input:
# raw = lib2data,
# output:
# link = OPJ(data_dir, "{lib}_{rep}.fastq.gz"),
# message:
# "Making link {output.link} to raw data {input.raw}."
# run:
# os.symlink(os.path.abspath(input.raw), output.link)
#absolute = "/pasteur/homes/bli/src/bioinfo_utils/snakemake_wrappers/includes/link_raw_data.rules"
#relative_include_path = "../snakemake_wrappers/includes/link_raw_data.snakefile"
#absolute_include_path = os.path.join(workflow.basedir, relative_include_path)
#assert os.path.exists(absolute_include_path)
#include: relative_include_path
include: ensure_relative(irules["link_raw_data"], workflow.basedir)
rule trim_and_dedup:
......
from setuptools import setup, find_packages
#from Cython.Build import cythonize
#import libworkflows
# Adapted from Biopython
__version__ = "Undefined"
for line in open('smincludes/__init__.py'):
if (line.startswith('__version__')):
exec(line.strip())
setup(
name="smincludes",
#version=libworkflows.__version__,
version=__version__,
description="Rules that can be included in snakemake workflows.",
author="Blaise Li",
author_email="blaise.li@normalesup.org",
license="MIT",
packages=find_packages())
#ext_modules = cythonize("libsmallrna/libsmallrna.pyx"),
#install_requires=["cytoolz"],
#zip_safe=False
from glob import glob
import os
OPJ = os.path.join
OPA = os.path.abspath
OPB = os.path.basename
__all__ = ["rules"]
# The working directory is that of the importing context.
# __path__ gives access to the package path
_local_dir, = __path__
_rule_files = glob(OPJ(_local_dir, "*.rules"))
rules = {}
for rule_file in _rule_files:
rules[OPB(rule_file)[:-6]] = OPA(rule_file)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment