Skip to content

Commit

Permalink
cleanup based on PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jdidion committed Oct 6, 2023
1 parent 532c9ad commit c0e2a8a
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions src/main/scala/com/fulcrumgenomics/sv/tools/SvPileup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -392,37 +392,35 @@ object SvPileup extends LazyLogging {

// The way aligned segments are generated for a template, if we have all the reads in the expected orientation
// the segments should all come out on the same strand. Therefore any difference in strand is odd.
val positive_strand = seg1.positiveStrand
if (positive_strand != seg2.positiveStrand) {
return true
}
// Otherwise, any segment that "moves backwards" down the genome is odd, as genome position and read position
// should increase together (unless the contig is curcular).
val contig = dict(seg1.range.refIndex)
val is_circular = contig.topology.contains(Topology.Circular)
if (!is_circular && (
(positive_strand && seg2.range.start < seg1.range.end) ||
(!positive_strand && seg1.range.start < seg2.range.end)
)) {
return true
}
// If the contig is curcular and the segments span the origin, treat them as contiguous when
// calculating the distance between them.
val innerDistance = if (is_circular && positive_strand && seg2.range.end <= seg1.range.start) {
require(seg1.range.end <= contig.length)
(contig.length - seg1.range.end) + seg2.range.start
}
else if (is_circular && !positive_strand && seg1.range.end <= seg2.range.start) {
require(seg2.range.end <= contig.length)
(contig.length - seg2.range.end) + seg1.range.start
}
else if (seg1.range.start <= seg2.range.start) {
seg2.range.start - seg1.range.end
}
else {
seg1.range.start - seg2.range.end
val positiveStrand = seg1.positiveStrand
positiveStrand != seg2.positiveStrand || {
// Otherwise, any segment that "moves backwards" down the genome is odd, as genome position and read position
// should increase together (unless the contig is circular).
val contig = dict(seg1.range.refIndex)
val isCircular = contig.topology.contains(Topology.Circular)
(!isCircular && (
(positiveStrand && seg2.range.start < seg1.range.end) ||
(!positiveStrand && seg1.range.start < seg2.range.end)
)) || {
// If the contig is circular and the segments span the origin, treat them as contiguous when
// calculating the distance between them.
val innerDistance = if (isCircular && positiveStrand && seg2.range.end <= seg1.range.start) {
require(seg1.range.end <= contig.length)
(contig.length - seg1.range.end) + seg2.range.start
}
else if (isCircular && !positiveStrand && seg1.range.end <= seg2.range.start) {
require(seg2.range.end <= contig.length)
(contig.length - seg2.range.end) + seg1.range.start
}
else if (seg1.range.start <= seg2.range.start) {
seg2.range.start - seg1.range.end
}
else {
seg1.range.start - seg2.range.end
}
val maxDistance = if (seg1.origin.isInterRead(seg2.origin)) maxBetweenReadDistance else maxWithinReadDistance
innerDistance > maxDistance
}
}
val maxDistance = if (seg1.origin.isInterRead(seg2.origin)) maxBetweenReadDistance else maxWithinReadDistance
innerDistance > maxDistance
}
}

0 comments on commit c0e2a8a

Please sign in to comment.