This is a test version of Biostars. For the public version, visit https://www.biostars.org.
extract_sv_reads/samblaster: explain this code please.

https://github.com/hall-lab/extract_sv_reads is a tools extracting splitter or discordant reads from a BAM or CRAM file. It's output can be used by lumy-sv to dected structural variant.

I'm trying to adapt it for my need. But I don't understand the lines 56 to 63 where it looks for spliced reads: https://github.com/hall-lab/extract_sv_reads/blob/master/src/exe/extract_sv_reads/extract_sv_reads.cpp#L56

if (mno(*left, *right) < opts.min_non_overlap) 
    continue;

if (should_check(*left, *right)) {
    if ((abs(insert_size(*left, *right)) < opts.min_indel_size)
            || ((desert(*left, *right) > 0)
                && (desert(*left, *right) - (int) std::max(0, insert_size(*left, *right))) > opts.max_unmapped_bases)) {
        continue;

The code is inspired from samblaster (SAM version) https://github.com/GregoryFaust/samblaster/blob/master/samblaster.cpp#L1119

As far as I understand, the current read is checked to it's supplementary alignements ("SA:Z:" tag). if the read and its suppl align have the same contig and the same strand then things(?) are checked. The code is a mix of variables with (un)clipped/start/end but I don't understand the real meaning of the code.

samblaster c cpp spliced-read

If the master does not understand the code then do others have a chance :-)

Dare I suggest creating an issue on GitHub in case this person does not use Biostars.

I'm not a master, but I'm too lazy to try to understand :-)

Spoken like a true programmer.

1 answer

I have posted a reply here: https://github.com/GregoryFaust/samblaster/issues/33

Log in to answer this question.