Skip to content

Commit 352601c

Browse files
committed
calibrate overlap validation defaults
Fix tail-side complexity scanning, align overlap-search defaults with fastp-style thresholds, and recalibrate validation presets so Normal favors consensus salvage while Strict keeps conservative mismatch rejection. Update README and benchmark docs to explain pairasm's template-centric consensus model and the intentionally apples-to-oranges nature of default tool comparisons.
1 parent bead653 commit 352601c

6 files changed

Lines changed: 64 additions & 28 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ pairasm \
7979
-1 sample_R1.fastq.gz \
8080
-2 sample_R2.fastq.gz \
8181
--min-overlap 30 \
82-
--overlap-diff-max 2 \
82+
--overlap-diff-max 5 \
8383
--diff-percent-max 0.2 \
84-
--min-complexity-score 39
84+
--min-complexity-score 30
8585
```
8686

8787
By default, merged reads are quality-corrected using the overlapping evidence from both mates. Use `--no-correct` when you want the merged sequence but do not want overlap-based quality correction.
@@ -116,6 +116,8 @@ The main operations are:
116116
- Overlap-aware quality correction, including a library mode that updates qualities without changing mate bases.
117117
- Normal no-overlap handling: a pair with no acceptable overlap is an expected outcome and not treated as a failure.
118118

119+
Unlike filtering tools that bundle merging like fastp, `pairasm` is entirely focused on overlap discovery and merging, which has important consequences for sensitivity. Whereas a tool like fastp might filter a mate because it's below quality thresholds in isolation, `pairasm` might instead "salveage" the pair, producing a merged consensus read with corrected quality scores that then passes filtering. As a result, `pairasm` will often merge considerably more pairs than `fastp` or VSEARCH with default settings. Merged corrected reads can then be considered in their own right for further filtering. A major goal for `pairasm` and `libpairassembly` was to leverage correction to turn overlapping mate evidence into more higher-confidence consensus reads.
120+
119121
## Using the library in another Rust tool
120122

121123
The library does not require applications to adopt a specific FASTQ parser. If your parser record can expose an ID, sequence, and FASTQ ASCII quality string, implement `SeqRecordView` and pass those records through `PairInput`.
@@ -130,7 +132,7 @@ fn merge_pair<R: SeqRecordView>(
130132
) -> libpairassembly::Result<Option<OwnedSequenceRead>> {
131133
let assembler = Assembler::builder()
132134
.with_overlap_params(OverlapParams::default().with_min_overlap(30))
133-
.with_validator(OverlapValidator::default().with_min_complexity_score(39))
135+
.with_validator(OverlapValidator::default().with_min_complexity_score(30))
134136
.build()?;
135137

136138
assembler

‎benches/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ cargo run -p pairasm-benches -- summarize --latest
3737

3838
Tool paths can be exported or copied into `benches/config/tools.env` from `tools.env.example`. Benchmark defaults can similarly be copied into `benches/config/benchmark.env` from `benchmark.env.example`.
3939

40-
These comparisons are not perfectly apples-to-apples yet. The tools differ in scoring, filtering, output semantics, and compression behavior. Treat the first runs as decision-support data: runtime, merged counts, and logs should guide which settings and datasets need deeper follow-up before release claims are made.
40+
It should be emphasized that these comparisons are knowingly not perfectly apples-to-apples. The tools differ in scoring, filtering, output semantics, and compression behavior. In particular, fastp's default merge output reflects both overlap detection and fastp's general read filtering, while `pairasm` is focused on overlap-based consensus assembly and does not apply the same pre-merge read-level filters. This makes default CLI comparisons useful for understanding normal tool behavior. They should not, however, be taken as a pure comparison of overlap discovery.
41+
42+
A `pairasm`-only merged read may therefore represent an intended salvage case: a pair whose individual reads look low quality, but whose overlapping evidence supports a corrected consensus. Treat benchmark results as decision-support data. Runtime, merged counts, output membership, and logs should guide which settings and datasets need deeper follow-up before release claims are made.

‎libpairassembly/src/assembler/tests/context_paths.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn test_corrected_pair_context_validates_corrected_slices() {
321321
let overlap = OverlapParams::default()
322322
.with_min_overlap(3)
323323
.with_min_comparisons(3);
324-
let validator = OverlapValidator::from_preset(ValidationPreset::Normal)
324+
let validator = OverlapValidator::from_preset(ValidationPreset::Strict)
325325
.with_k(1)
326326
.with_min_complexity_score(4);
327327
let asm = Assembler::builder()
@@ -356,7 +356,7 @@ fn test_corrected_pair_context_merges_corrected_slices() {
356356
let overlap = OverlapParams::default()
357357
.with_min_overlap(3)
358358
.with_min_comparisons(3);
359-
let validator = OverlapValidator::from_preset(ValidationPreset::Normal)
359+
let validator = OverlapValidator::from_preset(ValidationPreset::Strict)
360360
.with_k(1)
361361
.with_min_complexity_score(4);
362362
let asm = Assembler::builder()
@@ -432,7 +432,7 @@ fn test_corrected_merged_context_validates_corrected_overlap() {
432432
let overlap = OverlapParams::default()
433433
.with_min_overlap(3)
434434
.with_min_comparisons(3);
435-
let validator = OverlapValidator::from_preset(ValidationPreset::Normal)
435+
let validator = OverlapValidator::from_preset(ValidationPreset::Strict)
436436
.with_k(1)
437437
.with_min_complexity_score(4);
438438
let asm = Assembler::builder()

‎libpairassembly/src/overlap/params.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::OverlapSpan;
1616
/// .with_tie_policy(TiePolicy::PreferFromStart);
1717
///
1818
/// assert_eq!(params.min_overlap(), 40);
19-
/// assert_eq!(params.allowed_differences_for(50), 2);
19+
/// assert_eq!(params.allowed_differences_for(50), 5);
2020
/// ```
2121
#[derive(Debug, Clone, Copy)]
2222
pub struct OverlapParams {
@@ -86,10 +86,10 @@ impl TiePolicy {
8686
impl Default for OverlapParams {
8787
fn default() -> Self {
8888
OverlapParams {
89-
overlap_diff_max: 2,
89+
overlap_diff_max: 5,
9090
min_overlap: 30,
9191
diff_percent_max: 0.2,
92-
min_comparisons: 50,
92+
min_comparisons: 30,
9393
tie_policy: TiePolicy::PreferFromStart,
9494
}
9595
}

‎libpairassembly/src/validate.rs‎

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ impl Default for Strictness {
7575
}
7676

7777
impl Strictness {
78-
pub const LOOSE_STRICTNESS_COMPLEXITY: usize = 30;
79-
pub const NORMAL_STRICTNESS_COMPLEXITY: usize = 39;
80-
pub const STRICT_STRICTNESS_COMPLEXITY: usize = 44;
78+
pub const LOOSE_STRICTNESS_COMPLEXITY: usize = 24;
79+
pub const NORMAL_STRICTNESS_COMPLEXITY: usize = 30;
80+
pub const STRICT_STRICTNESS_COMPLEXITY: usize = 39;
8181

8282
fn get(&self) -> usize {
8383
match self {
@@ -146,22 +146,22 @@ impl ValidationPolicy {
146146
k: 3,
147147
strictness: Strictness::Loose(Strictness::LOOSE_STRICTNESS_COMPLEXITY),
148148
min_overlap_floor: 5,
149-
mismatch_multiplier: 8.0,
150-
mismatch_offset: 1.0,
149+
mismatch_multiplier: 10.0,
150+
mismatch_offset: 1.5,
151151
},
152152
ValidationPreset::Normal => Self {
153153
k: 3,
154154
strictness: Strictness::Normal(Strictness::NORMAL_STRICTNESS_COMPLEXITY),
155-
min_overlap_floor: 8,
156-
mismatch_multiplier: 6.0,
157-
mismatch_offset: 0.75,
155+
min_overlap_floor: 5,
156+
mismatch_multiplier: 8.0,
157+
mismatch_offset: 1.0,
158158
},
159159
ValidationPreset::Strict => Self {
160160
k: 3,
161161
strictness: Strictness::Strict(Strictness::STRICT_STRICTNESS_COMPLEXITY),
162-
min_overlap_floor: 11,
163-
mismatch_multiplier: 4.0,
164-
mismatch_offset: 0.5,
162+
min_overlap_floor: 8,
163+
mismatch_multiplier: 6.0,
164+
mismatch_offset: 0.75,
165165
},
166166
}
167167
}
@@ -688,7 +688,7 @@ mod utils {
688688
}
689689

690690
if singleton_count * 4 + doubleton_count >= minscore {
691-
return i + k;
691+
return bases.len() - i;
692692
}
693693
}
694694

@@ -777,6 +777,38 @@ mod tests {
777777
assert!(tail <= seq.len() + 1);
778778
}
779779

780+
#[test]
781+
fn test_tail_complexity_reports_bases_needed_from_tail() {
782+
let seq = b"ACGTTGCAGATCTGACCTGAATCGTACGAGTCTAGCGTATGCTAGTCGATCGTACCTGATCGAA";
783+
let reversed: Vec<_> = seq.iter().copied().rev().collect();
784+
let k = 3;
785+
786+
for min_score in [30, 39, 44] {
787+
let from_tail = utils::min_overlap_by_complexity_tail(seq, k, min_score);
788+
let from_reversed_head = utils::min_overlap_by_complexity_head(&reversed, k, min_score);
789+
790+
assert_eq!(
791+
from_tail, from_reversed_head,
792+
"tail complexity should report the number of bases needed from the tail, not a left-origin coordinate"
793+
);
794+
}
795+
}
796+
797+
#[test]
798+
fn test_tail_complexity_requirement_is_monotonic() {
799+
let seq = b"ACGTTGCAGATCTGACCTGAATCGTACGAGTCTAGCGTATGCTAGTCGATCGTACCTGATCGAA";
800+
let k = 3;
801+
802+
let loose = utils::min_overlap_by_complexity_tail(seq, k, 30);
803+
let normal = utils::min_overlap_by_complexity_tail(seq, k, 39);
804+
let strict = utils::min_overlap_by_complexity_tail(seq, k, 44);
805+
806+
assert!(
807+
loose <= normal && normal <= strict,
808+
"raising the required complexity score should not reduce the required tail overlap: loose={loose}, normal={normal}, strict={strict}"
809+
);
810+
}
811+
780812
#[test]
781813
fn test_compute_min_informative_overlap_is_bounded() {
782814
let r1 = SequenceRead::new("read1", "ACGTACGTACGT", "IIIIIIIIIIII");

‎pairassembler/src/cli.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub struct Cli {
8888
pub unmerged_out: Option<String>,
8989

9090
/// Maximum basecall mismatches permitted before a potential overlap is rejected.
91-
#[arg(long, default_value_t = 2, help_heading = "Overlap Settings")]
91+
#[arg(long, default_value_t = 5, help_heading = "Overlap Settings")]
9292
pub overlap_diff_max: usize,
9393

9494
/// Minimum number of bases that must overlap before an overlap can be accepted.
@@ -100,7 +100,7 @@ pub struct Cli {
100100
pub diff_percent_max: f32,
101101

102102
/// Minimum base comparisons required before overlap thresholds are meaningful.
103-
#[arg(long, default_value_t = 50, help_heading = "Overlap Settings")]
103+
#[arg(long, default_value_t = 30, help_heading = "Overlap Settings")]
104104
pub min_comparisons: usize,
105105

106106
/// K-mer length used when assessing overlap informativeness.
@@ -116,7 +116,7 @@ pub struct Cli {
116116
#[arg(
117117
short = 'E',
118118
long,
119-
default_value_t = 39,
119+
default_value_t = 30,
120120
help_heading = "Validation Settings"
121121
)]
122122
pub min_complexity_score: usize,
@@ -244,12 +244,12 @@ mod tests {
244244
input2: "r2.fastq".to_owned(),
245245
output_file: None,
246246
unmerged_out: None,
247-
overlap_diff_max: 2,
247+
overlap_diff_max: 5,
248248
min_overlap: 30,
249249
diff_percent_max: 0.2,
250-
min_comparisons: 50,
250+
min_comparisons: 30,
251251
k: 3,
252-
min_complexity_score: 39,
252+
min_complexity_score: 30,
253253
no_correct: false,
254254
progress_every: 100_000,
255255
summary: None,

0 commit comments

Comments
 (0)