Skip to content

Commit 39e9afc

Browse files
committed
changed learnapp to learn_apply in all config and files that call config params
1 parent 1b8d185 commit 39e9afc

8 files changed

Lines changed: 39 additions & 39 deletions

File tree

.test/config_learnapp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ basis_dir: "/path/to/output/kmerize/"
4343
score_dir: "/path/to/output/scoring/"
4444

4545

46-
learnapp:
46+
learn_apply:
4747
save_apply_associations: False
4848
fragmentation: False
4949
version: absolute

resources/LA_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ model_dir: "/path/to/output/model/"
4242
basis_dir: "/path/to/output/kmerize/"
4343
score_dir: "/path/to/output/scoring/"
4444

45-
# learnapp params
46-
learnapp:
45+
# learn_apply params
46+
learn_apply:
4747
save_apply_associations: False # Bool, use True if needing to extract more details. Increases storage requirements substantially.
4848
fragmentation: True # Bool, fragments the data according to the variables below (version, frag_length, min_length, location, seed)
4949
version: absolute

resources/kmer-association-example/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ model_dir: "/path/to/output/model/"
4242
basis_dir: "/path/to/output/kmerize/"
4343
score_dir: "/path/to/output/scoring/"
4444

45-
# learnapp params
46-
learnapp:
45+
# learn_apply params
46+
learn_apply:
4747
save_apply_associations: False # Bool, use True if needing to extract more details. Increases storage requirements substantially.
4848
fragmentation: True # Bool, fragments the data according to the variables below (version, frag_length, min_length, location, seed)
4949
version: absolute

snekmer/rules/apply.smk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ out_dir = skm.io.define_output_dir(
7272
config["alphabet"], config["k"], nested=config["nested_output"]
7373
)
7474

75-
threshold_type = config["learnapp"]["threshold"]
76-
selection_type = config["learnapp"]["selection"]
75+
threshold_type = config["learn_apply"]["threshold"]
76+
selection_type = config["learn_apply"]["selection"]
7777

78-
apply_cfg = config.get("learnapp", {})
78+
apply_cfg = config.get("learn_apply", {})
7979
concat_results = apply_cfg.get("apply_output", "snekmer_results.csv")
8080
extra_all = [concat_results] if concat_results is not None else []
8181

@@ -101,7 +101,7 @@ rule all:
101101
expand(
102102
join(out_dir, "apply", "seq-annotation-scores-{nb}.csv"), nb=FAS
103103
)
104-
if config["learnapp"]["save_apply_associations"]
104+
if config["learn_apply"]["save_apply_associations"]
105105
else []
106106
)
107107
],
@@ -129,12 +129,12 @@ rule apply:
129129
confidence_associations=expand("{conf}", conf=confidence_file),
130130
decoy_stats=expand("{decoy}", decoy=decoy_stats_file),
131131
params:
132-
selection_type=config["learnapp"]["selection"],
133-
threshold_type=config["learnapp"]["threshold"],
132+
selection_type=config["learn_apply"]["selection"],
133+
threshold_type=config["learn_apply"]["threshold"],
134134
output:
135135
seq_ann=(
136136
expand(join(out_dir, "apply", "seq-annotation-scores-{nb}.csv"), nb=FAS)
137-
if config["learnapp"]["save_apply_associations"]
137+
if config["learn_apply"]["save_apply_associations"]
138138
else []
139139
),
140140
kmer_summary=join(out_dir, "apply", "kmer-summary-{nb}.csv"),

snekmer/rules/learn.smk

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ out_dir = skm.io.define_output_dir(
7373
)
7474

7575
if (
76-
config["learnapp"]["selection"] != "top_hit"
77-
and config["learnapp"]["threshold"] == "None"
76+
config["learn_apply"]["selection"] != "top_hit"
77+
and config["learn_apply"]["threshold"] == "None"
7878
):
7979
raise Exception(
8080
"The only selection method that allows for None is `top_hit`. Other methods inherently use a threshold"
@@ -99,11 +99,11 @@ rule all:
9999
join(out_dir, "learn", "kmer-counts-total.csv"),
100100
# Fragmentation outputs (only if enabled)
101101
expand(join(out_dir, "fragmented", "{nb}.fasta"), nb=FAS)
102-
if config["learnapp"]["fragmentation"]
102+
if config["learn_apply"]["fragmentation"]
103103
else [],
104104
# expand(join(out_dir, "vector_frag", "{nb}.npz"), nb=FAS)
105105
expand(join(out_dir, "vector", "vector_frag", "{nb}.npz"), nb=FAS)
106-
if config["learnapp"]["fragmentation"]
106+
if config["learn_apply"]["fragmentation"]
107107
else [],
108108
# Forward evaluation scores
109109
expand(
@@ -112,7 +112,7 @@ rule all:
112112
"evaluate",
113113
(
114114
"eval_apply_sequences"
115-
if not config["learnapp"]["fragmentation"]
115+
if not config["learn_apply"]["fragmentation"]
116116
else "eval_apply_frag"
117117
),
118118
"seq-annotation-scores-{nb}.csv.gz",
@@ -126,7 +126,7 @@ rule all:
126126
"evaluate",
127127
(
128128
"eval_apply_reversed"
129-
if not config["learnapp"]["fragmentation"]
129+
if not config["learn_apply"]["fragmentation"]
130130
else "eval_apply_reversed_frag"
131131
),
132132
"seq-annotation-scores-{nb}.csv.gz",
@@ -149,7 +149,7 @@ use rule unzip from process with:
149149
zipped=join(input_dir, "zipped", "{uz}.gz"),
150150

151151

152-
if config["learnapp"]["fragmentation"]:
152+
if config["learn_apply"]["fragmentation"]:
153153

154154
rule fragmentation:
155155
input:
@@ -161,11 +161,11 @@ if config["learnapp"]["fragmentation"]:
161161
message:
162162
"Fragmenting sequences in {input.fasta}. Output written to {output.fasta_out}."
163163
params:
164-
version=config["learnapp"]["version"],
165-
frag_length=config["learnapp"]["frag_length"],
166-
location=config["learnapp"]["location"],
167-
min_length=config["learnapp"]["min_length"],
168-
seed=config["learnapp"]["seed"],
164+
version=config["learn_apply"]["version"],
165+
frag_length=config["learn_apply"]["frag_length"],
166+
location=config["learn_apply"]["location"],
167+
min_length=config["learn_apply"]["min_length"],
168+
seed=config["learn_apply"]["seed"],
169169
script:
170170
resource_path("snekmer", "scripts", "learn_fragment.py")
171171

@@ -224,7 +224,7 @@ rule eval_apply_reverse_seqs:
224224
data=join(
225225
out_dir,
226226
"vector",
227-
("vector" if not config["learnapp"]["fragmentation"] else "vector_frag"),
227+
("vector" if not config["learn_apply"]["fragmentation"] else "vector_frag"),
228228
"{nb}.npz",
229229
),
230230
annotation=expand("{an}", an=annot_files),
@@ -235,7 +235,7 @@ rule eval_apply_reverse_seqs:
235235
"evaluate",
236236
(
237237
"eval_apply_reversed"
238-
if not config["learnapp"]["fragmentation"]
238+
if not config["learn_apply"]["fragmentation"]
239239
else "eval_apply_reversed_frag"
240240
),
241241
"seq-annotation-scores-{nb}.csv.gz",
@@ -254,7 +254,7 @@ rule reverse_decoy_evaluations:
254254
"evaluate",
255255
(
256256
"eval_apply_reversed"
257-
if not config["learnapp"]["fragmentation"]
257+
if not config["learn_apply"]["fragmentation"]
258258
else "eval_apply_reversed_frag"
259259
),
260260
"seq-annotation-scores-{nb}.csv.gz",
@@ -276,7 +276,7 @@ rule eval_apply_sequences:
276276
data=join(
277277
out_dir,
278278
"vector",
279-
("vector" if not config["learnapp"]["fragmentation"] else "vector_frag"),
279+
("vector" if not config["learn_apply"]["fragmentation"] else "vector_frag"),
280280
"{nb}.npz",
281281
),
282282
annotation=expand("{an}", an=annot_files),
@@ -287,7 +287,7 @@ rule eval_apply_sequences:
287287
"evaluate",
288288
(
289289
"eval_apply_sequences"
290-
if not config["learnapp"]["fragmentation"]
290+
if not config["learn_apply"]["fragmentation"]
291291
else "eval_apply_frag"
292292
),
293293
"seq-annotation-scores-{nb}.csv.gz",
@@ -306,7 +306,7 @@ rule evaluate:
306306
"evaluate",
307307
(
308308
"eval_apply_sequences"
309-
if not config["learnapp"]["fragmentation"]
309+
if not config["learn_apply"]["fragmentation"]
310310
else "eval_apply_frag"
311311
),
312312
"seq-annotation-scores-{nb}.csv.gz",
@@ -320,7 +320,7 @@ rule evaluate:
320320
message:
321321
"Calculating global confidence scores based on Apply results. Output written to {output.eval_glob}."
322322
params:
323-
modifier=config["learnapp"]["conf_weight_modifier"],
323+
modifier=config["learn_apply"]["conf_weight_modifier"],
324324
script:
325325
resource_path("snekmer", "scripts", "learn_evaluate_sequences.py")
326326

snekmer/scripts/apply.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# Run script
1515
# ---------------------------------------------------------
1616

17-
weight_top = config["learnapp"].get("weight_top", 0.5)
18-
weight_distance = config["learnapp"].get("weight_distance", 0.5)
19-
save_apply_associations = config["learnapp"]["save_apply_associations"]
17+
weight_top = config["learn_apply"].get("weight_top", 0.5)
18+
weight_distance = config["learn_apply"].get("weight_distance", 0.5)
19+
save_apply_associations = config["learn_apply"]["save_apply_associations"]
2020

2121
apply = KmerCompare(
2222
snakemake.input.compare_associations,

snekmer/scripts/learn_eval_apply_sequences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def execute_all(self, config: str) -> None:
238238
kmer_counts = self.construct_kmer_counts_dataframe()
239239
kmer_counts, self.kmer_count_totals = match_kmer_counts_format(kmer_counts,self.kmer_count_totals)
240240
final_matrix_with_scores = self.calculate_cosine_similarity(kmer_counts)
241-
if not config["learnapp"]["save_apply_associations"]:
241+
if not config["learn_apply"]["save_apply_associations"]:
242242
final_matrix_with_scores = self.filter_top_two_values(
243243
final_matrix_with_scores
244244
)

snekmer/scripts/learn_evaluate_sequences.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def read_and_transform_input_data(
9696
header=0,
9797
engine="c",
9898
)
99-
threshold_type = config["learnapp"]["threshold"]
100-
selection_method = config["learnapp"]["selection"]
101-
weight_top = config["learnapp"].get("weight_top", 0.5)
102-
weight_distance = config["learnapp"].get("weight_distance", 0.5)
99+
threshold_type = config["learn_apply"]["threshold"]
100+
selection_method = config["learn_apply"]["selection"]
101+
weight_top = config["learn_apply"].get("weight_top", 0.5)
102+
weight_distance = config["learn_apply"].get("weight_distance", 0.5)
103103

104104
if threshold_type == "None":
105105
threshold_type = None

0 commit comments

Comments
 (0)