Implement advanced primer search filtering and reference handling

This update introduces new configuration options for pair selection, including multi-match filtering, circularity settings, and reference site validation. It also enhances the search functionality to correctly identify and track repeated sequences and reference locations, improving the accuracy of primer pair identification.
This commit is contained in:
Eric Coissac committed 2026-11-03 22:43:50 +11:00
1 parent c156f11947
commit 57c2517b24
15 files changed
+2041 -9

No files matched your search

+19
View File
@@ -19,6 +19,8 @@ type SearchParams struct {
FalsePositive float64 // -x: fraction of the counterexamples it may match (0.1)
MinSpecificity float64 // -T: pairs with a lower Bs are dropped (0.6)
Circular bool // -c: sequences are circular
NoMultiMatch bool // -U: discard the primers matching several times in a sequence
Reference string // -R: identifier of an example sequence on which the amplicons are located ("" = none)
Partitions int // partitions of the k-mer counter (default 256)
TmpDir string
@@ -41,6 +43,8 @@ type SearchInfo struct {
StrictWords int // words found without error in at least StrictQuorum of the examples
MinStrict int // that quorum, in sequences
Matches int // approximate occurrences of those words
Repeated int // strict words dropped because repeated in an example (-U)
MultiMatch int // words dropped because matching several times in a sequence (-U)
Pair PairInfo
}
@@ -63,6 +67,16 @@ func Search(c *Corpus, taxa *Taxa, p SearchParams) ([]PairStats, *SearchInfo, er
return nil, nil, err
}
info := &SearchInfo{Counts: sw.Counts, StrictWords: len(sw.Words), MinStrict: sw.MinSequences}
if p.NoMultiMatch {
sw.Words, info.Repeated = DropRepeatedWords(sw.Words)
}
refIndex := -1
if p.Reference != "" {
if refIndex, err = c.IndexOfExample(p.Reference); err != nil {
return nil, info, err
}
}
words := make([]uint64, len(sw.Words))
for i, w := range sw.Words {
@@ -72,6 +86,9 @@ func Search(c *Corpus, taxa *Taxa, p SearchParams) ([]PairStats, *SearchInfo, er
if err != nil {
return nil, info, err
}
if p.NoMultiMatch {
wm, info.MultiMatch = DropMultiMatch(wm)
}
for _, w := range wm {
info.Matches += len(w.Matches)
}
@@ -85,6 +102,8 @@ func Search(c *Corpus, taxa *Taxa, p SearchParams) ([]PairStats, *SearchInfo, er
FalsePositive: p.FalsePositive,
MinSpecificity: p.MinSpecificity,
Circular: p.Circular,
Reference: refIndex,
HasReference: refIndex >= 0,
}, p.Model)
info.Pair = pinfo
return pairs, info, err