Skip to content

Commit

Permalink
Merge pull request #17 from bcgsc/release/v5.1.1
Browse files Browse the repository at this point in the history
Release/v5.1.1
  • Loading branch information
cgrisdale authored Jul 7, 2021
2 parents 78f5a57 + b788752 commit aef05b2
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 68 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![build](https://github.com/bcgsc/pori_graphkb_loader/workflows/build/badge.svg?branch=master) ![Docker Image Version (latest semver)](https://img.shields.io/docker/v/bcgsc/pori-graphkb-loader?label=docker%20image) ![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).

This package is used to import content from a variety of sources into GraphKB using the API.

- [Loaders](#loaders)
Expand Down
43 changes: 31 additions & 12 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,7 +1,7 @@
{
"name": "@bcgsc-pori/graphkb-loader",
"main": "src/index.js",
"version": "5.1.0",
"version": "5.2.0",
"repository": {
"type": "git",
"url": "https://github.com/bcgsc/pori_graphkb_loader.git"
Expand Down
104 changes: 59 additions & 45 deletions src/civic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,20 @@ const validateEvidenceSpec = ajv.compile({


/**
* Convert the CIViC relevance types to GraphKB terms
* Extract the appropriate GraphKB relevance term from a CIViC evidence record
*/
const getRelevance = async ({ rawRecord, conn }) => {
const translateRelevance = ({ evidenceType, clinicalSignificance, evidenceDirection }) => {
switch (evidenceType) { // eslint-disable-line default-case
case 'Predictive': {
const translateRelevance = (evidenceType, evidenceDirection, clinicalSignificance) => {
switch (evidenceType) { // eslint-disable-line default-case
case 'Predictive': {
if (evidenceDirection === 'Does Not Support') {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Sensitivity':

case 'Sensitivity/Response': {
return 'no response';
}
}
} else if (evidenceDirection === 'Supports') {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Sensitivity':
case 'Adverse Response':
Expand All @@ -129,61 +137,66 @@ const getRelevance = async ({ rawRecord, conn }) => {

case 'Sensitivity/Response': { return 'sensitivity'; }
}
break;
}
break;
}

case 'Functional': {
return clinicalSignificance.toLowerCase();
}
case 'Functional': {
return clinicalSignificance.toLowerCase();
}

case 'Diagnostic': {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Positive': { return 'favours diagnosis'; }
case 'Diagnostic': {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Positive': { return 'favours diagnosis'; }

case 'Negative': { return 'opposes diagnosis'; }
}
break;
case 'Negative': { return 'opposes diagnosis'; }
}
break;
}

case 'Prognostic': {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Negative':
case 'Prognostic': {
switch (clinicalSignificance) { // eslint-disable-line default-case
case 'Negative':

case 'Poor Outcome': {
return 'unfavourable prognosis';
}
case 'Positive':
case 'Poor Outcome': {
return 'unfavourable prognosis';
}
case 'Positive':

case 'Better Outcome': {
return 'favourable prognosis';
}
case 'Better Outcome': {
return 'favourable prognosis';
}
break;
}
break;
}

case 'Predisposing': {
if (['Positive', null, 'null'].includes(clinicalSignificance)) {
return 'Predisposing';
} if (clinicalSignificance.includes('Pathogenic')) {
return clinicalSignificance;
} if (clinicalSignificance === 'Uncertain Significance') {
return 'likely predisposing';
}
break;
case 'Predisposing': {
if (['Positive', null, 'null'].includes(clinicalSignificance)) {
return 'predisposing';
} if (clinicalSignificance.includes('Pathogenic')) {
return clinicalSignificance.toLowerCase();
} if (clinicalSignificance === 'Uncertain Significance') {
return 'likely predisposing';
}
break;
}
}

throw new Error(
`unable to process relevance (${JSON.stringify({ clinicalSignificance, evidenceDirection, evidenceType })})`,
);
};
throw new Error(
`unable to process relevance (${JSON.stringify({ clinicalSignificance, evidenceDirection, evidenceType })})`,
);
};

/**
* Convert the CIViC relevance types to GraphKB terms
*/
const getRelevance = async ({ rawRecord, conn }) => {
// translate the type to a GraphKB vocabulary term
let relevance = translateRelevance({
clinicalSignificance: rawRecord.clinical_significance,
evidenceDirection: rawRecord.evidence_direction,
evidenceType: rawRecord.evidence_type,
}).toLowerCase();
let relevance = translateRelevance(
rawRecord.evidence_type,
rawRecord.evidence_direction,
rawRecord.clinical_significance,
).toLowerCase();

if (RELEVANCE_CACHE[relevance] === undefined) {
relevance = await conn.getVocabularyTerm(relevance);
Expand Down Expand Up @@ -572,7 +585,6 @@ const downloadEvidenceRecords = async (baseUrl) => {

if (
record.clinical_significance === 'N/A'
|| record.evidence_direction === 'Does Not Support'
|| (record.clinical_significance === null && record.evidence_type === 'Predictive')
) {
counts.skip++;
Expand Down Expand Up @@ -682,6 +694,7 @@ const upload = async (opt) => {

const oneToOne = mappedCount === 1 && preupload.size === 1;

// upload all GraphKB statements for this CIViC Evidence Item
for (const record of recordList) {
for (const variant of record.variants) {
for (const drugs of record.drugs) {
Expand Down Expand Up @@ -738,5 +751,6 @@ const upload = async (opt) => {
module.exports = {
SOURCE_DEFN,
specs: { validateEvidenceSpec },
translateRelevance,
upload,
};
9 changes: 7 additions & 2 deletions src/civic/variant.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const normalizeVariantRecord = ({
type: name.replace(/-/g, ' '),
}];
} if (match = /^t\(([^;()]+);([^;()]+)\)\(([^;()]+);([^;()]+)\)$/i.exec(name)) {
// convert translocation syntax
const [, chr1, chr2, pos1, pos2] = match;
return [{
positional: true,
Expand All @@ -141,6 +142,7 @@ const normalizeVariantRecord = ({
variant: `translocation(${pos1}, ${pos2})`,
}];
} if (match = /^(p\.)?([a-z*]\d+\S*)\s+\((c\.[^)]+)\)$/i.exec(name)) {
// split combined protein + cds notation
let [, , protein, cds] = match;

// correct deprecated cds syntac
Expand All @@ -152,7 +154,7 @@ const normalizeVariantRecord = ({
}
}
return [{
inferredBy: [
inferredBy: [ // keep the cds variant as a link to the protein variant
{
positional: true,
reference1: { ...referenceGene },
Expand Down Expand Up @@ -183,7 +185,10 @@ const normalizeVariantRecord = ({
let rest = { type: 'fusion' };

if (tail) {
if (match = /^[a-z](\d+);[a-z](\d+)$/.exec(tail || '')) {
if (match = /^e(\d+)-e(\d+)$/.exec(tail || '')) {
const [, exon1, exon2] = match;
rest = { positional: true, variant: `fusion(e.${exon1},e.${exon2})` };
} else if (match = /^[a-z](\d+);[a-z](\d+)$/.exec(tail || '')) {
const [, exon1, exon2] = match;
rest = { positional: true, variant: `fusion(e.${exon1},e.${exon2})` };
} else {
Expand Down
Loading

0 comments on commit aef05b2

Please sign in to comment.