-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinish_process.smk
166 lines (154 loc) · 7.01 KB
/
finish_process.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
configfile: 'seekdeep_illumina_general.yaml'
def get_qluster_fastqs(wildcards):
output_files=[]
samples=[line.strip() for line in open(config['output_folder']+'/non-empty_extractions.txt')]
for sample in samples:
sample_prefix=sample.split('MID')[1].split('_')[0]
output_files.append(config['output_folder']+f'/analysis/{sample_prefix}_extraction/{sample}_qlusterOut/output.fastq.gz')
return output_files
import os
amplicon_folder=config['output_folder']+'/analysis/popClustering'
amplicons=os.listdir(amplicon_folder)
amplicons.remove('locationByIndex')
rule all:
input:
# all_sample_commands=expand(config['output_folder']+'/qluster_shell_commands/{sample}_qluster_command.sh', sample=[line.strip() for line in open(config['output_folder']+'/non-empty_extractions.txt')]),
# qluster_output=get_qluster_fastqs
# all_process_cluster_commands=expand(config['output_folder']+'/process_cluster_shell_commands/{amplicon}_process_cluster_command.sh', amplicon=amplicons)
# analysis_folder=expand(config['output_folder']+'/analysis/popClustering/{amplicon}/analysis/selectedClustersInfo.tab.txt.gz', amplicon=amplicons)
process_pairs=config['output_folder']+'/analysis/reports/allProcessPairsCounts.tab.txt'
rule prep_qluster:
input:
runnable_samples=config['output_folder']+'/non-empty_extractions.txt',
qluster_commands=config['output_folder']+'/analysis/qlusterCmds.txt'
params:
output_folder=config['output_folder']+'/qluster_shell_commands',
analysis_dir='/home/analysis'
output:
all_sample_commands=expand(config['output_folder']+'/qluster_shell_commands/{sample}_qluster_command.sh', sample=[line.strip() for line in open(config['output_folder']+'/non-empty_extractions.txt')])
script:
'scripts/prep_qluster.py'
rule run_qluster:
input:
sample_command=config['output_folder']+'/qluster_shell_commands/{sample}_qluster_command.sh',
data_folder=config['primer_plus_fastq_binding'],
sif_file=config['sif_file_location'],
genome_root_folder=config['genome_binding'],
params:
output_dir=config['output_folder'],
softlink_fastq_binding=config['softlink_fastq_binding'],
singularity_qluster_file='/seekdeep_output/qluster_shell_commands/{sample}_qluster_command.sh'
output:
qluster_output=config['output_folder']+'/analysis/{sample_prefix}_extraction/{sample}_qlusterOut/output.fastq.gz'
resources:
time_min=config['max_run_time_min'],
mem_mb=config['max_memory_mb'],
nodes=config['cpus_to_use']
shell:
'''
singularity exec -B {input.data_folder}:/input_data \
-B {params.output_dir}:/seekdeep_output \
-B {input.genome_root_folder}:/genome_info \
-B {params.output_dir}/analysis/:/home/analysis \
{params.softlink_fastq_binding} \
{input.sif_file} bash {params.singularity_qluster_file}
'''
rule prep_process_cluster:
input:
process_cluster_commands=config['output_folder']+'/analysis/processClusterCmds.txt',
qluster_done=get_qluster_fastqs
params:
output_folder=config['output_folder']+'/process_cluster_shell_commands',
analysis_dir='/home/analysis'
output:
all_process_cluster_commands=expand(config['output_folder']+'/process_cluster_shell_commands/{amplicon}_process_cluster_command.sh', amplicon=amplicons)
script:
'scripts/prep_process_cluster.py'
rule run_process_cluster:
input:
data_folder=config['primer_plus_fastq_binding'],
sif_file=config['sif_file_location'],
genome_root_folder=config['genome_binding'],
actual_process_cluster_command=config['output_folder']+'/process_cluster_shell_commands/{amplicon}_process_cluster_command.sh'
params:
output_dir=config['output_folder'],
softlink_fastq_binding=config['softlink_fastq_binding'],
singularity_process_cluster_command='/seekdeep_output/process_cluster_shell_commands/{amplicon}_process_cluster_command.sh'
output:
analysis_folder=config['output_folder']+'/analysis/popClustering/{amplicon}/analysis/selectedClustersInfo.tab.txt.gz'
threads: config['cpus_to_use']
resources:
time_min=config['max_run_time_min'],
mem_mb=config['max_memory_mb'],
nodes=config['cpus_to_use']
shell:
'''
singularity exec -B {input.data_folder}:/input_data \
-B {params.output_dir}:/seekdeep_output \
-B {input.genome_root_folder}:/genome_info \
-B {params.output_dir}/analysis/:/home/analysis \
{params.softlink_fastq_binding} \
{input.sif_file} bash {params.singularity_process_cluster_command}
'''
rule combine_stats:
input:
analysis_folder=expand(config['output_folder']+'/analysis/popClustering/{amplicon}/analysis/selectedClustersInfo.tab.txt.gz', amplicon=amplicons),
sif_file=config['sif_file_location']
params:
output_dir=config['output_folder'],
actual_command=config['output_folder']+'/analysis/combineExtractionCountsCmd.sh',
singularity_command='/home/analysis/combineExtractionCountsCmd.sh',
junk_file=temp('junk_file.txt'),
junk_file2=temp('junk_file2.txt')
output:
extraction_profile=config['output_folder']+'/analysis/reports/allExtractionProfile.tab.txt',
failed_primers=config['output_folder']+'/analysis/reports/combinedAllFailedPrimerCounts.tab.txt',
extraction_stats=config['output_folder']+'/analysis/reports/allExtractionStats.tab.txt',
process_pairs=config['output_folder']+'/analysis/reports/allProcessPairsCounts.tab.txt'
shell:
'''
echo "cd /home/analysis" >{params.junk_file}
cat {params.actual_command} >{params.junk_file2}
cat {params.junk_file} {params.junk_file2} >{params.actual_command}
singularity exec -B {params.output_dir}:/seekdeep_output \
-B {params.output_dir}/analysis/:/home/analysis \
{input.sif_file} bash {params.singularity_command}
'''
#gen_config_commands=[line.strip() for line in open(config['output_folder']+'/analysis/genConfigCmds.txt')]
#rule gen_config:
# input:
# data_folder=config['primer_plus_fastq_binding'],
# sif_file=config['sif_file_location'],
# setup_done=config['output_folder']+'/finished_setup.txt',
# genome_root_folder=config['genome_binding'],
# process_cluster_files=expand(config['output_folder']+'/process_cluster_jobs/{number}_process_cluster_done.txt', number=list(range(len(process_cluster_commands))))
# params:
# output_dir=config['output_folder'],
# softlink_fastq_binding=config['softlink_fastq_binding'],
# command=lambda wildcards: gen_config_commands[int(wildcards.number)]
# output:
# gen_config_done=config['output_folder']+'/gen_config_jobs/{number}_gen_config_done.txt',
# threads: config['cpus_to_use']
# resources:
# time_min=config['max_run_time_min'],
# mem_mb=config['max_memory_mb'],
# nodes=config['cpus_to_use']
# shell:
# '''
# singularity exec -B {input.data_folder}:/input_data \
# -B {params.output_dir}:/seekdeep_output \
# -B {input.genome_root_folder}:/genome_info \
# {params.softlink_fastq_binding} \
# -H {params.output_dir}/analysis/:/home/analysis \
# {input.sif_file} {params.command}
# touch {output.gen_config_done}
# '''
#rule all_done:
# input:
# gen_config_files=expand(config['output_folder']+'/gen_config_jobs/{number}_gen_config_done.txt', number=list(range(len(gen_config_commands))))
# output:
# all_finished=config['output_folder']+'/all_finished.txt'
# shell:
# '''
# touch {output.all_finished}
# '''