Skip to content

Commit

Permalink
Merge pull request #7 from bcgsc/release/v1.1.2
Browse files Browse the repository at this point in the history
Release/v1.1.2
  • Loading branch information
creisle authored Apr 26, 2021
2 parents 00a8df7 + e184641 commit b0ab72f
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
name: node-${{ matrix.node }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm test
- name: Publish Unit Test Results
uses: EnricoMi/[email protected]
if: always()
if: matrix.node == 12
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: coverage/junit.xml
- uses: codecov/codecov-action@v1
with:
yml: codecov.yml
token: ${{ secrets.CODECOV_TOKEN }}
if: matrix.node == 12
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# GraphKB Parser

[![codecov](https://codecov.io/gh/bcgsc/pori_graphkb_parser/branch/master/graph/badge.svg?token=D3IG5YL6JT)](https://codecov.io/gh/bcgsc/pori_graphkb_parser) ![build](https://github.com/bcgsc/pori_graphkb_parser/workflows/build/badge.svg?branch=master) [![npm version](https://badge.fury.io/js/%40bcgsc-pori%2Fgraphkb-parser.svg)](https://badge.fury.io/js/%40bcgsc-pori%2Fgraphkb-parser)
[![codecov](https://codecov.io/gh/bcgsc/pori_graphkb_parser/branch/master/graph/badge.svg?token=D3IG5YL6JT)](https://codecov.io/gh/bcgsc/pori_graphkb_parser) ![build](https://github.com/bcgsc/pori_graphkb_parser/workflows/build/badge.svg?branch=master) [![npm version](https://badge.fury.io/js/%40bcgsc-pori%2Fgraphkb-parser.svg)](https://badge.fury.io/js/%40bcgsc-pori%2Fgraphkb-parser) ![node versions](https://img.shields.io/badge/node-10%20%7C%2012%20%7C%2014-blue)

This repository is part of the [platform for oncogenomic reporting and interpretation](https://github.com/bcgsc/pori).

- [About](#about)
- [Getting Started](#getting-started)
Expand All @@ -12,7 +14,7 @@ parsed notation.

## Getting Started

Import the package
Import the package (Or try it out online with [RunKit](https://runkit.com/creisle/6083062ff39ff0001b93ea6f))

```js
const kbp = require('@bcgsc-pori/graphkb-parser');
Expand Down
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
status:
project:
default:
target: 90%
threshold: 1%
10 changes: 4 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bcgsc-pori/graphkb-parser",
"version": "1.1.1",
"version": "1.1.2",
"description": "A package for parsing and recreating HGVS-like variant notation used in GraphKB",
"main": "./src/index.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const error = require('./error');
const constants = require('./constants');

module.exports = {
variant, position, error, constants,
variant, position, error, constants, parse: variant.parse,
};
15 changes: 11 additions & 4 deletions src/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { ParsingError, InputValidationError } = require('./error');
const { AA_PATTERN, AA_CODES } = require('./constants');


const CDS_PATT = /(\d+)?([-+]\d+)?/;
const CDS_PATT = /(-?\d+)?([-+]\d+)?/;
const PROTEIN_PATT = new RegExp(`(${AA_PATTERN})?(\\d+|\\?)`);
const CYTOBAND_PATT = /[pq]((\d+|\?)(\.(\d+|\?))?)?/;

Expand Down Expand Up @@ -145,16 +145,22 @@ class IntronicPosition extends BasicPosition {
}


class CdsPosition extends BasicPosition {
class CdsPosition extends Position {
/**
* @param {Object} opt options
* @param {string} opt.prefix the position prefix
* @param {Number} opt.offset the offset from the nearest cds position
*/
constructor(opt) {
const { offset } = opt;
const { offset, pos } = opt;
super(opt);

if (pos === '?' || pos === null) {
this.pos = null;
} else {
this.pos = Number(pos);
}

if (offset === null) {
this.offset = null;
} else if (offset !== undefined) {
Expand All @@ -169,6 +175,7 @@ class CdsPosition extends BasicPosition {
}
}


toString() {
let offset = '';

Expand All @@ -180,7 +187,7 @@ class CdsPosition extends BasicPosition {
}
offset = `${offset}${this.offset}`;
}
return `${super.toString(this)}${offset}`;
return `${this.pos || '?'}${offset}`;
}

static get prefix() {
Expand Down
22 changes: 19 additions & 3 deletions test/variant/continuous.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ describe('coding sequence like', () => {
expect(result.toString()).toBe(notation);
});

test('five prime UTR intron', () => {
const notation = 'FEATURE:c.-23+1A>G';
const result = parse(notation);
const exp = {
type: 'substitution',
break1Start: { '@class': 'CdsPosition', pos: -23, offset: 1 },
break1Repr: 'c.-23+1',
reference1: 'FEATURE',
refSeq: 'A',
untemplatedSeqSize: 1,
untemplatedSeq: 'G',
};
expect(result.toJSON()).toEqual(exp);
expect(result.toString()).toBe(notation);
});

test('noncoding deletion single bp', () => {
const notation = 'FEATURE:n.3+1del';
const result = parse(notation);
Expand Down Expand Up @@ -458,15 +474,15 @@ describe('coding sequence like', () => {
const result = parse(notation);
const exp = {
type: NOTATION_TO_TYPES['>'],
break1Start: { '@class': 'CdsPosition', pos: 1, offset: -124 },
break1Repr: 'c.1-124',
break1Start: { '@class': 'CdsPosition', pos: -124, offset: 0 },
break1Repr: 'c.-124',
untemplatedSeq: 'T',
untemplatedSeqSize: 1,
refSeq: 'C',
reference1: 'FEATURE',
};
expect(result.toJSON()).toEqual(exp);
expect(result.toString()).toBe('FEATURE:c.1-124C>T');
expect(result.toString()).toBe('FEATURE:c.-124C>T');
});
});

Expand Down

0 comments on commit b0ab72f

Please sign in to comment.