Pattern free string
PartialRejectionSampling.PatternFreeString
— TypePatternFreeString{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
.
PartialRejectionSampling.PatternFreeString
— MethodPatternFreeString(alphabet::Vector{String}, pattern::String)
Construct a PRS.PatternFreeString
.
using PartialRejectionSampling
PRS.PatternFreeString("ATGTA", ["A", "C", "G", "T"])
# output
PatternFreeString{String}
- pattern = ATGTA
- alphabet = ["A", "C", "G", "T"]
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.
PartialRejectionSampling._pattern_can_occur_if_reassignment_at
— Method_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.
PartialRejectionSampling._pattern_free_string_prs
— Method_generate_pattern_free_string_prs(
rng::Random.AbstractRNG,
pattern::String,
alphabet::Vector{String},
size::Int
)::String
Generate a string uniformly at random among all strings made of characters from alphabet
with no occurence of the pattern pattern
, using a tailored version of Partial Rejection Sampling (PRS)
See also
- Juan Gil , Joshua Amaniampong , Jake Wellens (2018), Sections 2.1 and 4
PartialRejectionSampling.generate_sample
— Methodgenerate_sample(
[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
.
Default sampler is PRS.generate_sample_prs
.
PartialRejectionSampling.generate_sample_prs
— Methodgenerate_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
- Juan Gil , Joshua Amaniampong , Jake Wellens (2018), Sections 2.1 and 4