From 995a486c9ffdb1678148d12e18f7f5c6c41874ef Mon Sep 17 00:00:00 2001 From: Ondrej Sladky Date: Tue, 6 Aug 2024 14:04:24 +0200 Subject: [PATCH 1/2] All builtin specifications correctly recognize `boost`. --- dnachisel/builtin_specifications/AllowPrimer.py | 2 ++ dnachisel/builtin_specifications/AvoidBlastMatches.py | 2 ++ dnachisel/builtin_specifications/AvoidHeterodimerization.py | 1 + dnachisel/builtin_specifications/SequenceLengthBounds.py | 3 ++- dnachisel/builtin_specifications/UniquifyAllKmers.py | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dnachisel/builtin_specifications/AllowPrimer.py b/dnachisel/builtin_specifications/AllowPrimer.py index 1d427ff..7fe4690 100644 --- a/dnachisel/builtin_specifications/AllowPrimer.py +++ b/dnachisel/builtin_specifications/AllowPrimer.py @@ -62,6 +62,7 @@ def __init__( avoid_heterodim_with=None, max_heterodim_tm=5, avoided_repeats=((2, 5), (3, 4), (4, 3)), + boost=1.0, ): location = Location.from_data(location) specs = { @@ -86,3 +87,4 @@ def __init__( location=location, ) self.register_specifications(specs) + self.boost = boost diff --git a/dnachisel/builtin_specifications/AvoidBlastMatches.py b/dnachisel/builtin_specifications/AvoidBlastMatches.py index 3069d01..26a5994 100644 --- a/dnachisel/builtin_specifications/AvoidBlastMatches.py +++ b/dnachisel/builtin_specifications/AvoidBlastMatches.py @@ -55,6 +55,7 @@ def __init__( e_value=1e80, culling_limit=1, location=None, + boost=1.0, ): """Initialize.""" self.blast_db = blast_db @@ -68,6 +69,7 @@ def __init__( self.e_value = e_value self.ungapped = ungapped self.culling_limit = culling_limit + self.boost = boost def initialized_on_problem(self, problem, role=None): return self._copy_with_full_span_if_no_location(problem) diff --git a/dnachisel/builtin_specifications/AvoidHeterodimerization.py b/dnachisel/builtin_specifications/AvoidHeterodimerization.py index 7ea154a..4046e12 100644 --- a/dnachisel/builtin_specifications/AvoidHeterodimerization.py +++ b/dnachisel/builtin_specifications/AvoidHeterodimerization.py @@ -36,6 +36,7 @@ def __init__( self.other_primers_sequences = other_primers_sequences self.tmax = tmax self.location = location + self.boost = boost def initialized_on_problem(self, problem, role=None): return self._copy_with_full_span_if_no_location(problem) diff --git a/dnachisel/builtin_specifications/SequenceLengthBounds.py b/dnachisel/builtin_specifications/SequenceLengthBounds.py index 4024e2c..0899f23 100644 --- a/dnachisel/builtin_specifications/SequenceLengthBounds.py +++ b/dnachisel/builtin_specifications/SequenceLengthBounds.py @@ -20,9 +20,10 @@ class SequenceLengthBounds(Specification): """ best_possible_score = 0 - def __init__(self, min_length=0, max_length=None): + def __init__(self, min_length=0, max_length=None, boost=1.0): self.min_length = min_length self.max_length = max_length + self.boost = boost def evaluate(self, problem): """Return 0 if the sequence length is between the bounds, else -1""" diff --git a/dnachisel/builtin_specifications/UniquifyAllKmers.py b/dnachisel/builtin_specifications/UniquifyAllKmers.py index 2357098..040bc01 100644 --- a/dnachisel/builtin_specifications/UniquifyAllKmers.py +++ b/dnachisel/builtin_specifications/UniquifyAllKmers.py @@ -137,7 +137,7 @@ def __init__( reference = Location.from_tuple(reference) self.reference = reference self.include_reverse_complement = include_reverse_complement - self.boost = 1.0 + self.boost = boost self.localization_data = localization_data def initialized_on_problem(self, problem, role="constraint"): From df266285275643f2d67082004cce1a7c22db4031 Mon Sep 17 00:00:00 2001 From: Ondrej Sladky Date: Tue, 6 Aug 2024 14:27:18 +0200 Subject: [PATCH 2/2] AllowPrimer passes boost to subspecifications. --- dnachisel/builtin_specifications/AllowPrimer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dnachisel/builtin_specifications/AllowPrimer.py b/dnachisel/builtin_specifications/AllowPrimer.py index 7fe4690..fdbe0b2 100644 --- a/dnachisel/builtin_specifications/AllowPrimer.py +++ b/dnachisel/builtin_specifications/AllowPrimer.py @@ -67,15 +67,15 @@ def __init__( location = Location.from_data(location) specs = { "unique_sequence": UniquifyAllKmers( - k=max_homology_length, location=location + k=max_homology_length, location=location, boost=boost ), "melting_temperature": EnforceMeltingTemperature( - mini=tmin, maxi=tmax, location=location + mini=tmin, maxi=tmax, location=location, boost=boost ), **{ "repeats_%d_%d" % (k, n): AvoidPattern( - RepeatedKmerPattern(k, n), location=location + RepeatedKmerPattern(k, n), location=location, boost=boost ) for (k, n) in avoided_repeats }, @@ -85,6 +85,7 @@ def __init__( other_primers_sequences=avoid_heterodim_with, tmax=max_heterodim_tm, location=location, + boost=boost, ) self.register_specifications(specs) self.boost = boost