Skip to content

Commit

Permalink
Add ability to use a BigBed file as a cytobands adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 6, 2024
1 parent 0605413 commit 27e9f71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export default class CytobandAdapter extends BaseAdapter {
refName: refName!,
start: +start!,
end: +end!,
name: name!,
type: type!,
name,
type,
gieStain: type || name,
})
})
}
Expand Down
19 changes: 18 additions & 1 deletion plugins/bed/src/BigBedAdapter/BigBedAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SimpleFeature,
SimpleFeatureSerializedNoId,
} from '@jbrowse/core/util'
import { Observer } from 'rxjs'
import { firstValueFrom, Observer, toArray } from 'rxjs'

// locals
import {
Expand Down Expand Up @@ -64,6 +64,23 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
return Object.keys(header.refsByName)
}

public async getData() {
const refNames = await this.getRefNames()
const features = []
for (const refName of refNames) {
const f = await firstValueFrom(
this.getFeatures({
assemblyName: 'unknown',
refName,
start: 0,
end: Number.MAX_SAFE_INTEGER,
}).pipe(toArray()),
)
features.push(f)
}
return features.flat()
}

async getHeader(opts?: BaseOptions) {
const { parser, header } = await this.configure(opts)
const { version, fileType } = header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function getCytobands(assembly: Assembly | undefined, refName: string) {
assembly.getCanonicalRefName(f.get('refName')) || f.get('refName'),
start: f.get('start'),
end: f.get('end'),
type: f.get('type') as string,
type: f.get('gieStain') as string,
}))
.filter(f => f.refName === refName) || []
)
Expand Down

0 comments on commit 27e9f71

Please sign in to comment.