-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
306 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { SimpleFeature } from '@jbrowse/core/util' | ||
|
||
const svTypes = new Set(['DUP', 'TRA', 'INV', 'CNV', 'DEL']) | ||
|
||
export function featureData( | ||
line: string, | ||
uniqueId: string, | ||
flip: boolean, | ||
names?: string[], | ||
) { | ||
const l = line.split('\t') | ||
const ref1 = l[flip ? 3 : 0]! | ||
const start1 = +l[flip ? 4 : 1]! | ||
const end1 = +l[flip ? 5 : 2]! | ||
const ref2 = l[!flip ? 3 : 0]! | ||
const start2 = +l[!flip ? 4 : 1]! | ||
const end2 = +l[!flip ? 5 : 2]! | ||
const name = l[6]! | ||
const score = +l[7]! | ||
const strand1 = parseStrand(l[8]!) | ||
const strand2 = parseStrand(l[9]!) | ||
const extra = l.slice(10) | ||
const rest = names | ||
? Object.fromEntries(names.slice(10).map((n, idx) => [n, extra[idx]])) | ||
: {} | ||
const ALT = svTypes.has(extra[0]!) ? `<${extra[0]}>` : undefined | ||
|
||
return new SimpleFeature({ | ||
...rest, | ||
start: start1, | ||
end: end1, | ||
type: 'paired_feature', | ||
refName: ref1, | ||
strand: strand1, | ||
name, | ||
score, | ||
uniqueId, | ||
mate: { | ||
refName: ref2, | ||
start: start2, | ||
end: end2, | ||
strand: strand2, | ||
}, | ||
...(ALT ? { ALT: [ALT] } : {}), // ALT is an array in VCF | ||
}) | ||
} | ||
|
||
function parseStrand(strand: string) { | ||
if (strand === '+') { | ||
return 1 | ||
} else if (strand === '-') { | ||
return -1 | ||
} else if (strand === '.') { | ||
return 0 | ||
} else { | ||
return undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
plugins/variants/src/VariantFeatureWidget/LaunchBreakendWidgetArea.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Suspense, lazy } from 'react' | ||
|
||
import { parseBreakend } from '@gmod/vcf' | ||
|
||
import type { VariantFeatureWidgetModel } from './stateModelFactory' | ||
|
||
// lazies | ||
const LaunchBreakendPanel = lazy(() => import('./LaunchBreakendPanel')) | ||
|
||
export default function LaunchBreakendWidgetArea({ | ||
model, | ||
}: { | ||
model: VariantFeatureWidgetModel | ||
}) { | ||
const { featureData } = model | ||
const feat = JSON.parse(JSON.stringify(featureData)) | ||
const { type = '' } = feat | ||
|
||
return ( | ||
<Suspense fallback={null}> | ||
{type === 'breakend' ? ( | ||
<LaunchBreakendPanel | ||
feature={feat} | ||
locStrings={feat.ALT.map( | ||
(alt: string) => parseBreakend(alt)?.MatePosition || '', | ||
)} | ||
model={model} | ||
/> | ||
) : type === 'translocation' ? ( | ||
<LaunchBreakendPanel | ||
feature={feat} | ||
model={model} | ||
locStrings={[`${feat.INFO.CHR2[0]}:${feat.INFO.END}`]} | ||
/> | ||
) : type === 'paired_feature' ? ( | ||
<LaunchBreakendPanel | ||
feature={feat} | ||
model={model} | ||
locStrings={[`${feat.mate.refName}:${feat.mate.start}`]} | ||
/> | ||
) : type.includes('inversion') || | ||
type.includes('deletion') || | ||
type.includes('duplication') || | ||
type.includes('cnv') || | ||
type.includes('sv') ? ( | ||
<LaunchBreakendPanel | ||
feature={{ | ||
uniqueId: 'random', | ||
refName: feat.refName, | ||
start: feat.start, | ||
end: feat.start + 1, | ||
mate: { | ||
refName: feat.refName, | ||
start: feat.end, | ||
end: feat.end + 1, | ||
}, | ||
}} | ||
model={model} | ||
locStrings={[`${feat.refName}:${feat.end}`]} | ||
/> | ||
) : null} | ||
</Suspense> | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
plugins/variants/src/VariantFeatureWidget/VariantConsequenceDataGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import BaseCard from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/BaseCard' | ||
|
||
import VariantConsequenceDataGridWrapper from './VariantConsequenceDataGridWrapper' | ||
|
||
export default function VariantConsequenceDataGrid({ | ||
data, | ||
fields, | ||
title, | ||
}: { | ||
data: string[] | ||
fields: string[] | ||
title: string | ||
}) { | ||
return data.length ? ( | ||
<BaseCard title={title}> | ||
<VariantConsequenceDataGridWrapper | ||
rows={data.map((elt, id) => ({ | ||
id, | ||
...Object.fromEntries(elt.split('|').map((e, i) => [fields[i], e])), | ||
}))} | ||
columns={fields.map(c => ({ field: c }))} | ||
/> | ||
</BaseCard> | ||
) : null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.