Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BEDPE add track workflow, avoid showing "Add track" when disabled #3631

Merged
merged 2 commits into from May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions plugins/bed/src/BedpeAdapter/BedpeAdapter.ts
Expand Up @@ -168,12 +168,16 @@ export default class BedpeAdapter extends BaseFeatureDataAdapter {
return featureData(f, uniqueId, true, names)
})

for (const obj of ret1) {
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
if (ret1) {
for (const obj of ret1) {
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
}
}

for (const obj of ret2) {
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
if (ret2) {
for (const obj of ret2) {
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
}
}

return intervalTree
Expand Down
13 changes: 13 additions & 0 deletions plugins/bed/src/index.ts
Expand Up @@ -10,6 +10,7 @@ import {
makeIndex,
makeIndexType,
AdapterGuesser,
TrackTypeGuesser,
} from '@jbrowse/core/util/tracks'

export default class BedPlugin extends Plugin {
Expand Down Expand Up @@ -116,5 +117,17 @@ export default class BedPlugin extends Plugin {
}
},
)

pluginManager.addToExtensionPoint(
'Core-guessTrackTypeForLocation',
(trackTypeGuesser: TrackTypeGuesser) => {
return (adapterName: string) => {
if (adapterName === 'BedpeAdapter') {
return 'VariantTrack'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the choice to make it use VariantTrack may make it unable to use the linear arc display, which may be useful for BEDPE (arc connects the two regions). at one point you mentioned trying to add arc rendering for VariantTrack but that it was tricky. could revisit that perhaps...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more tangential but multi-region arc may be useful too. the LinearAlignmentsArcDisplay ended up becoming multi-region capable recently, and similar concept could apply to the regular LinearArcDisplay

}
return trackTypeGuesser(adapterName)
}
},
)
}
}
Expand Up @@ -6,6 +6,7 @@ import JBrowseMenu from '@jbrowse/core/ui/Menu'
import {
getSession,
isSessionModelWithWidgets,
isSessionWithAddTracks,
isSessionModelWithConnections,
} from '@jbrowse/core/util'
import {
Expand Down Expand Up @@ -116,6 +117,22 @@ export default observer(function HamburgerMenu({
onClick: () => setConnectionManagerOpen(true),
})
}

const trackMenuItems = [
{
label: 'Add track...',
onClick: () => {
if (isSessionModelWithWidgets(session)) {
session.showWidget(
session.addWidget('AddTrackWidget', 'addTrackWidget', {
view: model.view.id,
}),
)
}
},
},
]

return (
<>
<IconButton
Expand All @@ -134,18 +151,7 @@ export default observer(function HamburgerMenu({
}}
onClose={() => setMenuEl(undefined)}
menuItems={[
{
label: 'Add track...',
onClick: () => {
if (isSessionModelWithWidgets(session)) {
session.showWidget(
session.addWidget('AddTrackWidget', 'addTrackWidget', {
view: model.view.id,
}),
)
}
},
},
...(isSessionWithAddTracks(session) ? trackMenuItems : []),
...(session.makeConnection ? connectionMenuItems : []),

...(assemblyNames.length > 1
Expand Down