forked from proksee-project/ProkaML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
138 lines (106 loc) · 3.97 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
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
'''
Copyright:
University of Manitoba & National Microbiology Laboratory, Canada, 2021
Written by: Arnab Saha Mandal
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this work except in compliance with the License. You may obtain a copy of the
License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
'''
import os
import glob
from os import environ
configfile: "config.yaml"
rule target:
input:
"species_well_represented_assemblyQC.joblib.gz"
checkpoint get_assembly_UIDs:
conda:
"dependencies.yaml"
output:
directory("database_build/temporary_outputs/entrez_id_list")
shell:
"python database_build/get_assembly_UIDs.py {config[email]} {config[api_key]}"
rule obtain_entrez_metadata:
conda:
"dependencies.yaml"
input:
"database_build/temporary_outputs/entrez_id_list/Assembly_UID_chunk{i}.txt"
output:
"database_build/temporary_outputs/entrez_species_metadata/Assembly_UID_chunk{i}_metadata.txt"
shell:
"python database_build/get_entrez_metadata.py {config[email]} {config[api_key]} {input}"
def log_entrez_metadata_report(wildcards):
ck_output = checkpoints.get_assembly_UIDs.get(**wildcards).output[0]
return expand("database_build/temporary_outputs/log_entrez_metadata_chunk{i}.txt",
i=glob_wildcards(os.path.join(ck_output,"Assembly_UID_chunk{i}.txt")).i)
rule log_entrez_metadata:
conda:
"dependencies.yaml"
input:
log_entrez_metadata_report
shell:
"python database_build/log_entrez_metadata.py"
def entrez_metadata_input(wildcards):
ck_output = checkpoints.get_assembly_UIDs.get(**wildcards).output[0]
return expand("database_build/temporary_outputs/entrez_species_metadata/Assembly_UID_chunk{i}_metadata.txt",
i=glob_wildcards(os.path.join(ck_output,"Assembly_UID_chunk{i}.txt")).i)
checkpoint get_species_counts:
conda:
"dependencies.yaml"
input:
entrez_metadata_input
output:
directory("database_build/temporary_outputs/species_reorganized_metadata")
shell:
"python database_build/get_species_counts.py {config[email]} {config[api_key]}"
rule append_gc_content:
conda:
"dependencies.yaml"
input:
"database_build/temporary_outputs/species_reorganized_metadata/{j}_metadata.txt"
output:
"database_build/temporary_outputs/species_reorganized_metadata_gc/{j}_metadata_gc.txt"
shell:
"python database_build/append_gc_content.py {config[email]} {config[api_key]} {input}"
def log_gc_content(wildcards):
ck_output = checkpoints.get_species_counts.get(**wildcards).output[0]
return expand("database_build/{j}_log_gc.txt", j=glob_wildcards(os.path.join(ck_output,"{j}_metadata.txt")).j)
rule log_gc_content:
conda:
"dependencies.yaml"
input:
log_gc_content
shell:
"python database_build/log_gc_content.py"
rule concatenate_metadata:
conda:
"dependencies.yaml"
input:
log_gc_content
output:
"well_represented_species_metadata.txt"
shell:
"python database_build/concatenate_metadata.py"
rule preprocess_metadata:
conda:
"dependencies.yaml"
input:
"well_represented_species_metadata.txt"
output:
"well_represented_species_metadata_normalized.txt"
shell:
"python preprocessing/cmd_preprocess_normalize.py"
rule generate_machine_learning_model:
conda:
"dependencies.yaml"
input:
"well_represented_species_metadata_normalized.txt"
output:
"species_well_represented_assemblyQC.joblib.gz"
shell:
"python machine_learning/cmd_build_apply_model.py"