Skip to content

Commit

Permalink
Check range due to possible rendering oddity
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 25, 2022
1 parent 4569c52 commit b0928c9
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions plugins/sequence/src/SequenceSearchAdapter/SequenceSearchAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Region,
complement,
reverse,
doesIntersect2,
} from '@jbrowse/core/util'
import { toArray } from 'rxjs/operators'

Expand All @@ -29,7 +30,7 @@ export default class extends BaseFeatureDataAdapter {
public getFeatures(query: Region, opts: BaseOptions) {
return ObservableCreate<Feature>(async observer => {
const sequenceAdapter = await this.configure()
const hw = 0
const hw = 1000
let { start: queryStart, end: queryEnd } = query
queryStart = Math.max(0, queryStart - hw)
queryEnd += hw
Expand Down Expand Up @@ -58,15 +59,18 @@ export default class extends BaseFeatureDataAdapter {
const matches = residues.matchAll(new RegExp(search, 'g'))
for (const match of matches) {
const s = queryStart + (match.index || 0)
observer.next(
new SimpleFeature({
uniqueId: `${this.id}-match-${s}-p`,
refName: query.refName,
start: s,
end: s + search.length,
strand: 1,
}),
)

if (doesIntersect2(s, s + search.length, query.start, query.end)) {
observer.next(
new SimpleFeature({
uniqueId: `${this.id}-match-${s}-p`,
refName: query.refName,
start: s,
end: s + search.length,
strand: 1,
}),
)
}
}
}
if (searchReverse) {
Expand All @@ -75,15 +79,17 @@ export default class extends BaseFeatureDataAdapter {
)
for (const match of matches) {
const s = queryStart + (match.index || 0)
observer.next(
new SimpleFeature({
uniqueId: `${this.id}-match-${s}-n`,
refName: query.refName,
start: s,
end: s + search.length,
strand: -1,
}),
)
if (doesIntersect2(s, s + search.length, query.start, query.end)) {
observer.next(
new SimpleFeature({
uniqueId: `${this.id}-match-${s}-n`,
refName: query.refName,
start: s,
end: s + search.length,
strand: -1,
}),
)
}
}
}
}
Expand Down

0 comments on commit b0928c9

Please sign in to comment.