Skip to content

Commit

Permalink
[skip ci] docs: add error catching for missing bg files in c/bg mode
Browse files Browse the repository at this point in the history
  • Loading branch information
christinehc committed May 10, 2024
1 parent 22dd1c5 commit 163239c
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions snekmer/scripts/score_with_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,31 @@

# generate family scores and object
scorer = skm.score.KmerScorer(method=config["score"]["method"])
scorer.fit(
list(basis.kmer_set.kmers),
data,
family,
bg=counts_bg,
label_col=label,
vec_col="sequence_vector",
weight_bg=config["score"]["background_weight"],
**config["score"]["scaler_kwargs"],
)
try:
scorer.fit(
list(basis.kmer_set.kmers),
data,
family,
bg=counts_bg,
label_col=label,
vec_col="sequence_vector",
weight_bg=config["score"]["background_weight"],
**config["score"]["scaler_kwargs"],
)
except TypeError as e:
raise ValueError(
"""
Snekmer model background weights detected as `None`.
This typically occurs when a score method of
`'combined'` or `'background'` is specified and no
accompanying background files are detected.
Please make sure any background files are stored in
an `input/background/` directory, or if no background
files are to be used, the `'family'` scoring method
is selected.
"""
) from e

# append scored sequences to dataframe
data = data.merge(
Expand Down

0 comments on commit 163239c

Please sign in to comment.