jguhlin / minimap2-rs

Rust bindings to minimap2 library
Other
60 stars 13 forks source link

Question: Can we force a mapping to _not_ have soft-clippings? #67

Open holtjma opened 1 month ago

holtjma commented 1 month ago

Hey @jguhlin,

Apologies if this is a naive question: I'm wondering if there's a programmatic way to tell the mapper not to allow soft-clippings, and to instead force the alignment of the ends (even if it's "bad"). I have a situation where there is a variant near the end of a sequence I'm mapping (within 3bp), and I'd like it to still map that component without clipping. Instead, it's soft-clipping the whole 3bp piece.

I think I can come behind and hack a mini-aligner for that fragment, but I was hoping there was some programmatic way to disable soft-clipping within the interface. Is there some hidden parameter in the MapOpt that might control this? Or is there some parameter controlling to cost of soft-clipping that I can set super higher? Or some other idea that will get the same desired result?

Matt

jrharting commented 1 month ago

hey Matt,

I was able to handle this HLA by increasing the match score. None of my tests changed in that case, but you would want to check.

22 /// Slightly modified Aligner for longer sequences 23 /// Increasing only the matching score from 1 ->2 for map-hifi because it seems 24 /// to capture the last couple bases when there is a mismatch at the end 25 pub fn get_g_aligner(seq: &[u8], threads: usize) -> Aligner { 26 let aligner = Aligner { 27 mapopt: MapOpt { 28 a: 2, 29 ..Aligner::builder().map_hifi().mapopt 30 }, 31 ..Aligner::builder().map_hifi() 32 } 33 .with_index_threads(threads) 34 .with_cigar() 35 .with_seq(seq);

On Tue, Aug 6, 2024 at 1:19 PM Matt Holt @.***> wrote:

Hey @jguhlin https://github.com/jguhlin,

Apologies if this is a naive question: I'm wondering if there's a programmatic way to tell the mapper not to allow soft-clippings, and to instead force the alignment of the ends (even if it's "bad"). I have a situation where there is a variant near the end of a sequence I'm mapping (within 3bp), and I'd like it to still map that component without clipping. Instead, it's soft-clipping the whole 3bp piece.

I think I can come behind and hack a mini-aligner for that fragment, but I was hoping there was some programmatic way to disable soft-clipping within the interface. Is there some hidden parameter in the MapOpt that might control this? Or is there some parameter controlling to cost of soft-clipping that I can set super higher? Or some other idea that will get the same desired result?

Matt

— Reply to this email directly, view it on GitHub https://github.com/jguhlin/minimap2-rs/issues/67, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3N5UIUYZGHAKQ2QDJVTYTZQEVUPAVCNFSM6AAAAABMDBGP3SVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TCNRSGUZTEMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

holtjma commented 1 month ago

Ah, that will probably work, but I will need to try it of course. I'll leave this open in case Joseph has some other ideas for managing this edge case.