Skip to content

Commit

Permalink
feat: fix parsing of non-uppercase SvType (bihealth/reev#434) (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Feb 6, 2024
1 parent ec7641e commit 761d416
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/genomicVars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ describe.concurrent('parseSeparatedStrucvar()', () => {
})
})

it('parse DEL:GRCh37:1:100:200', () => {
expect(parseSeparatedStrucvar('DEL:1:100:200')).toEqual({
it('parse Del:GRCh37:1:100:200', () => {
expect(parseSeparatedStrucvar('Del:1:100:200')).toEqual({
chrom: '1',
copyNumber: undefined,
genomeBuild: 'grch37',
Expand Down
14 changes: 12 additions & 2 deletions src/lib/genomicVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type SvType = 'DEL' | 'DUP'

/** Interface for regex groups when parsing with `REGEX_CNV_COLON` or `REGEX_CNV_HYPHEN`. */
export interface RegexCnvGroups {
svType: SvType
svType: string
genomeBuild?: string
chrom?: string
sequence?: string
Expand Down Expand Up @@ -420,7 +420,7 @@ export function parseSeparatedStrucvar(
// Obtain the genome build and chromosome from the parsed groups. Also,
// perform validation.
const {
svType,
svType: svType$Regex,
genomeBuild: genomeBuildValue,
sequence,
chrom: chromValue,
Expand Down Expand Up @@ -460,6 +460,16 @@ export function parseSeparatedStrucvar(
}
}

// Normalize the SV type.
let svType: SvType
if (svType$Regex.toUpperCase() === 'DEL') {
svType = 'DEL'
} else if (svType$Regex.toUpperCase() === 'DUP') {
svType = 'DUP'
} else {
throw new ParseError(`Unknown SV type: ${svType$Regex}`)
}

return {
svType,
genomeBuild,
Expand Down

0 comments on commit 761d416

Please sign in to comment.