Skip to content

Commit

Permalink
[skip ci] Parse out INFO field
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 6, 2023
1 parent 1b44f60 commit e0710f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const DataTable = observer(function ({ model }: { model: SpreadsheetModel }) {
field: m,
width: widths[i],
}))

return (
<div ref={ref}>
<ResizeBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ export function parseVcfBuffer(buffer: Buffer, options: ParseOptions = {}) {
const { selectedAssemblyName } = options
const { header, body } = splitVcfFileHeaderAndBody(bufferToString(buffer))
const vcfParser = new VCF({ header })
const lines = body.split(/\n|\r\n/)

const keys = new Set<string>()
const rows = lines.map(l => {
const [CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT] = l.split('\t')
const ret = Object.fromEntries(
INFO?.split(';').map(e => {
const [key, val = true] = e.split('=')
keys.add(key)
return [key, val]
}) || [],
)
return { CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, ...ret }
})

return {
vcfParser,
rows: body.split(/\n|\r\n/).map((row, idx) => {
const [CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT] =
row.split('\t')
rows: rows.map((row, idx) => {
return {
CHROM,
POS,
ID,
REF,
ALT,
QUAL,
FILTER,
INFO,
FORMAT,
...row,
id: idx,
__lineData: row,
}
Expand All @@ -33,8 +37,8 @@ export function parseVcfBuffer(buffer: Buffer, options: ParseOptions = {}) {
'ALT',
'QUAL',
'FILTER',
'INFO',
'FORMAT',
...keys,
],
assemblyName: selectedAssemblyName,
}
Expand Down

0 comments on commit e0710f6

Please sign in to comment.