SlideShare a Scribd company logo
Indexing Text with
Approximate q-grams
Adriano Galati & Marjolijn Elsinga
Overview
• Approximate string matching
- Neighborhood generation
- Reduction to Exact Searching
- Intermediate Partitioning
• Indexing text using q-grams
• Filtration condition
• Finding approximate q-grams
- Trie data structure
- Non-deterministic automaton (NFA)
• Parameters
Approximate string matching
Text
Pattern
Goal: Retrieve all occurrences of P in T whose
edit distance is at most k
Edit distance: ),( BAed
nT ..1
mP..1
Solutions
All kinds of solutions, most investigated area
in computer science
In on-line versions of the problem the
pattern can be preprocessed, the text
cannot
Classical solution: using dynamic
programming and a matrix is O(mn)
Fill matrix where ĂŹs the minimum edit
distance between P and a suffix of T
Initialize the borders with
Fill internal cells with
Classical solution
nmC ..0,..0 jiC ,
0and ,00, == ji CiC
),,min(1
if
1,1,1,1
1,1
−−−−
−−
+
=
jijiji
jiji
CCC
TPC
Solution (2)
If text is large, on-line algorithms are not practical
and preprocessing becomes necessary
Focus: Sequence retrieving indexes, with no
restrictions on the patterns and the occurrences
Approaches:
• Neighborhood Generation
• Reduction to Exact Searching
• Intermediate Partitioning
Neighborhood Generation
Set of strings matching a pattern with k errors is
finite ( )
Therefore it can be enumerated
Each string can be searched using a
data structure
This structure is designed for exact matching
)(PUk∈
)(PUk
Neighborhood Generation (2)
+ O(n) space and construction time
- Not optimized for secondary memory
- Inefficient in space requirements
Is promising for searching short patterns
only
Reduction to Exact Searching
Indexes based on filters
Filter checks for simpler condition than the
matching condition, discarding large parts of the
text
Main principle: if two strings A and B match with k
errors and k+s non-overlapping samples are
extracted from A, then at least s of these must
appear without errors in B
Reduction to Exact Searching (2)
+ can be built in linear time and need O(n)
space
+ with some method it is possible to make
an index that takes less space then the
text itself
- Are based on suffix trees or on indexing all
the q-grams
Intermediate Partitioning
 Reduces the search to approximate search
instead of exact search
 Main principle: if two strings A and B match with
at most k errors and j disjoint substrings are
taken from A, then at least one of these appears
in B with
 Split the pattern in j pieces, search each piece
in the index allowing errors, extend the
approximate matches to complete occurrences
 jk /
 jk /
Question (Ingmar)
I think the main principle is incorrect, because if
AAABBBBBB
BBBBBBBBB
These match with k=3 errors. If we take the
disjoint substrings AAA BBB BBB so j=3. Now
they say that one of these will appear in the
other with errors. However AAA match
with 3 errors, BBB with 0 and BBB with 0
  13/3 =
Answer
The pattern is split in j pieces, each piece is
searched in the index allowing errors
AAA BBB BBB
BBB BBB BBB
We match BBB with ABB and not with AAA and
AAB, because it is not possible to match them
with more then errors, with k=3 and j=3,
unless we change the parameters
 jk /
 jk /
Intermediate Partitioning (2)
+ optimizing point between neighborhood
generating (worse with longer pieces) and
reduction to exact searching (worse with
shorter pieces)
Has been used on the patterns but not yet
on the text itself
Indexing text using q-grams
Steps:
• Filtering text
• Finding approximate q-grams
Advantages:
• Takes little space
• Has an alternative tradeoff
• User can decide what is important: saving space
or better performance
Filtration condition
Based on locating approximate matches of
pattern q-grams in text
Leads to a filtration tolerating higher error
levels compared to exact q-gram matching
Condition for an approximate match
Two strings A and B
Now: at least one string Ai appears in B with at most
errors
Only the q-grams for which this hold, will be used for
searching
kBAed ≤),(
jj AxxAxAA 12211 ... −=
 jk /
Example: Condition
A: CCTC TCTC CCCT
B: CCCC CTCT TCTC
We see: k=8
We take: j=3
Now e=2, so at least one Ai appears in B
with at most 2 errors
Question (Peter)
“Note that it is possible that , so we are
not only ‘distributing’ errors across pieces, but
also ‘removing’ some of them”
How does this work?
  kjkj <× /
Answer
A1 A2 A3x1 x2
k=5
j=3
e=1
Q-grams vs. Q-samples
Q-grams overlap
Q-samples do not overlap
String: ABCDEF
Q-grams: {ABC, BCD, CDE, DEF}
Q-samples: {ABC, DEF}
In a q-gram index all the text q-grams are stored in
increasing order
In a q-sample index only some text q-grams are
stored
Constructing q-samples
We need to extract j pieces from each potential pattern
occurrence in the text
So: a q-sample every h text-characters
We need to guarantee that j q-samples are inside any
occurrence of P
Minimal length of P = m-k 




 +−−
≤
j
qkm
h
1
Question (Jacob)
Could you please explain how the restriction
of h is built up?
Answer
j
qkm
h
j
qkm
j
n
qkmn
qPn
q
1
1
1
1
1textsamples-q#
+−−
≤
+−−
≤
+−−≤
+−≤
+−=
Next step
Best match distance (bed) is calculated for
each test sequence of q-samples
This is the distance between the q-sample
sequence and the involved text (h)
The text area h is only examined if its bed is
at most k
Algorithm
Each q-sample sequence has its own counter M
M indicates the number of errors produced by the
q-sample sequence and is initialized to
So: we start by assuming that each q-sample
gives enough errors to disallow a match
)1( += ejM
Error-environment
After calculating the M for each q-sample
sequence, we obtain the e-environment of
each q-sample sequence
This is the set of possible q-samples that
appear inside the q-sample sequence with
at most e errors
Finishing
Now all text areas have its own e-
environments connected to it through the q-
samples
They can be checked with dynamic
programming
Finding approximate q-grams
Finding all the text q-samples that appear inside a
given pattern block
Note: it is not necessary to generate all since
we are interested only in the text q-samples
(position)
( ) { 1.. / , ( , ) }q
e r iI Q r n h bed d Q e= ∈ ≤  
iQ
( )q
e iU Q
Finding approximate q-grams (2)
 Idea: to store all the different text q-samples in a
trie data structure
 We fill in a matrix such that is the
sed between and a suffix of
 is relevant for some
 In a trie traversal of the q-samples, the characters
of are obtained one by one
l
1..iS 1..lQ
S ,q lC e⇔ ≤ l
S
0.. ,0..| |q QC
Question (Laurence)
 Can you please show me the matrix is
build on page section 3 in fig. 4? It is a bit
unclear to me how the matrix is initialized
and the different cells are being filled.
Answer
i jS Q=,i jC if= then 1, 1i jC − − else 1, 1, 1 , 11 min( , , )i j i j i jC C C− − − −+
Answer
s
u
r
v
e
y
1
2
3
0
1
2
34
5
0 0
4
56
s
1
2
1
1
2
2
21
2
0 0
1
22
eg
1
0
1
1
1
0
12
3
0 0
2
34
ru
1
2
2
1
2
3
33
2
0 0
3
22
yr
Finding approximate q-grams (4)
When we reach the leaf nodes (depth q) we check
in if there is a cell with value the
corresponding text is reported
Complexity
e≤ ⇒
(| | ) ( )O Q q O mq=
Finding approximate q-grams (3)
Pruning:
• All the value of a row to the next are nondecreasing
• If all the values of a row are larger than at that
point we can abandon that branch of the trie
e
Finding approximate q-grams (5)
Alternative way:
• To model the search with a non-deterministic
automaton (NFA)
Finding approximate q-grams (6)
Consider the NFA for errors
Every row denotes the number of errors seen
Every column represents matching a prefix of S
Horizontal arrows represent matching a
character
All the others increment the number of errors
2e =
Question (Bogdan)
I can imagine how the trie can be used together with the
matrix in order to benefit from common prefixes of
certain q-samples (by reusing the rows of the matrix
which are already computed for the common prefix).
However, I don't see how this can be done in the case of
the NFA. If it can't be done, this would mean that the
algorithm has to be run separately for each q-tuple,
which probably makes the NFA approach much worse.
Am I right to think that or is there a way to run the NFA in
a "smarter" way so as to benefit from common prefixes?
Bogdam (answer)
 Yes, you are right, the algorithm has to run for
each q-tuple, but you have to consider the
complexity of it, that is linear ( )O e
Parameters of the Problem
 Smaller value the search of e-environment
will be cheaper
 Larger value gives more exact estimates of the
actual number of error but with a higher cost to
search the e-environment
 As grows, longer test sequences with less
errors per piece are used the cost to find the
relevant q-samples decreases but the amount of
text verification increases.
⇒e
e
j
⇒
Parameters of the Problem (2)
1. Notice: the index of this approach only
stores non-overlapping q-samples, its
space requirement is small
2. Notice: the space consumption of index
depends on the interval h
Parameters of the Problem (3)
 Standard implementation q-gram index stores all
the locations of all the q-grams of the text
 The number of q-grams
 Storing a position takes
 space consumption is
 Ratio between this method and standard
approach
1n q= − +
log n
⇒ logn n
/ log( / ) 1
log
r
n h n h
v
n n h
= ≈
Question (Bogdan)
 Could you please explain what the
"columns" used in the 5th section are?
 The table shows how the error level
increases the number of processed
columns of matrix or NFA
Question (Lee/Bram)
 The article talks about disjoint non overlapping
q-grams. At the end they say that will probably
enhance the scheme that they allow overlapping
q-grams. Any idea how our current algorithms
have to be changed for that and what the
advantages are?
 http://www.cs.utexas.edu/users/mobios/MoBIoS
Papers/2003-IndexingProteinSequences-TR-04-
06.pdf
Question (Lee)
In the second paragraph of section 4 they
say “In that particular case we can avoid
the use of counters…” Can you explain
that ?
Answer
The error counters M are initialized at a high value
After that all pattern-blocks are compared to the
corresponding text piece and the counter value is
updated to a lower value
In this particular case, when e = the error counter
can get as low as k+1, which is higher than the initial
value
 jk /
Any other questions?

More Related Content

What's hot (19)

PDF
25010001
Premavardhan Reddy
 
PDF
220exercises2
sadhanakumble
 
PDF
Quantum Noise and Error Correction
Daniel Bulhosa SolĂłrzano
 
PDF
Quantum Computation and the Stabilizer Formalism for Error Correction
Daniel Bulhosa SolĂłrzano
 
PDF
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
ijscmc
 
PDF
Nonlinear Algebraic Systems with Three Unknown Variables
IJRES Journal
 
PDF
Seminar Report (Final)
Aruneel Das
 
PDF
Polynomial Tensor Sketch for Element-wise Matrix Function (ICML 2020)
ALINLAB
 
PDF
Computational intelligence based simulated annealing guided key generation in...
ijitjournal
 
PDF
Jensen's inequality, EM 알고리즘
Jungkyu Lee
 
PPT
Presentacion limac-unc
Pucheta Julian
 
PDF
Unequal-Cost Prefix-Free Codes
Daniel Bulhosa SolĂłrzano
 
PDF
FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS
roymeister007
 
PPTX
Statistical Physics Assignment Help
Statistics Assignment Help
 
PDF
Density Based Clustering
SSA KPI
 
PDF
audition wrutings. draft
NeverMora
 
PDF
1404.1503
John Mendoza GarcĂ­a
 
PPTX
Stochastic Processes Homework Help
Statistics Assignment Help
 
PDF
Grovers Algorithm
CaseyHaaland
 
25010001
Premavardhan Reddy
 
220exercises2
sadhanakumble
 
Quantum Noise and Error Correction
Daniel Bulhosa SolĂłrzano
 
Quantum Computation and the Stabilizer Formalism for Error Correction
Daniel Bulhosa SolĂłrzano
 
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
ijscmc
 
Nonlinear Algebraic Systems with Three Unknown Variables
IJRES Journal
 
Seminar Report (Final)
Aruneel Das
 
Polynomial Tensor Sketch for Element-wise Matrix Function (ICML 2020)
ALINLAB
 
Computational intelligence based simulated annealing guided key generation in...
ijitjournal
 
Jensen's inequality, EM 알고리즘
Jungkyu Lee
 
Presentacion limac-unc
Pucheta Julian
 
Unequal-Cost Prefix-Free Codes
Daniel Bulhosa SolĂłrzano
 
FINITE DIFFERENCE MODELLING FOR HEAT TRANSFER PROBLEMS
roymeister007
 
Statistical Physics Assignment Help
Statistics Assignment Help
 
Density Based Clustering
SSA KPI
 
audition wrutings. draft
NeverMora
 
Stochastic Processes Homework Help
Statistics Assignment Help
 
Grovers Algorithm
CaseyHaaland
 

Similar to Indexing Text with Approximate q-grams (20)

PPT
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
RAtna29
 
PDF
USING ADAPTIVE AUTOMATA IN GRAMMAR-BASED TEXT COMPRESSION TO IDENTIFY FREQUEN...
ijcsit
 
PDF
Using Adaptive Automata in Grammar Based Text Compression to Identify Frequen...
AIRCC Publishing Corporation
 
PDF
Using Adaptive Automata In Grammar-Based Text Compression To Identify Frequen...
AIRCC Publishing Corporation
 
PDF
Lecture10.pdf
tmmwj1
 
PPTX
String Matching (Naive,Rabin-Karp,KMP)
Aditya pratap Singh
 
PPT
Designing A Syntax Based Retrieval System03
Avelin Huo
 
PPT
String matching algorithms
Dr Shashikant Athawale
 
PPTX
String Matching Algorithms: Naive, KMP, Rabin-Karp
NAtional Institute of TEchnology Rourkela , Galgotias University
 
PDF
Iaetsd effective method for searching substrings in large databases
Iaetsd Iaetsd
 
PDF
Pattern matching programs
akruthi k
 
PPTX
String Matching Finite Automata & KMP Algorithm.
Malek Sumaiya
 
PPT
String kmp
thinkphp
 
PPT
chap09alg.ppt for string matching algorithm
SadiaSharmin40
 
PDF
Proposed Method for String Transformation using Probablistic Approach
Editor IJMTER
 
PDF
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
ijceronline
 
PPT
String matching algorithm
Alokeparna Choudhury
 
PPTX
String Searching and Matching
Umma Khatuna Jannat
 
PPT
Chap09alg
Munkhchimeg
 
PPT
Chap09alg
Munhchimeg
 
4888009.pptnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
RAtna29
 
USING ADAPTIVE AUTOMATA IN GRAMMAR-BASED TEXT COMPRESSION TO IDENTIFY FREQUEN...
ijcsit
 
Using Adaptive Automata in Grammar Based Text Compression to Identify Frequen...
AIRCC Publishing Corporation
 
Using Adaptive Automata In Grammar-Based Text Compression To Identify Frequen...
AIRCC Publishing Corporation
 
Lecture10.pdf
tmmwj1
 
String Matching (Naive,Rabin-Karp,KMP)
Aditya pratap Singh
 
Designing A Syntax Based Retrieval System03
Avelin Huo
 
String matching algorithms
Dr Shashikant Athawale
 
String Matching Algorithms: Naive, KMP, Rabin-Karp
NAtional Institute of TEchnology Rourkela , Galgotias University
 
Iaetsd effective method for searching substrings in large databases
Iaetsd Iaetsd
 
Pattern matching programs
akruthi k
 
String Matching Finite Automata & KMP Algorithm.
Malek Sumaiya
 
String kmp
thinkphp
 
chap09alg.ppt for string matching algorithm
SadiaSharmin40
 
Proposed Method for String Transformation using Probablistic Approach
Editor IJMTER
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
ijceronline
 
String matching algorithm
Alokeparna Choudhury
 
String Searching and Matching
Umma Khatuna Jannat
 
Chap09alg
Munkhchimeg
 
Chap09alg
Munhchimeg
 
Ad

Recently uploaded (20)

PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
July Patch Tuesday
Ivanti
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Biography of Daniel Podor.pdf
Daniel Podor
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Ad

Indexing Text with Approximate q-grams

  • 1. Indexing Text with Approximate q-grams Adriano Galati & Marjolijn Elsinga
  • 2. Overview • Approximate string matching - Neighborhood generation - Reduction to Exact Searching - Intermediate Partitioning • Indexing text using q-grams • Filtration condition • Finding approximate q-grams - Trie data structure - Non-deterministic automaton (NFA) • Parameters
  • 3. Approximate string matching Text Pattern Goal: Retrieve all occurrences of P in T whose edit distance is at most k Edit distance: ),( BAed nT ..1 mP..1
  • 4. Solutions All kinds of solutions, most investigated area in computer science In on-line versions of the problem the pattern can be preprocessed, the text cannot Classical solution: using dynamic programming and a matrix is O(mn)
  • 5. Fill matrix where ĂŹs the minimum edit distance between P and a suffix of T Initialize the borders with Fill internal cells with Classical solution nmC ..0,..0 jiC , 0and ,00, == ji CiC ),,min(1 if 1,1,1,1 1,1 −−−− −− + = jijiji jiji CCC TPC
  • 6. Solution (2) If text is large, on-line algorithms are not practical and preprocessing becomes necessary Focus: Sequence retrieving indexes, with no restrictions on the patterns and the occurrences Approaches: • Neighborhood Generation • Reduction to Exact Searching • Intermediate Partitioning
  • 7. Neighborhood Generation Set of strings matching a pattern with k errors is finite ( ) Therefore it can be enumerated Each string can be searched using a data structure This structure is designed for exact matching )(PUk∈ )(PUk
  • 8. Neighborhood Generation (2) + O(n) space and construction time - Not optimized for secondary memory - Inefficient in space requirements Is promising for searching short patterns only
  • 9. Reduction to Exact Searching Indexes based on filters Filter checks for simpler condition than the matching condition, discarding large parts of the text Main principle: if two strings A and B match with k errors and k+s non-overlapping samples are extracted from A, then at least s of these must appear without errors in B
  • 10. Reduction to Exact Searching (2) + can be built in linear time and need O(n) space + with some method it is possible to make an index that takes less space then the text itself - Are based on suffix trees or on indexing all the q-grams
  • 11. Intermediate Partitioning  Reduces the search to approximate search instead of exact search  Main principle: if two strings A and B match with at most k errors and j disjoint substrings are taken from A, then at least one of these appears in B with  Split the pattern in j pieces, search each piece in the index allowing errors, extend the approximate matches to complete occurrences  jk /  jk /
  • 12. Question (Ingmar) I think the main principle is incorrect, because if AAABBBBBB BBBBBBBBB These match with k=3 errors. If we take the disjoint substrings AAA BBB BBB so j=3. Now they say that one of these will appear in the other with errors. However AAA match with 3 errors, BBB with 0 and BBB with 0   13/3 =
  • 13. Answer The pattern is split in j pieces, each piece is searched in the index allowing errors AAA BBB BBB BBB BBB BBB We match BBB with ABB and not with AAA and AAB, because it is not possible to match them with more then errors, with k=3 and j=3, unless we change the parameters  jk /  jk /
  • 14. Intermediate Partitioning (2) + optimizing point between neighborhood generating (worse with longer pieces) and reduction to exact searching (worse with shorter pieces) Has been used on the patterns but not yet on the text itself
  • 15. Indexing text using q-grams Steps: • Filtering text • Finding approximate q-grams Advantages: • Takes little space • Has an alternative tradeoff • User can decide what is important: saving space or better performance
  • 16. Filtration condition Based on locating approximate matches of pattern q-grams in text Leads to a filtration tolerating higher error levels compared to exact q-gram matching
  • 17. Condition for an approximate match Two strings A and B Now: at least one string Ai appears in B with at most errors Only the q-grams for which this hold, will be used for searching kBAed ≤),( jj AxxAxAA 12211 ... −=  jk /
  • 18. Example: Condition A: CCTC TCTC CCCT B: CCCC CTCT TCTC We see: k=8 We take: j=3 Now e=2, so at least one Ai appears in B with at most 2 errors
  • 19. Question (Peter) “Note that it is possible that , so we are not only ‘distributing’ errors across pieces, but also ‘removing’ some of them” How does this work?   kjkj <× /
  • 20. Answer A1 A2 A3x1 x2 k=5 j=3 e=1
  • 21. Q-grams vs. Q-samples Q-grams overlap Q-samples do not overlap String: ABCDEF Q-grams: {ABC, BCD, CDE, DEF} Q-samples: {ABC, DEF} In a q-gram index all the text q-grams are stored in increasing order In a q-sample index only some text q-grams are stored
  • 22. Constructing q-samples We need to extract j pieces from each potential pattern occurrence in the text So: a q-sample every h text-characters We need to guarantee that j q-samples are inside any occurrence of P Minimal length of P = m-k       +−− ≤ j qkm h 1
  • 23. Question (Jacob) Could you please explain how the restriction of h is built up?
  • 25. Next step Best match distance (bed) is calculated for each test sequence of q-samples This is the distance between the q-sample sequence and the involved text (h) The text area h is only examined if its bed is at most k
  • 26. Algorithm Each q-sample sequence has its own counter M M indicates the number of errors produced by the q-sample sequence and is initialized to So: we start by assuming that each q-sample gives enough errors to disallow a match )1( += ejM
  • 27. Error-environment After calculating the M for each q-sample sequence, we obtain the e-environment of each q-sample sequence This is the set of possible q-samples that appear inside the q-sample sequence with at most e errors
  • 28. Finishing Now all text areas have its own e- environments connected to it through the q- samples They can be checked with dynamic programming
  • 29. Finding approximate q-grams Finding all the text q-samples that appear inside a given pattern block Note: it is not necessary to generate all since we are interested only in the text q-samples (position) ( ) { 1.. / , ( , ) }q e r iI Q r n h bed d Q e= ∈ ≤   iQ ( )q e iU Q
  • 30. Finding approximate q-grams (2)  Idea: to store all the different text q-samples in a trie data structure  We fill in a matrix such that is the sed between and a suffix of  is relevant for some  In a trie traversal of the q-samples, the characters of are obtained one by one l 1..iS 1..lQ S ,q lC e⇔ ≤ l S 0.. ,0..| |q QC
  • 31. Question (Laurence)  Can you please show me the matrix is build on page section 3 in fig. 4? It is a bit unclear to me how the matrix is initialized and the different cells are being filled.
  • 32. Answer i jS Q=,i jC if= then 1, 1i jC − − else 1, 1, 1 , 11 min( , , )i j i j i jC C C− − − −+
  • 34. Finding approximate q-grams (4) When we reach the leaf nodes (depth q) we check in if there is a cell with value the corresponding text is reported Complexity e≤ ⇒ (| | ) ( )O Q q O mq=
  • 35. Finding approximate q-grams (3) Pruning: • All the value of a row to the next are nondecreasing • If all the values of a row are larger than at that point we can abandon that branch of the trie e
  • 36. Finding approximate q-grams (5) Alternative way: • To model the search with a non-deterministic automaton (NFA)
  • 37. Finding approximate q-grams (6) Consider the NFA for errors Every row denotes the number of errors seen Every column represents matching a prefix of S Horizontal arrows represent matching a character All the others increment the number of errors 2e =
  • 38. Question (Bogdan) I can imagine how the trie can be used together with the matrix in order to benefit from common prefixes of certain q-samples (by reusing the rows of the matrix which are already computed for the common prefix). However, I don't see how this can be done in the case of the NFA. If it can't be done, this would mean that the algorithm has to be run separately for each q-tuple, which probably makes the NFA approach much worse. Am I right to think that or is there a way to run the NFA in a "smarter" way so as to benefit from common prefixes?
  • 39. Bogdam (answer)  Yes, you are right, the algorithm has to run for each q-tuple, but you have to consider the complexity of it, that is linear ( )O e
  • 40. Parameters of the Problem  Smaller value the search of e-environment will be cheaper  Larger value gives more exact estimates of the actual number of error but with a higher cost to search the e-environment  As grows, longer test sequences with less errors per piece are used the cost to find the relevant q-samples decreases but the amount of text verification increases. ⇒e e j ⇒
  • 41. Parameters of the Problem (2) 1. Notice: the index of this approach only stores non-overlapping q-samples, its space requirement is small 2. Notice: the space consumption of index depends on the interval h
  • 42. Parameters of the Problem (3)  Standard implementation q-gram index stores all the locations of all the q-grams of the text  The number of q-grams  Storing a position takes  space consumption is  Ratio between this method and standard approach 1n q= − + log n ⇒ logn n / log( / ) 1 log r n h n h v n n h = ≈
  • 43. Question (Bogdan)  Could you please explain what the "columns" used in the 5th section are?  The table shows how the error level increases the number of processed columns of matrix or NFA
  • 44. Question (Lee/Bram)  The article talks about disjoint non overlapping q-grams. At the end they say that will probably enhance the scheme that they allow overlapping q-grams. Any idea how our current algorithms have to be changed for that and what the advantages are?  http://www.cs.utexas.edu/users/mobios/MoBIoS Papers/2003-IndexingProteinSequences-TR-04- 06.pdf
  • 45. Question (Lee) In the second paragraph of section 4 they say “In that particular case we can avoid the use of counters…” Can you explain that ?
  • 46. Answer The error counters M are initialized at a high value After that all pattern-blocks are compared to the corresponding text piece and the counter value is updated to a lower value In this particular case, when e = the error counter can get as low as k+1, which is higher than the initial value  jk /