Skip to content

Commit

Permalink
Merge pull request #1860 from GMOD/fix_filter_jexl
Browse files Browse the repository at this point in the history
Fix alignments read filter jexl syntax
  • Loading branch information
rbuels authored Mar 31, 2021
2 parents 17e0ed1 + 9c70dc6 commit 322c211
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/alignments/src/LinearPileupDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ const stateModelFactory = (
if (self.filterBy.tagFilter) {
const { tag, value } = self.filterBy.tagFilter
filters.push(
`jexl:"${value}" =='*' ? getTag(feature,"${tag}") != undefined : getTag(feature,"${tag}") == "${value}")`,
`jexl:"${value}" =='*' ? getTag(feature,"${tag}") != undefined : getTag(feature,"${tag}") == "${value}"`,
)
}
if (self.filterBy.readName) {
Expand Down
13 changes: 9 additions & 4 deletions plugins/alignments/src/LinearSNPCoverageDisplay/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,30 @@ const stateModelFactory = (
},
// The SNPCoverage filters are called twice because the BAM/CRAM features
// pass filters and then the SNPCoverage score features pass through
// here, and those have no name/flags/tags so those are passed thru
// here, and are already have 'snpinfo' are passed through
get filters() {
let filters: string[] = []
if (self.filterBy) {
const { flagInclude, flagExclude } = self.filterBy
filters = [
`jexl:get(feature,'snpinfo') != undefined ? true : ((get(feature,'flags')&${flagInclude})==${flagInclude}) && !(get(feature,'flags')&${flagExclude})`,
`jexl:get(feature,'snpinfo') != undefined ? true : ` +
`((get(feature,'flags')&${flagInclude})==${flagInclude}) && ` +
`!((get(feature,'flags')&${flagExclude}))`,
]

if (self.filterBy.tagFilter) {
const { tag, value } = self.filterBy.tagFilter
filters.push(
`jexl:get(feature,'snpinfo') ? true : "${value}" =='*' ? getTag(feature,"${tag}") != undefined : getTag(feature,"${tag}") == "${value}")`,
`jexl:get(feature,'snpinfo') != undefined ? true : ` +
`"${value}" =='*' ? getTag(feature,"${tag}") != undefined : ` +
`getTag(feature,"${tag}") == "${value}"`,
)
}
if (self.filterBy.readName) {
const { readName } = self.filterBy
filters.push(
`jexl:get(feature,'snpinfo') ? true : get(feature,'name') == "${readName}"`,
`jexl:get(feature,'snpinfo') != undefined ? true : ` +
`get(feature,'name') == "${readName}"`,
)
}
}
Expand Down

0 comments on commit 322c211

Please sign in to comment.