public static bool OverlapsAlignment(this BamAlignment read1, BamAlignment read2) { var r2StartIsInR1 = read1.ContainsPosition(read2.Position, read2.RefID); var r2EndIsInR1 = read1.ContainsPosition(read2.GetLastBasePosition(), read2.RefID); var r1StartIsInR2 = read2.ContainsPosition(read1.Position, read1.RefID); var r1EndIsInR2 = read2.ContainsPosition(read1.GetLastBasePosition(), read1.RefID); return((r2StartIsInR1 || r2EndIsInR1 || r1StartIsInR2 || r1EndIsInR2)); }
public static bool ContainsPosition(this BamAlignment alignment, long position, int refId, bool startInclusive = true, bool endInclusive = true) { return(alignment.RefID == refId && (startInclusive ? alignment.Position <= position : alignment.Position < position) && (endInclusive ? alignment.GetLastBasePosition() >= position : alignment.GetLastBasePosition() > position)); }