-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSnakefile-demux
64 lines (47 loc) · 2.29 KB
/
Snakefile-demux
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
63
from string import ascii_lowercase
import os
import subprocess
from pathlib import Path
import csv
import glob
# get current username for computer
home_dir = str(Path.home())
# read in the config file to get pathways/samples into variables
# determine if config file is in folder, if not, copy the config file from snakemake pipeline directory into working path
if Path('config_demux.yaml').is_file():
config_fname = 'config_demux.yaml'
else:
demux_config = f"{home_dir}/gbs/GBS_snakemake_pipeline/config/config_demux.yaml"
with open('config_demux.yaml', 'w', newline='') as conf_out:
with open(demux_config, 'r') as config:
for line in config:
conf_out.write(line)
config_fname = 'config_demux.yaml'
configfile: config_fname
demux_dir = config["demux_dir"]
demux_parent = Path(demux_dir).name
demux_output = f"{demux_parent}.tar.gz"
reference_fai = config["reference"]
demux_files = glob.glob(f'{demux_dir}/*')
# generate a list of sorted bams and fastqc files that will be output at end of process
sample_outputs = [f'{Path(i).stem[:-2]}' for i in demux_files] # get just name (no .1 or .2 on file name)
trim_input1 = demux_parent+'/{sample}.1.fastq'
print(trim_input1)
trim_input2 = demux_parent+'/{sample}.2.fastq'
# get the pathway from the read1 fastq file, this is where we want to run the pipeline (set working dir)
path_name, base_name = os.path.split(demux_dir)
file_handle = os.path.splitext(base_name)[0]
file_name = os.path.splitext(file_handle)[0]
lib_id = Path(demux_dir).parent.name # for naming the am ID line - just get the name of the folder the demux lives in
workdir: path_name
####################################### RULES ##################################################
rule all:
input:
expand("sorted_bams/{sort_out}.bam", sort_out=sample_outputs),
"log/multiqc_report",
demux_output
include: f"{home_dir}/gbs/GBS_snakemake_pipeline/workflow/rules/demux/trim-demux.smk"
include: f"{home_dir}/gbs/GBS_snakemake_pipeline/workflow/rules/demux/bwa_map-demux.smk"
include: f"{home_dir}/gbs/GBS_snakemake_pipeline/workflow/rules/demux/novosort-demux.smk"
include: f"{home_dir}/gbs/GBS_snakemake_pipeline/workflow/rules/demux/qc_stats.smk"
include: f"{home_dir}/gbs/GBS_snakemake_pipeline/workflow/rules/demux/cleanup.smk"