-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
62 lines (52 loc) · 1.82 KB
/
Snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""``snakemake`` pipeline that runs analysis."""
import os
import pandas as pd
configfile: 'config.yml'
wildcard_constraints:
tile="tile_\d+"
rule all:
input:
expand("results/{tile}",
tile=config['tiles']),
expand("results/summary/dms_{tile}_analysis.md",
tile=config['tiles']),
'results/dms-view/data_all_tiles.csv'
rule cat_dms_view:
"""Concatenate all `dms-view` data."""
input:
expand("results/{tile}/dms_view/data.csv",
tile=config['tiles'])
output: csv='results/dms-view/data_all_tiles.csv'
run:
(pd.concat([pd.read_csv(f) for f in input])
.to_csv(output.csv, index=False, float_format='%.4f')
)
rule jupnb_to_md:
"""Convert Jupyter notebook to Markdown format."""
input: notebook="results/notebooks/{notebook}.ipynb"
output: markdown="results/summary/{notebook}.md"
params: outdir=lambda wildcards, output: os.path.dirname(output.markdown)
conda: 'environment.yml'
shell:
"""
jupyter nbconvert \
--output-dir {params.outdir} \
--to markdown \
{input.notebook}
"""
rule dms_tile_analysis:
"""Analyze DMS data for a tile."""
input:
amplicon="data/{tile}_amplicon.fasta",
alignspecs="data/{tile}_subamplicon_alignspecs.txt",
samplelist="data/{tile}_samplelist.csv",
output:
resultsdir=directory("results/{tile}"),
dms_view="results/{tile}/dms_view/data.csv",
params:
errpre=lambda wc: config['tiles'][wc.tile]['errpre'],
site_number_offset=lambda wc: config['tiles'][wc.tile]['site_number_offset']
threads: config['max_cpus']
conda: 'environment.yml'
log: notebook='results/notebooks/dms_{tile}_analysis.ipynb'
notebook: 'dms_tile_analysis.py.ipynb'