Skip to content

bcgsc/pori_graphkb_parser

Repository files navigation

GraphKB Parser

codecov build npm version node versions

This repository is part of the platform for oncogenomic reporting and interpretation.

About

The GraphKB parser is a node module for parsing variant notation and producing strings from parsed notation.

Getting Started

Import the package (Or try it out online with RunKit)

const {parseVariant, stringifyVariant, jsonifyVariant} = require('@bcgsc-pori/graphkb-parser');

To use the variant parser methods simply pass a string into

> const parsedResult = parseVariant('FEATURE:p.G12D');
{
    'prefix': 'p',
    ...
}

Which returns a variant notation object. This can be turned back into a string

> stringifyVariant(parsedResult);
'FEATURE:p.G12D'

or a JSON (removes extra attributes used by parse methods)

> jsonifyVariant(parsedResult)

If the notation is improperly formatted, the parse function will raise a parsing error

try {
   const parsedResult = parseVariant('FEATUREp.G12D');
} catch (err) {
    if (err instanceof kbp.error.ParsingError) {
        console.log('Error in parsing the notation');
    }
}

See notation for information regarding the notation syntax.