Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 19, 2024
1 parent 1194a7c commit a410a68
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
43 changes: 26 additions & 17 deletions plugins/bed/src/BedGraphAdapter/BedGraphAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
import { Feature, fetchAndMaybeUnzip, SimpleFeature } from '@jbrowse/core/util'
import {
Feature,
fetchAndMaybeUnzip,
Region,
SimpleFeature,
} from '@jbrowse/core/util'
import IntervalTree from '@flatten-js/interval-tree'
import {
BaseFeatureDataAdapter,
Expand Down Expand Up @@ -42,24 +47,29 @@ export default class BedGraphAdapter extends BaseFeatureDataAdapter {
const names = (await this.getNames())?.slice(3) || []
const intervalTree = new IntervalTree()
for (let i = 0; i < lines.length; i++) {
const [refName, s, e, ...rest] = lines[i]!.split('\t')
const line = lines[i]!
const [refName, s, e, ...rest] = line.split('\t')
for (let j = 0; j < rest.length; j++) {
const uniqueId = `${this.id}-${refName}-${i}`
const uniqueId = `${this.id}-${refName}-${i}-${j}`
const start = +s!
const end = +e!
intervalTree.insert(
[start, end],
new SimpleFeature({
id: uniqueId,
data: {
refName,
start,
end,
score: +rest[i]!,
source: names[i] || `col${i}`,
},
}),
)
const score = +rest[j]!
const source = names[j] || `col${j}`
if (score) {
intervalTree.insert(
[start, end],
new SimpleFeature({
id: uniqueId,
data: {
refName,
start,
end,
score,
source,
},
}),
)
}
}
}

Expand Down Expand Up @@ -132,7 +142,6 @@ export default class BedGraphAdapter extends BaseFeatureDataAdapter {
const { start, end, refName } = query
const intervalTree = await this.loadFeatureIntervalTree(refName)
intervalTree?.search([start, end]).forEach(f => {
console.log({ f })
observer.next(f)
})
observer.complete()
Expand Down
32 changes: 32 additions & 0 deletions plugins/bed/src/BedGraphAdapter/configSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ConfigurationSchema } from '@jbrowse/core/configuration'

/**
* #config BedGraphAdapter
*/
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars

const BedGraphAdapter = ConfigurationSchema(
'BedGraphAdapter',
{
/**
* #slot
*/
bedGraphLocation: {
type: 'fileLocation',
defaultValue: {
uri: '/path/to/my.bedgraph',
locationType: 'UriLocation',
},
},
/**
* #slot
*/
columnNames: {
type: 'stringArray',
description: 'List of column names',
defaultValue: [],
},
},
{ explicitlyTyped: true },
)
export default BedGraphAdapter
2 changes: 1 addition & 1 deletion plugins/bed/src/BedGraphAdapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PluginManager from '@jbrowse/core/PluginManager'
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'

import configSchema from '../BedAdapter/configSchema'
import configSchema from './configSchema'

export default function BedGraphAdapterF(pluginManager: PluginManager) {
pluginManager.addAdapterType(
Expand Down

0 comments on commit a410a68

Please sign in to comment.