Skip to content

Commit

Permalink
Fix crash with very long features (GMOD#282)
Browse files Browse the repository at this point in the history
* limit feature min max to 500000 bp

* feature min max limit

* change
  • Loading branch information
shashankbrgowda authored Oct 25, 2023
1 parent c5d7c0a commit cfbaa39
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export function layoutsModelFactory(
const BaseLinearApolloDisplay = baseModelFactory(pluginManager, configSchema)

return BaseLinearApolloDisplay.named('LinearApolloDisplayLayouts')
.props({
featuresMinMaxLimit: 500_000,
})
.volatile(() => ({
seenFeatures: observable.map<string, AnnotationFeatureI>(),
}))
Expand All @@ -31,7 +34,8 @@ export function layoutsModelFactory(
for (const [, feature] of self.seenFeatures) {
if (
refName !== assembly?.getCanonicalRefName(feature.refSeq) ||
!doesIntersect2(start, end, feature.min, feature.max)
!doesIntersect2(start, end, feature.min, feature.max) ||
feature.length > self.featuresMinMaxLimit
) {
continue
}
Expand Down Expand Up @@ -118,9 +122,13 @@ export function layoutsModelFactory(
feature.max - feature.min === 0
? feature.min + 1
: feature.max
return rowForFeature
.slice(feature.min - min, featureMax - min)
.some(Boolean)
let start = feature.min - min,
end = featureMax - min
if (feature.min - min < 0) {
start = 0
end = featureMax - feature.min
}
return rowForFeature.slice(start, end).some(Boolean)
})
.some(Boolean)
) {
Expand All @@ -133,7 +141,13 @@ export function layoutsModelFactory(
rowNum++
) {
const row = rows[rowNum]
row.fill(true, feature.min - min, feature.max - min)
let start = feature.min - min,
end = feature.max - min
if (feature.min - min < 0) {
start = 0
end = feature.max - feature.min
}
row.fill(true, start, end)
const layoutRow = featureLayout.get(rowNum)
layoutRow?.push([rowNum - startingRow, feature])
}
Expand Down

0 comments on commit cfbaa39

Please sign in to comment.