Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
036c688
Add or update comments in ncit loader
mathieulemieux Feb 9, 2026
91c3d1a
Add ncit setSynonyms()
mathieulemieux Feb 9, 2026
5d09a03
Add tests for ncit setSynonyms()
mathieulemieux Feb 9, 2026
0065b75
Update ncit cleanRawRow()
mathieulemieux Feb 9, 2026
5b6733d
Update ncit uploadFile()
mathieulemieux Feb 9, 2026
656e7c1
Refactor setSynonyms() into filterSynonyms()
mathieulemieux Feb 10, 2026
2a0f638
format ncit cleanRawRow()
mathieulemieux Feb 10, 2026
c206d50
Format ncit uploadFile()
mathieulemieux Feb 10, 2026
9597953
Fix ncit tests
mathieulemieux Feb 10, 2026
71fed8a
Add counts in ncit loader
mathieulemieux Feb 12, 2026
eb51a63
Fix synonyms handling for ncit + linting
mathieulemieux Feb 12, 2026
59fed0f
Remove comment
mathieulemieux Feb 12, 2026
74496ae
Improve ncit logging message for no edge upload
mathieulemieux Feb 25, 2026
aa998d5
Add NotImplementedError and NotSupportedError classes
mathieulemieux Feb 25, 2026
47cddbe
Update ncit loader with new error calsses and war logging
mathieulemieux Feb 25, 2026
0871c03
Fix ncit NotSupportedError usage
mathieulemieux Feb 25, 2026
14c6109
Add and update ncit logging
mathieulemieux Feb 25, 2026
63794b5
Fix ncit synonym to name comparison
mathieulemieux Feb 25, 2026
0cdda60
Update ncit logging msg
mathieulemieux Feb 25, 2026
ecc5620
Fix counting in ncit logging
mathieulemieux Feb 25, 2026
e59bf4a
Simplify ncit logging
mathieulemieux Feb 25, 2026
ed55edd
Split ncit upload logic into processFileContent()
mathieulemieux Feb 26, 2026
6d8f8e0
Fix async/await in ncit uploadFile()
mathieulemieux Feb 26, 2026
37b1cee
Upgrade logging msg level in ncit
mathieulemieux Feb 26, 2026
699ed69
Export ncit module
mathieulemieux Feb 26, 2026
3b0a22e
Add support for deprecating in ncit loader
mathieulemieux Mar 5, 2026
80ad914
Add logging msg to ncit deprecateRecords()
mathieulemieux Mar 5, 2026
085872e
Add count to ncit deprecateRecords()
mathieulemieux Mar 5, 2026
d6fab9e
Add test for ncit deprecateRecords()
mathieulemieux Mar 6, 2026
f5e5b04
Improve ApiConnection.addRecord() readability
mathieulemieux Mar 10, 2026
b9fcf83
Reorganize ncit uploadFile()
mathieulemieux Mar 11, 2026
b3b444a
Adds support for ncit file loader --ignoreSynonyms & --ignoreDeprecat…
mathieulemieux Mar 11, 2026
bf55f36
Move ncit logging to the end
mathieulemieux Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ fileParser.add_argument('--ignoreCache', {
default: false,
help: 'Load the full content, to not check for previously loaded records already in the GraphKB instance',
});
fileParser.add_argument('--ignoreSynonyms', {
action: 'store_true',
default: false,
help: 'For NCIt loader only: ignore synonyms instead upload as alias records (overrides default behavior)',
});
fileParser.add_argument('--ignoreDeprecating', {
action: 'store_true',
default: false,
help: 'For NCIt loader only: ignore deprecation of old records (overrides default behavior)',
});

const civicParser = subparsers.add_parser('civic');
civicParser.add_argument('--trustedCurators', {
Expand Down
29 changes: 18 additions & 11 deletions src/graphkb.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,15 @@ class ApiConnection {

/**
* @param {object} opt
* @param {string} opt.target
* @param {object} opt.content
* @param {boolean} [opt.existsOk=false] do not error if a record cannot be created because it already exists
* @param {string} opt.target
* @param {boolean} [opt.existsOk=false] do not error if a record cannot be created because it already exists (409)
* @param {object} [opt.fetchConditions=null] the filters clause to be used in attempting to fetch this record
* @param {boolean} [opt.fetchExisting=true] return the record if it already exists
* @param {boolean} [opt.fetchFirst=false] attempt to fetch the record before trying to create it
* @param {function} opt.sortFunc function to be used in order records if multiple are returned to limit the result to 1
* @param {boolean} [opt.fetchFirst=false] attempt first to fetch and return the record, otherwise create it
* @param {function} [opt.sortFunc=()=>0] function to be used in order records if multiple are returned to limit the result to 1
* @param {function} [opt.upsert=false]
* @param {function} [opt.upsertCheckExclude=[]]
*/
async addRecord(opt) {
const {
Expand All @@ -548,9 +550,18 @@ class ApiConnection {
upsertCheckExclude = [],
} = opt;
const model = schema.get(target);

// Early exit on invalid target
if (!model) {
throw new Error(`cannot find model from target (${target})`);
}

// Unless specific fetchConditions filters are provided,
// will fetch the record, when needed, by all of its properties (except undefined ones)
const filters = fetchConditions || convertRecordToQueryFilters(content);

// Will first try to fetch and/or update the record if it already exists
// 1. Optionnaly try to first fetch and return the record if it already exists.
// Will try to update it if upsert=true
if (fetchFirst || upsert) {
try {
const result = await this.getUniqueRecordBy({
Expand All @@ -566,12 +577,7 @@ class ApiConnection {
} catch (err) { }
}


if (!model) {
throw new Error(`cannot find model from target (${target})`);
}

// Then (since record dosen't already exists) will create a new record
// 2. Attemps to create a new record
try {
const { result } = jc.retrocycle(await this.request({
body: content,
Expand All @@ -585,6 +591,7 @@ class ApiConnection {
this.created[model.name].push(result['@rid']);
return result;
} catch (err) {
// On conflict (409), do not throw error if existsOk or upsert.
if (err.statusCode === 409 && (existsOk || upsert)) {
if (fetchExisting || upsert) {
const result = await this.getUniqueRecordBy({
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const hgnc = require('./hgnc');
const sources = require('./sources');
const ontology = require('./ontology');
const util = require('./util');
const ncit = require('./ncit');

const { logger } = require('./logging');

Expand Down Expand Up @@ -51,6 +52,7 @@ module.exports = {
entrezGene,
graphkb,
hgnc,
ncit,
ontology,
pubmed,
refseq,
Expand Down
Loading
Loading