#[non_exhaustive]pub struct NormalizeConfig {
pub cross_boundaries: bool,
pub error_config: ErrorConfig,
pub window_size: u64,
pub prevent_overlap: bool,
/* private fields */
}Expand description
Configuration for variant normalization
Marked #[non_exhaustive] so adding a normalization knob is additive rather
than breaking. Build it with NormalizeConfig::new (or the
NormalizeConfig::strict / NormalizeConfig::lenient /
NormalizeConfig::silent presets) plus the with_* builders, or from
Default, rather than a struct literal; the fields stay pub, so
anything the builders do not cover is still reachable by assigning to the
field directly. Mirrors the attribute on its result-side counterpart
crate::normalize::NormalizeResult, which #1033 marked for the same
reason.
This is the type that carries the error mode — Default and
NormalizeConfig::lenient both give it ErrorConfig::lenient(). Do not
confuse it with crate::commands::NormalizeCommandConfig, which
configures the batch run around a normalization (reference directory,
progress, workers) and has no error mode at all. The two used to share the
name NormalizeConfig, so NormalizeConfig::default() resolved to
whichever one a single use line had brought into scope.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cross_boundaries: boolWhether to allow crossing exon-intron boundaries
error_config: ErrorConfigError handling configuration (controls reference validation behavior)
window_size: u64Window size for reference sequence fetching
prevent_overlap: boolVestigial overlap-prevention flag retained for source compatibility.
Overlap is now prevented structurally: normalize_allele merges
adjacent sub-variants before the per-variant pipeline runs, and
merge_consecutive_edits uses a strict prev.end + 1 == next.start
adjacency rule, so the normalizer cannot emit overlapping ranges
from non-overlapping inputs. Detection of input-time overlap is
handled unconditionally by detect_overlap_conflicts. This field
has no effect and is preserved only so existing callers (notably
with_overlap_prevention) keep compiling.
Implementations§
Source§impl NormalizeConfig
impl NormalizeConfig
Sourcepub fn for_entry_point(
direction: ShuffleDirection,
error_config: ErrorConfig,
) -> Self
pub fn for_entry_point( direction: ShuffleDirection, error_config: ErrorConfig, ) -> Self
Build the configuration for an entry point — a seam where an error mode arrives from outside the library (the CLI, the PyO3 bindings, the web service).
The direction argument is always
[ShuffleDirection::ThreePrime] at every such seam: no entry point
accepts a direction from a caller any more.
It is still a parameter so that the internal 3’/5’ differential can
build an entry-point-shaped config, and so that the #1197 lint below
keeps binding the error argument, which is what that constructor
exists for.
Both settings are required arguments, which is the whole point:
NormalizeConfig::default().with_direction(d) silently fills in every
field the caller does not name, and error_config defaults to
ErrorConfig::lenient. That is the shape that produced #1181 — the
CLI built an ErrorConfig from --error-mode, passed it into
run_normalize, and then constructed the normalizer’s config without
it, so the flag (and --ignore / --reject with it) was inert from the
initial commit through 678 commits and roughly five months. #1191 fixed
that one call site; this constructor removes the shape (#1197).
Forgetting the error configuration in this call cannot compile, just
as it cannot in the web service’s struct literal. Note the limit of that
guarantee: it binds only callers who choose this constructor. default,
new, the lenient/strict/silent presets and Normalizer::new all
remain reachable and all supply an error configuration the caller never
named, so a new entry point can still elide one and compile. What
stops it is a lint, not the type system —
tests/it/issue_1197_required_error_config.rs scans the entry-point
seams for those shapes and fails the build.
Prefer this over the builder chain at every entry point; the builder remains for library callers that deliberately want the lenient default.
§Example
use ferro_hgvs::error_handling::ErrorConfig;
use ferro_hgvs::normalize::{NormalizeConfig, ShuffleDirection};
let config =
NormalizeConfig::for_entry_point(ShuffleDirection::ThreePrime, ErrorConfig::strict());
assert_eq!(config.shuffle_direction, ShuffleDirection::ThreePrime);
assert!(config.should_reject_ref_mismatch());Sourcepub fn strict() -> Self
pub fn strict() -> Self
Create a config with strict error handling (reject reference mismatches)
Sourcepub fn lenient() -> Self
pub fn lenient() -> Self
Create a config with lenient error handling (warn on reference mismatches)
Sourcepub fn silent() -> Self
pub fn silent() -> Self
Create a config with silent error handling (ignore reference mismatches)
Sourcepub fn allow_crossing_boundaries(self) -> Self
pub fn allow_crossing_boundaries(self) -> Self
Allow crossing boundaries
Sourcepub fn with_error_mode(self, mode: ErrorMode) -> Self
pub fn with_error_mode(self, mode: ErrorMode) -> Self
Set error handling mode
Sourcepub fn with_error_config(self, error_config: ErrorConfig) -> Self
pub fn with_error_config(self, error_config: ErrorConfig) -> Self
Replace the entire error-handling configuration.
Sourcepub fn with_error_override(
self,
error_type: ErrorType,
action: ErrorOverride,
) -> Self
pub fn with_error_override( self, error_type: ErrorType, action: ErrorOverride, ) -> Self
Set a specific error type override
Sourcepub fn skip_validation(self) -> Self
👎Deprecated since 0.2.0: Use with_error_mode(ErrorMode::Silent) instead
pub fn skip_validation(self) -> Self
Use with_error_mode(ErrorMode::Silent) instead
Disable reference validation (sets RefSeqMismatch to SilentCorrect)
Sourcepub fn with_overlap_prevention(self, prevent: bool) -> Self
pub fn with_overlap_prevention(self, prevent: bool) -> Self
Set the vestigial prevent_overlap flag.
This builder is retained only for source compatibility with existing
callers. The flag has no runtime effect: overlap prevention is handled
structurally by normalize_allele, merge_consecutive_edits, and
detect_overlap_conflicts. See NormalizeConfig::prevent_overlap
for details.
Sourcepub fn ref_mismatch_action(&self) -> ResolvedAction
pub fn ref_mismatch_action(&self) -> ResolvedAction
Get the resolved action for reference sequence mismatch
Sourcepub fn should_reject_ref_mismatch(&self) -> bool
pub fn should_reject_ref_mismatch(&self) -> bool
Returns true if reference mismatches should be rejected
Sourcepub fn should_warn_ref_mismatch(&self) -> bool
pub fn should_warn_ref_mismatch(&self) -> bool
Returns true if reference mismatches should emit warnings
Sourcepub fn variant_exceeds_reference_action(&self) -> ResolvedAction
pub fn variant_exceeds_reference_action(&self) -> ResolvedAction
Get the resolved action for VariantExceedsReference (W5003) —
fires when the provider returns fewer bytes than the HGVS
interval span (the input violates HGVS spec refseq.md §43).
Closes-after: #355.
Sourcepub fn should_reject_variant_exceeds_reference(&self) -> bool
pub fn should_reject_variant_exceeds_reference(&self) -> bool
Returns true if VariantExceedsReference should be rejected
(strict mode default).
Sourcepub fn should_warn_variant_exceeds_reference(&self) -> bool
pub fn should_warn_variant_exceeds_reference(&self) -> bool
Returns true if VariantExceedsReference should emit a warning
(lenient mode default; silent mode suppresses).
Sourcepub fn position_past_end_action(&self) -> ResolvedAction
pub fn position_past_end_action(&self) -> ResolvedAction
Get the resolved action for PositionPastEnd (W4004).
Sourcepub fn should_reject_position_past_end(&self) -> bool
pub fn should_reject_position_past_end(&self) -> bool
Returns true if past-end positions should be rejected (strict mode).
Sourcepub fn should_reject_reduced_capability(&self) -> bool
pub fn should_reject_reduced_capability(&self) -> bool
Returns true if a reduced-capability (no-genomic-data) degradation
should be rejected — i.e. strict mode. Unlike the registry-backed
spec warnings, ReducedCapabilityNoGenome is an environmental
limitation rather than an input defect, so it is not user-overridable
per errors-axis; it is simply promoted to an error in strict mode and
surfaced as a warning-plus-best-effort otherwise (#1012 item 2).
Sourcepub fn should_warn_position_past_end(&self) -> bool
pub fn should_warn_position_past_end(&self) -> bool
Returns true if past-end positions should emit warnings (lenient mode).
Sourcepub fn intronic_bare_transcript_action(&self) -> ResolvedAction
pub fn intronic_bare_transcript_action(&self) -> ResolvedAction
Get the resolved action for IntronicOnBareTranscript (W4007) —
fires when an intronic offset appears on a bare transcript reference
(NM_ c. / NR_ n. with genomic_context: None). See #486 EINTRONIC.
Sourcepub fn should_reject_intronic_bare_transcript(&self) -> bool
pub fn should_reject_intronic_bare_transcript(&self) -> bool
Returns true if an intronic offset on a bare transcript should be rejected (strict mode default / errors-axis override).
Sourcepub fn should_warn_intronic_bare_transcript(&self) -> bool
pub fn should_warn_intronic_bare_transcript(&self) -> bool
Returns true if an intronic offset on a bare transcript should emit a warning (lenient mode default; silent suppresses).
Sourcepub fn overlap_conflict_action(&self) -> ResolvedAction
pub fn overlap_conflict_action(&self) -> ResolvedAction
Get the resolved action for OverlapConflictingEdits (W5002).
Sourcepub fn should_reject_overlap_conflict(&self) -> bool
pub fn should_reject_overlap_conflict(&self) -> bool
Returns true if cis-allele edits with coincident reference
bounds should be rejected (strict mode default). Closes #395
item 6 — previously the overlap.rs:88 emit site unconditionally
pushed the warning, bypassing the registry’s
always_warn_if_not_rejected policy table that declared
Strict→Reject.
Sourcepub fn unresolvable_centromere_action(&self) -> ResolvedAction
pub fn unresolvable_centromere_action(&self) -> ResolvedAction
Get the resolved action for UnresolvableCentromere (W4005).
Sourcepub fn should_reject_unresolvable_centromere(&self) -> bool
pub fn should_reject_unresolvable_centromere(&self) -> bool
Returns true if an unresolvable cen position should be rejected
(strict mode default). A centromere is an assembly-annotated region
with no sequence-derivable base, so it cannot be normalized; strict
mode promotes the UnresolvableSpecialPosition warning to an error
rather than silently echoing the input. See #488.
Sourcepub fn transcript_flank_action(&self) -> ResolvedAction
pub fn transcript_flank_action(&self) -> ResolvedAction
Get the resolved action for TranscriptFlankNotDescribable (W4006).
Sourcepub fn should_reject_transcript_flank(&self) -> bool
pub fn should_reject_transcript_flank(&self) -> bool
Returns true if a telomere marker resolving to a transcript-flank position on a genomic-reference c. should be rejected (strict default).
Sourcepub fn incomplete_cds_start_action(&self) -> ResolvedAction
pub fn incomplete_cds_start_action(&self) -> ResolvedAction
Get the resolved action for IncompleteCdsStartReference (W5004) —
fires when a c./p./r. variant is described against a transcript
whose 5’ CDS is annotated incomplete (cds_start_NF). See #972 Task 5.
Sourcepub fn should_reject_incomplete_cds_start(&self) -> bool
pub fn should_reject_incomplete_cds_start(&self) -> bool
Returns true if a c./p./r. variant against a cds_start_NF
transcript should be rejected (strict mode default).
Sourcepub fn should_warn_incomplete_cds_start(&self) -> bool
pub fn should_warn_incomplete_cds_start(&self) -> bool
Returns true if a c./p./r. variant against a cds_start_NF
transcript should emit a warning (lenient mode default; silent
suppresses).
Sourcepub fn initiator_met_canonicalization_action(&self) -> ResolvedAction
pub fn initiator_met_canonicalization_action(&self) -> ResolvedAction
Get the resolved action for InitiatorMetCanonicalization (W3022) —
fires when the canonical protein duplication form covers position 1,
the initiator methionine. See #92.
Sourcepub fn should_warn_initiator_met_canonicalization(&self) -> bool
pub fn should_warn_initiator_met_canonicalization(&self) -> bool
Returns true if the InitiatorMetCanonicalization advisory should be
surfaced as a warning.
W3022 is advisory about ferro’s own output, not a defect in the input:
p.Met1dup is spec-canonical — HGVS prioritization requires a
duplicating insertion to be described as a duplication
(general.md §56-57, protein/insertion.md §20), and the initiator
carve-outs are scoped to substitutions that destroy the ATG
(protein/substitution.md §49, checklist.md §65), which a dup does
not. The normalizer emits the warning whenever the final edit is a
Met1-covering duplication, including when the input already was one and
nothing was rewritten.
So the base mode must never promote it to an error: strict mode would
then refuse the very string strict mode emits, and normalization would
stop being idempotent. Reject from the base mode therefore maps to
“surface it”, which also keeps strict from being quieter than lenient
(ResolvedAction::should_warn is true only for WarnCorrect, i.e.
lenient).
Silent mode, and an override resolving to Accept/SilentCorrect
(--ignore W3022), suppress it. Before #1196 the push was
unconditional, so none of that worked.
An explicit Reject override also surfaces it, because the rejection
ladder in normalize_core promotes it from the warning list — the same
should_warn_* || should_reject_* emission shape the PositionPastEnd
and IncompleteCdsStartReference sites use.
Sourcepub fn should_reject_initiator_met_canonicalization(&self) -> bool
pub fn should_reject_initiator_met_canonicalization(&self) -> bool
Returns true if the InitiatorMetCanonicalization advisory should be
promoted to a hard error.
Only an explicit Reject override does this — --reject W3022 or
[error-handling] reject = ["W3022"]. The base mode never does, for the
reasons in Self::should_warn_initiator_met_canonicalization.
This is the one place the distinction matters. action_for collapses
strict-mode Default and an explicit Reject into the same
ResolvedAction::Reject, so without consulting
ErrorConfig::explicit_override the --reject direction of the knob
would be inert for this code — reintroducing, for W3022 alone, exactly
the defect #1196 exists to remove.
Trait Implementations§
Source§impl Clone for NormalizeConfig
impl Clone for NormalizeConfig
Source§fn clone(&self) -> NormalizeConfig
fn clone(&self) -> NormalizeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NormalizeConfig
impl Debug for NormalizeConfig
Source§impl Default for NormalizeConfig
impl Default for NormalizeConfig
Source§impl<'de> Deserialize<'de> for NormalizeConfig
impl<'de> Deserialize<'de> for NormalizeConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for NormalizeConfig
Source§impl PartialEq for NormalizeConfig
impl PartialEq for NormalizeConfig
Auto Trait Implementations§
impl Freeze for NormalizeConfig
impl RefUnwindSafe for NormalizeConfig
impl Send for NormalizeConfig
impl Sync for NormalizeConfig
impl Unpin for NormalizeConfig
impl UnsafeUnpin for NormalizeConfig
impl UnwindSafe for NormalizeConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.