-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakyVC_chromosomewise.smk
66 lines (58 loc) · 3.49 KB
/
snakyVC_chromosomewise.smk
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
64
65
66
import sys
import os
import re
project_name = config['project_name']
workflow_path = config['workflow_path']
input_files_1 = config['input_files_1']
input_files_2 = config['input_files_2']
chromosomes = config['chromosomes']
reference_file = config['reference_file']
output_folder = config['output_folder']
memory = config['memory']
threads = config['threads']
samples = []
input_folder_1 = ''
input_folder_2 = ''
input_extension_1 = ''
input_extension_2 = ''
for i in range(len(input_files_1)):
if os.path.dirname(input_files_1[i]) != input_folder_1:
input_folder_1 = os.path.dirname(input_files_1[i])
possible_sample = re.sub('_[^_]*$', '', str(os.path.basename(input_files_1[i])))
if not possible_sample in samples:
samples.append(possible_sample)
possible_extension = re.sub(possible_sample,'',str(os.path.basename(input_files_1[i])))
if possible_extension != input_extension_1:
input_extension_1 = possible_extension
for i in range(len(input_files_2)):
if os.path.dirname(input_files_2[i]) != input_folder_2:
input_folder_2 = os.path.dirname(input_files_2[i])
possible_sample = re.sub('_[^_]*$', '', str(os.path.basename(input_files_2[i])))
if not possible_sample in samples:
samples.append(possible_sample)
possible_extension = re.sub(possible_sample,'',str(os.path.basename(input_files_2[i])))
if possible_extension != input_extension_2:
input_extension_2 = possible_extension
rule all:
input:
expand(os.path.join(os.path.abspath(output_folder),'BWA_sam','{sample}.sam'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'BWA_sam_log','{sample}.log'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'GATK_SortSam','{sample}.bam'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'GATK_MarkDuplicates','{sample}.bam'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'GATK_AddOrReplaceReadGroups','{sample}.bam'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'GATK_HaplotypeCaller_gvcf_gz','{sample}.g.vcf.gz'), sample=samples),
expand(os.path.join(os.path.abspath(output_folder),'GATK_CombineGVCFs_gz','{project_name}_{{chromosome}}.g.vcf.gz'.format(project_name=project_name)), chromosome=chromosomes),
expand(os.path.join(os.path.abspath(output_folder),'GATK_GenotypeGVCFs_gz','{project_name}_{{chromosome}}.vcf.gz'.format(project_name=project_name)), chromosome=chromosomes),
os.path.join(os.path.abspath(output_folder),'GATK_GatherVcfs_gz_chromosomewise','{project_name}.vcf.gz'.format(project_name=project_name)),
os.path.join(os.path.abspath(output_folder),'GATK_SelectVariants_gz_chromosomewise_SNPs','{project_name}_snp.vcf.gz'.format(project_name=project_name)),
os.path.join(os.path.abspath(output_folder),'GATK_SelectVariants_gz_chromosomewise_Indels','{project_name}_indel.vcf.gz'.format(project_name=project_name))
include: './tasks/bwa/bwa_mem_pair.smk'
include: './tasks/gatk/gatk_sortsam.smk'
include: './tasks/gatk/gatk_markduplicates.smk'
include: './tasks/gatk/gatk_addorreplacereadgroups.smk'
include: './tasks/gatk/gatk_haplotypecaller.smk'
include: './tasks/gatk/gatk_combinegvcfs_chromosomewise.smk'
include: './tasks/gatk/gatk_genotypegvcfs_chromosomewise.smk'
include: './tasks/gatk/gatk_gathervcfs_chromosomewise.smk'
include: './tasks/gatk/gatk_selectvariants_chromosomewise_snp.smk'
include: './tasks/gatk/gatk_selectvariants_chromosomewise_indel.smk'