Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 14, 2024
1 parent 9233a8f commit 3bfca11
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 23 deletions.
5 changes: 0 additions & 5 deletions plugins/alignments/src/BamAdapter/BamAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ export default class BamAdapter extends BaseFeatureDataAdapter {
readName,
} = filterBy || {}

let hits = 0
let nohits = 0
for (const record of records) {
let ref: string | undefined
if (!record.tags.MD) {
Expand Down Expand Up @@ -228,16 +226,13 @@ export default class BamAdapter extends BaseFeatureDataAdapter {
const ret = this.featureCache.get(`${record.id}`)

if (!ret) {
nohits++
const elt = new BamSlightlyLazyFeature(record, this, ref)
this.featureCache.set(`${record.id}`, elt)
observer.next(elt)
} else {
hits++
observer.next(ret)
}
}
console.log({ hits, nohits })
observer.complete()
})
}, signal)
Expand Down
6 changes: 2 additions & 4 deletions plugins/alignments/src/BamAdapter/BamSlightlyLazyFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import {
import { BamRecord } from '@gmod/bam'

// locals
import { getMismatches, parseCigar } from '../MismatchParser'
import { getMismatches } from '../MismatchParser'
import BamAdapter from './BamAdapter'
import { cacheGetter } from '../shared/util'
import { getTagAlt } from '../util'
import { getModPositions, getModProbabilities } from '../ModificationParser'
import { getMaxProbModAtEachPosition } from '../shared/getMaximumModificationAtEachPosition'
import { getMaxProbModAtEachPosition } from '../shared/getMaxProbModAtEachPosition'

export default class BamSlightlyLazyFeature implements Feature {
// uses parameter properties to automatically create fields on the class
Expand Down
5 changes: 0 additions & 5 deletions plugins/alignments/src/CramAdapter/CramAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ export default class CramAdapter extends BaseFeatureDataAdapter {
tagFilter,
readName,
} = filterBy || {}
let hits = 0
let nohits = 0
for (const record of records) {
const flags = record.flags
if ((flags & flagInclude) !== flagInclude && !(flags & flagExclude)) {
Expand Down Expand Up @@ -276,16 +274,13 @@ export default class CramAdapter extends BaseFeatureDataAdapter {
// can be re-used across blocks
const ret = this.featureCache.get(`${record.uniqueId}`)
if (!ret) {
nohits++
const elt = this.cramRecordToFeature(record)
this.featureCache.set(`${record.uniqueId}`, elt)
observer.next(elt)
} else {
hits++
observer.next(ret)
}
}
console.log({ nohits, hits })

observer.complete()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readFeaturesToCIGAR, readFeaturesToMismatches } from './util'
import { parseCigar } from '../MismatchParser'
import { mdToMismatches } from '../MismatchParser/mdToMismatches'
import { cacheGetter } from '../shared/util'
import { getMaxProbModAtEachPosition } from '../shared/getMaximumModificationAtEachPosition'
import { getMaxProbModAtEachPosition } from '../shared/getMaxProbModAtEachPosition'

export default class CramSlightlyLazyFeature implements Feature {
// uses parameter properties to automatically create fields on the class
Expand Down Expand Up @@ -146,7 +146,6 @@ export default class CramSlightlyLazyFeature implements Feature {
}

get modifications() {
console.log('here')
return getMaxProbModAtEachPosition(this)
}

Expand Down
1 change: 0 additions & 1 deletion plugins/alignments/src/PileupRenderer/renderAlignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export function renderAlignment({
}

case 'modifications': {
const cigarOps = parseCigar(feature.get('CIGAR'))
renderModifications({
ctx,
feat,
Expand Down
4 changes: 2 additions & 2 deletions plugins/alignments/src/PileupRenderer/renderModifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { bpSpanPx, max, sum } from '@jbrowse/core/util'
import { fillRect, LayoutFeature } from './util'
import { RenderArgsWithColor } from './makeImageData'
import { alphaColor } from '../shared/util'
import { MaximumProbabilityMod } from '../shared/getMaximumModificationAtEachPosition'
import { MaxProbMod } from '../shared/getMaxProbModAtEachPosition'

// render modifications stored in MM tag in BAM
export function renderModifications({
Expand Down Expand Up @@ -35,7 +35,7 @@ export function renderModifications({
const isolatedModification = colorBy?.modifications?.isolatedModification
const twoColor = colorBy?.modifications?.twoColor

;(feature.get('modifications') as MaximumProbabilityMod[])?.forEach(
;(feature.get('modifications') as MaxProbMod[] | undefined)?.forEach(
({ allProbs, prob, type }, pos) => {
const r = start + pos
const [leftPx, rightPx] = bpSpanPx(r, r + 1, region, bpPerPx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
PreBaseCoverageBinSubtypes,
SkipMap,
} from '../shared/types'
import { MaximumProbabilityMod } from '../shared/getMaxProbModAtEachPosition'
import { MaxProbMod } from '../shared/getMaxProbModAtEachPosition'

function mismatchLen(mismatch: Mismatch) {
return !isInterbase(mismatch.type) ? mismatch.length : 1
Expand Down Expand Up @@ -283,7 +283,7 @@ function processModification({
const twoColor = colorBy?.modifications?.twoColor
const isolatedModification = colorBy?.modifications?.isolatedModification

;(feature.get('modifications') as MaximumProbabilityMod[])?.forEach(
;(feature.get('modifications') as MaxProbMod[] | undefined)?.forEach(
({ type, prob, allProbs }, pos) => {
if (isolatedModification && type !== isolatedModification) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getModPositions, getModProbabilities } from '../ModificationParser'
import { getNextRefPos, parseCigar } from '../MismatchParser'
import { getTagAlt } from '../util'

export interface MaximumProbabilityMod {
export interface MaxProbMod {
type: string
prob: number
allProbs: number[]
Expand All @@ -21,7 +21,7 @@ export function getMaxProbModAtEachPosition(
if (seq) {
const modifications = getModPositions(mm, seq, fstrand)
const probabilities = getModProbabilities(feature)
const maxProbModForPosition = [] as MaximumProbabilityMod[]
const maxProbModForPosition = [] as MaxProbMod[]

let probIndex = 0
for (const { type, positions } of modifications) {
Expand Down

0 comments on commit 3bfca11

Please sign in to comment.