Pattern free string

PartialRejectionSampling.PatternFreeStringType
PatternFreeString{T<:String} <: AbstractPointProcess{T}

Struct with fields

  • alphabet::Vector{String},
  • pattern::String,

used to generate strings made of characters from alphabet avoiding the prescribed pattern.

source
PartialRejectionSampling._check_extension!Method
_check_extension!(
    tmp_vec::Vector{String},
    str_vec::Vector{String},
    pattern::String,
    window::UnitRange{U}
)::UnitRange{U} where {U<:Int}

Assuming join(tmp_vec[window]) == join(str_vec[window]) == pattern, check whether a reassigment of "" elements from left or right of tmp_vec[window] can make pattern occur. If this is the case, the identified "" elements of tmp_vec are set with the corresponding elements from str_vec and the extended window where pattern can arise is returned. Otherwise the original window is returned.

source
PartialRejectionSampling._pattern_can_occur_if_reassignment_atMethod
_pattern_can_occur_if_reassignment_at(
    pattern::String,
    vec::Vector{String},
    window::UnitRange{U}
)::UnitRange{U} where {U<:Int}

Find the range of indices of window where "" elements of vec[window] can be modified to make the resulting join(vec[window]) == pattern. An empty range is returned otherwise.

source
PartialRejectionSampling.generate_sample_prsMethod
generate_sample_prs(
    [rng::Random.AbstractRNG,]
    pp::PatternFreeString{T},
    size::Int
)::T where {T<:String}

Generate a string uniformly at random among all strings made of characters from pp.alphabet with no occurence of pp.pattern, using a tailored version of Partial Rejection Sampling (PRS).

using PartialRejectionSampling
pp = PRS.PatternFreeString("ATGTA", ["A", "C", "G", "T"])
PRS.generate_sample_prs(pp, 20)

See also

source