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

Fix drawing inverted CIGAR segments on dotplot #3170

Merged
merged 7 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/breakpoint-split-view/src/BreakpointSplitView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BreakpointSplitViewType extends ViewType {
const INFO = feature.get('INFO')
endPos = INFO.END[0] - 1
mateRefName = getCanonicalRefName(INFO.CHR2[0])
} else if (bnd) {
} else if (bnd?.MatePosition) {
const matePosition = bnd.MatePosition.split(':')
endPos = +matePosition[1] - 1
mateRefName = getCanonicalRefName(matePosition[0])
Expand Down
2 changes: 1 addition & 1 deletion plugins/breakpoint-split-view/src/components/Breakends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getMatchedBreakendFeatures(features: Map<string, Feature>) {
const bnd = parseBreakend(a)
if (bnd) {
if (!candidates[cur]) {
candidates[bnd.MatePosition] = [f]
candidates[bnd.MatePosition || 'none'] = [f]
} else {
candidates[cur].push(f)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-16-helper-text"
Expand Down Expand Up @@ -1358,7 +1357,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-18-helper-text"
Expand Down Expand Up @@ -1435,7 +1433,6 @@ exports[`ConfigurationEditor widget renders with defaults of the PileupTrack sch
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-19-helper-text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ exports[`<AddConnectionWidget /> renders 1`] = `
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-md26zr-MuiInputBase-root-MuiOutlinedInput-root"
variant="outlined"
>
<div
aria-describedby="mui-1-helper-text"
Expand Down
12 changes: 9 additions & 3 deletions plugins/dotplot-view/src/DotplotRenderer/DotplotRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,17 @@ export default class DotplotRenderer extends ComparativeRenderer {
max: number,
feature: Feature,
) {
const strand = feature.get('strand') || 1
if (strand === -1) {
;[max, min] = [min, max]
}
if (num < min - fudgeFactor) {
const strand = feature.get('strand') || 1
const start = strand === 1 ? feature.get('start') : feature.get('end')
const end = strand === 1 ? feature.get('end') : feature.get('start')
let start = feature.get('start')
let end = feature.get('end')
const refName = feature.get('refName')
if (strand === -1) {
;[end, start] = [start, end]
}

warnings.push({
message: `feature at (X ${refName}:${start}-${end}) ${r} ${lt}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ exports[`<LinearGenomeView /> renders one track, one region 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root css-16awh2u-MuiAutocomplete-root"
class="MuiAutocomplete-root css-1qqsdnr-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 200px;"
>
Expand Down Expand Up @@ -722,7 +722,7 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root css-16awh2u-MuiAutocomplete-root"
class="MuiAutocomplete-root css-1qqsdnr-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 255.27500000000003px;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ exports[`<JBrowseLinearGenomeView /> renders successfully 1`] = `
/>
</button>
<div
class="MuiAutocomplete-root mui-1auycx3-MuiAutocomplete-root"
class="MuiAutocomplete-root mui-1kxbtff-MuiAutocomplete-root"
data-testid="autocomplete"
style="width: 200px;"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import { fireEvent, waitFor } from '@testing-library/react'
import { LocalFile } from 'generic-filehandle'
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { TextEncoder, TextDecoder } from 'web-encoding'

import { JBrowse, setup, getPluginManager, generateReadBuffer } from './util'
import { createView, setup, generateReadBuffer } from './util'

window.TextEncoder = TextEncoder
window.TextDecoder = TextDecoder

expect.extend({ toMatchImageSnapshot })

setup()

beforeEach(() => {
clearCache()
clearAdapterCache()
// @ts-ignore
fetch.resetMocks()
// @ts-ignore
fetch.mockResponse(
generateReadBuffer(
url => new LocalFile(require.resolve(`../../test_data/volvox/${url}`)),
Expand All @@ -30,10 +28,7 @@ beforeEach(() => {
const delay = { timeout: 10000 }

test('opens a vcf.gz file in the spreadsheet view', async () => {
const pluginManager = getPluginManager()
const { findByTestId, getByTestId, findByText } = render(
<JBrowse pluginManager={pluginManager} />,
)
const { session, findByTestId, getByTestId, findByText } = createView()
fireEvent.click(await findByText('File'))
fireEvent.click(await findByText('Add'))
fireEvent.click(await findByText('Spreadsheet view'))
Expand All @@ -48,14 +43,11 @@ test('opens a vcf.gz file in the spreadsheet view', async () => {
).not.toBeDisabled(),
)
fireEvent.click(await findByTestId('open_spreadsheet'))
expect(pluginManager.rootModel.session.views.length).toBe(2)
expect(session.views.length).toBe(2)
}, 15000)

test('opens a bed.gz file in the spreadsheet view', async () => {
const pluginManager = getPluginManager()
const { findByTestId, getByTestId, findByText } = render(
<JBrowse pluginManager={pluginManager} />,
)
const { findByTestId, session, getByTestId, findByText } = createView()
fireEvent.click(await findByText('File'))
fireEvent.click(await findByText('Add'))
fireEvent.click(await findByText('Spreadsheet view'))
Expand All @@ -70,5 +62,5 @@ test('opens a bed.gz file in the spreadsheet view', async () => {
).not.toBeDisabled(),
)
fireEvent.click(await findByTestId('open_spreadsheet'))
expect(pluginManager.rootModel.session.views.length).toBe(2)
expect(session.views.length).toBe(2)
}, 15000)
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import { fireEvent, waitFor } from '@testing-library/react'
import { LocalFile } from 'generic-filehandle'
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { TextEncoder, TextDecoder } from 'web-encoding'

import { JBrowse, setup, getPluginManager, generateReadBuffer } from './util'
import { setup, createView, generateReadBuffer } from './util'

window.TextEncoder = TextEncoder
window.TextDecoder = TextDecoder

expect.extend({ toMatchImageSnapshot })

setup()

beforeEach(() => {
clearCache()
clearAdapterCache()
// @ts-ignore
fetch.resetMocks()
// @ts-ignore
fetch.mockResponse(
generateReadBuffer(url => {
return new LocalFile(require.resolve(`../../test_data/volvox/${url}`))
Expand All @@ -31,13 +29,8 @@ const delay = { timeout: 20000 }

test('opens a vcf.gz file in the sv inspector view', async () => {
console.warn = jest.fn()
const pluginManager = getPluginManager()
const { findByTestId, getByTestId, findByText } = render(
<JBrowse pluginManager={pluginManager} />,
)
const {
rootModel: { session },
} = pluginManager
const { session, findByTestId, getByTestId, findByText } = createView()

fireEvent.click(await findByText('File'))
fireEvent.click(await findByText('Add'))
fireEvent.click(await findByText('SV inspector'))
Expand Down
2 changes: 0 additions & 2 deletions products/jbrowse-web/src/tests/Alignments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { LocalFile } from 'generic-filehandle'
// locals
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import {
setup,
expectCanvasMatch,
Expand All @@ -14,7 +13,6 @@ import {
pc,
} from './util'

expect.extend({ toMatchImageSnapshot })
setup()

beforeEach(() => {
Expand Down
2 changes: 0 additions & 2 deletions products/jbrowse-web/src/tests/AlignmentsFeatures.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { LocalFile } from 'generic-filehandle'
// locals
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import {
setup,
expectCanvasMatch,
Expand All @@ -14,7 +13,6 @@ import {
hts,
} from './util'

expect.extend({ toMatchImageSnapshot })
setup()

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import React from 'react'
import { fireEvent, render, waitFor, within } from '@testing-library/react'
import { fireEvent, waitFor, within } from '@testing-library/react'
import { LocalFile, RemoteFile } from 'generic-filehandle'
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import crypto from 'crypto'
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import config from '../../test_data/volvox/config.json'
import {
JBrowse,
setup,
createView,
expectCanvasMatch,
generateReadBuffer,
getPluginManager,
} from './util'

expect.extend({ toMatchImageSnapshot })
setup()

// @ts-ignore
global.crypto = { getRandomValues: crypto.randomFillSync }

beforeEach(() => {
clearCache()
clearAdapterCache()
sessionStorage.clear()
// @ts-ignore
fetch.resetMocks()
// @ts-ignore
fetch.mockResponse(
generateReadBuffer(
url => new LocalFile(require.resolve(`../../test_data/volvox/${url}`)),
Expand All @@ -34,7 +32,7 @@ beforeEach(() => {
const delay = { timeout: 20000 }

test('open a bigwig track that needs oauth authentication and has existing token', async () => {
const pm = getPluginManager({
const { state, view, findByTestId, findByText } = createView({
...config,
tracks: [
{
Expand All @@ -54,17 +52,18 @@ test('open a bigwig track that needs oauth authentication and has existing token
},
],
})
const state = pm.rootModel
const { findByTestId, findByText } = render(<JBrowse pluginManager={pm} />)
const token = '1234'
sessionStorage.setItem('dropboxOAuth-token', token)
// @ts-ignore
await waitFor(() => expect(state.internetAccounts.length).toBe(2))
// @ts-ignore
state.internetAccounts[0].validateToken = jest.fn().mockReturnValue(token)
// @ts-ignore
state.internetAccounts[0].openLocation = jest
.fn()
.mockReturnValue(new RemoteFile('volvox_microarray_dropbox.bw'))
await findByText('Help')
state.session.views[0].setNewView(5, 0)
view.setNewView(5, 0)
fireEvent.click(
await findByTestId('htsTrackEntry-volvox_microarray_dropbox', {}, delay),
)
Expand All @@ -78,7 +77,7 @@ test('open a bigwig track that needs oauth authentication and has existing token
}, 25000)

test('opens a bigwig track that needs external token authentication', async () => {
const pm = getPluginManager({
const { view, findByTestId } = createView({
...config,
internetAccounts: [
{
Expand Down Expand Up @@ -107,9 +106,7 @@ test('opens a bigwig track that needs external token authentication', async () =
},
],
})
const state = pm.rootModel
const { findByTestId } = render(<JBrowse pluginManager={pm} />)
state.session.views[0].setNewView(5, 0)
view.setNewView(5, 0)
fireEvent.click(
await findByTestId(
'htsTrackEntry-volvox_microarray_externaltoken',
Expand Down Expand Up @@ -138,7 +135,7 @@ test('opens a bigwig track that needs external token authentication', async () =
}, 25000)

test('opens a bigwig track that needs httpbasic authentication', async () => {
const pm = getPluginManager({
const { view, findByTestId, findByText } = createView({
...config,
tracks: [
{
Expand All @@ -158,9 +155,7 @@ test('opens a bigwig track that needs httpbasic authentication', async () => {
},
],
})
const state = pm.rootModel
const { findByTestId, findByText } = render(<JBrowse pluginManager={pm} />)
state.session.views[0].setNewView(5, 0)
view.setNewView(5, 0)
fireEvent.click(
await findByTestId('htsTrackEntry-volvox_microarray_httpbasic', {}, delay),
)
Expand Down
2 changes: 0 additions & 2 deletions products/jbrowse-web/src/tests/BigWig.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fireEvent } from '@testing-library/react'
import { LocalFile } from 'generic-filehandle'
import { clearCache } from '@jbrowse/core/util/io/RemoteFileWithRangeCache'
import { clearAdapterCache } from '@jbrowse/core/data_adapters/dataAdapterCache'
import { toMatchImageSnapshot } from 'jest-image-snapshot'

import {
setup,
Expand All @@ -13,7 +12,6 @@ import {
hts,
} from './util'

expect.extend({ toMatchImageSnapshot })
setup()

beforeEach(() => {
Expand Down
Loading