Skip to content

Commit b4e1cbf

Browse files
authored
Merge pull request #219 from CBIIT/EVSSIP-274-Update-mapping-for-GDC-release-2.5.0
EVS SIP 274 - GDC Mapping Update for NCIt 22.08e
2 parents f8cdd7e + 371c0bf commit b4e1cbf

File tree

5 files changed

+232
-79
lines changed

5 files changed

+232
-79
lines changed

server/data_files/GDC/gdc_props.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/data_files/GDC/gdc_values.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/data_files/GDC/ncit_details.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/service/search/controller.js

Lines changed: 227 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -629,15 +629,15 @@ const synchronziedLoadSynonmysfromNCIT = (ncitids, idx, next) => {
629629
d.synonyms.forEach((data) => {
630630
if (
631631
checker_arr.indexOf(
632-
(data.name + "@#$" + data.termGroup + "@#$" + data.source)
632+
(data.name + "@#$" + data.termType + "@#$" + data.source)
633633
.trim()
634634
.toLowerCase()
635635
) !== -1
636636
)
637637
return;
638638
let obj = {};
639639
obj.termName = data.name;
640-
obj.termGroup = data.termGroup;
640+
obj.termGroup = data.termType;
641641
obj.termSource = data.source;
642642
//only keep NCI synonyms
643643
if (obj.termSource == "NCI") {
@@ -648,7 +648,7 @@ const synchronziedLoadSynonmysfromNCIT = (ncitids, idx, next) => {
648648
}
649649
}
650650
checker_arr.push(
651-
(data.name + "@#$" + data.termGroup + "@#$" + data.source)
651+
(data.name + "@#$" + data.termType + "@#$" + data.source)
652652
.trim()
653653
.toLowerCase()
654654
);
@@ -1290,92 +1290,243 @@ const exportAllCompareResult = async function(req, res){
12901290
res.send(report);
12911291
}
12921292

1293-
const generateProperties = async function(req, res) {
1294-
const dataset = [];
1295-
let output_file_path = path.join(__dirname, '..', '..', 'data_files', 'GDC', 'gdc_values_updated.js');
1296-
let GDCDict = await shared.getGDCDictionaryByVersion("2.4.1");
1297-
1298-
for(let node in GDCDict){
1299-
let entry = GDCDict[node];
1300-
let uid = node + "/" + entry.category + "/gdc";
1301-
if(entry.properties){
1302-
let prop_dict = entry.properties;
1303-
for(let prop in prop_dict){
1304-
let tmp = {};
1305-
tmp.category = entry.category;
1306-
tmp.node = node;
1307-
tmp.property = prop;
1308-
let dict = prop_dict[prop];
1309-
tmp.ncit = dict.termDef && dict.termDef.source && dict.termDef.source == "NCIt" ? (dict.termDef.term_id || dict.termDef.cde_id ) : "";
1310-
dataset.push(tmp);
1311-
}
1312-
}
1313-
}
1293+
const generateGDCPropertiesReport = async function(req, res) {
1294+
const dataset = [];
1295+
let GDCDict = await shared.getGDCDictionaryByVersion("2.5.0");
1296+
let prop_mapping = shared.readGDCProps();
1297+
1298+
for(let node in GDCDict){
1299+
let entry = GDCDict[node];
1300+
if(entry.properties){
1301+
let prop_dict = entry.properties;
1302+
for(let prop in prop_dict){
1303+
let tmp = {};
1304+
let uid = entry.category + "." + node + "." + prop;
1305+
tmp.category = entry.category;
1306+
tmp.node = node;
1307+
tmp.property = prop;
1308+
let dict = prop_dict[prop];
1309+
tmp.ncit = prop_mapping[uid] !== undefined ? prop_mapping[uid] : '';
1310+
tmp.cdeid = dict.termDef && dict.termDef.source && dict.termDef.source === "caDSR" ? (dict.termDef.cde_id) : "";
1311+
dataset.push(tmp);
1312+
}
1313+
}
1314+
}
13141315

13151316
// You can define styles as json object
1316-
const styles = {
1317+
const styles = {
13171318
cellPink: {
13181319
fill: {
1319-
fgColor: {
1320-
rgb: 'FF00FF00'
1321-
}
1320+
fgColor: {
1321+
rgb: '1F497D'
1322+
}
1323+
},
1324+
font:{
1325+
color: {
1326+
rgb: 'FFFFFF'
1327+
}
13221328
}
13231329
}
1324-
};
1330+
};
13251331

1326-
//Array of objects representing heading rows (very top)
1327-
const heading = [
1328-
];
1332+
//Array of objects representing heading rows (very top)
1333+
const heading = [
1334+
];
13291335

1330-
//Here you specify the export structure
1331-
const specification = {
1332-
category: { // <- the key should match the actual data key
1333-
displayName: 'Category', // <- Here you specify the column header
1334-
headerStyle: styles.cellPink, // <- Header style
1335-
width: 220 // <- width in pixels
1336-
},
1337-
node: {
1338-
displayName: 'Node',
1339-
headerStyle: styles.cellPink,
1340-
width: 220 // <- width in chars (when the number is passed as string)
1341-
},
1342-
property: {
1343-
displayName: 'Property',
1344-
headerStyle: styles.cellPink,
1345-
width: 220 // <- width in pixels
1346-
},
1347-
ncit: {
1348-
displayName: 'NCIt Code',
1349-
headerStyle: styles.cellPink,
1350-
width: 220 // <- width in pixels
1351-
}
1336+
//Here you specify the export structure
1337+
const specification = {
1338+
category: { // <- the key should match the actual data key
1339+
displayName: 'Category', // <- Here you specify the column header
1340+
headerStyle: styles.cellPink, // <- Header style
1341+
width: 220 // <- width in pixels
1342+
},
1343+
node: {
1344+
displayName: 'Node',
1345+
headerStyle: styles.cellPink,
1346+
width: 220 // <- width in chars (when the number is passed as string)
1347+
},
1348+
property: {
1349+
displayName: 'Property',
1350+
headerStyle: styles.cellPink,
1351+
width: 220 // <- width in pixels
1352+
},
1353+
ncit: {
1354+
displayName: 'NCIt Code',
1355+
headerStyle: styles.cellPink,
1356+
width: 220 // <- width in pixels
1357+
},
1358+
cdeid: {
1359+
displayName: 'CDE ID',
1360+
headerStyle: styles.cellPink,
1361+
width: 220 // <- width in pixels
13521362
}
1363+
}
13531364

1354-
// Define an array of merges. 1-1 = A:1
1355-
// The merges are independent of the data.
1356-
// A merge will overwrite all data _not_ in the top-left cell.
1357-
const merges = [];
1358-
1359-
// Create the excel report.
1360-
// This function will return Buffer
1361-
const report = export_excel.buildExport(
1362-
[ // <- Notice that this is an array. Pass multiple sheets to create multi sheet report
1363-
{
1364-
name: 'Report', // <- Specify sheet name (optional)
1365-
heading: heading, // <- Raw heading array (optional)
1366-
merges: merges, // <- Merge cell ranges
1367-
specification: specification, // <- Report specification
1368-
data: dataset // <-- Report data
1365+
// Define an array of merges. 1-1 = A:1
1366+
// The merges are independent of the data.
1367+
// A merge will overwrite all data _not_ in the top-left cell.
1368+
const merges = [];
1369+
1370+
// Create the excel report.
1371+
// This function will return Buffer
1372+
const report = export_excel.buildExport(
1373+
[ // <- Notice that this is an array. Pass multiple sheets to create multi sheet report
1374+
{
1375+
name: 'Report', // <- Specify sheet name (optional)
1376+
heading: heading, // <- Raw heading array (optional)
1377+
merges: merges, // <- Merge cell ranges
1378+
specification: specification, // <- Report specification
1379+
data: dataset // <-- Report data
1380+
}
1381+
]
1382+
);
1383+
1384+
// You can then return this straight
1385+
res.attachment('GDC_Properties_Data_Mapping.xlsx'); // This is sails.js specific (in general you need to set headers)
1386+
res.send(report);
1387+
}
1388+
1389+
1390+
const generateGDCValuesReport = async function(req, res) {
1391+
const dataset = [];
1392+
let GDCDict = await shared.getGDCDictionaryByVersion("2.5.0");
1393+
let gdc_values = shared.readGDCValues();
1394+
let syns = shared.readNCItDetails();
1395+
1396+
for(let node in GDCDict){
1397+
let entry = GDCDict[node];
1398+
if(entry.properties){
1399+
let prop_dict = entry.properties;
1400+
for(let prop in prop_dict){
1401+
let uid = entry.category + "." + node + "." + prop;
1402+
let prop_enum = prop_dict[prop] !== undefined && prop_dict[prop].enum !== undefined && prop_dict[prop].enum.length > 0 ? prop_dict[prop].enum : [];
1403+
prop_enum = prop_dict[prop] !== undefined && prop_dict[prop].items !== undefined && prop_dict[prop].items.enum !== undefined && prop_dict[prop].items.enum.length > 0 ? prop_dict[prop].items.enum : prop_enum;
1404+
1405+
let mappings = gdc_values[uid] !== undefined ? gdc_values[uid] : [];
1406+
let deprecated_enum = prop_dict[prop] !== undefined && prop_dict[prop].deprecated_enum !== undefined && prop_dict[prop].deprecated_enum.length > 0 ? prop_dict[prop].deprecated_enum : [];
1407+
1408+
for(let value of prop_enum){
1409+
let tmp = {};
1410+
tmp.category = entry.category;
1411+
tmp.node = node;
1412+
tmp.property = prop;
1413+
tmp.value = value;
1414+
tmp.ncit = [];
1415+
tmp.icdo3 = '';
1416+
tmp.icdoS = [];
1417+
tmp.ncitPV = [];
1418+
1419+
if (deprecated_enum.includes(value)) {
1420+
continue;
1421+
}
1422+
1423+
let map = mappings.find(({ nm }) => nm === value);
1424+
if(map !== undefined){
1425+
tmp.ncit = Array.isArray(map.n_c) ? map.n_c.join('|') : '';
1426+
tmp.icdo3 = map.i_c;
1427+
tmp.icdoS = Array.isArray(map.i_c_s) ? map.i_c_s.join('|') : ''
1428+
for(let code of map.n_c){
1429+
tmp.ncitPV.push(syns[code] !== undefined ? syns[code].label : '');
1430+
}
1431+
tmp.ncitPV = Array.isArray(tmp.ncitPV) ? tmp.ncitPV.join('|') : '';
1432+
}
1433+
1434+
dataset.push(tmp);
1435+
}
13691436
}
1370-
]
1371-
);
1437+
}
1438+
}
1439+
1440+
// You can define styles as json object
1441+
const styles = {
1442+
cellPink: {
1443+
fill: {
1444+
fgColor: {
1445+
rgb: '1F497D'
1446+
}
1447+
},
1448+
font:{
1449+
color: {
1450+
rgb: 'FFFFFF'
1451+
}
1452+
}
1453+
}
1454+
};
13721455

1373-
// You can then return this straight
1374-
res.attachment('report.xlsx'); // This is sails.js specific (in general you need to set headers)
1375-
res.send(report);
1456+
//Array of objects representing heading rows (very top)
1457+
const heading = [
1458+
];
1459+
1460+
//Here you specify the export structure
1461+
const specification = {
1462+
category: { // <- the key should match the actual data key
1463+
displayName: 'Category', // <- Here you specify the column header
1464+
headerStyle: styles.cellPink, // <- Header style
1465+
width: 220 // <- width in pixels
1466+
},
1467+
node: {
1468+
displayName: 'Node',
1469+
headerStyle: styles.cellPink,
1470+
width: 220 // <- width in chars (when the number is passed as string)
1471+
},
1472+
property: {
1473+
displayName: 'Property',
1474+
headerStyle: styles.cellPink,
1475+
width: 220 // <- width in pixels
1476+
},
1477+
value: {
1478+
displayName: 'GDC Values',
1479+
headerStyle: styles.cellPink,
1480+
width: 220 // <- width in pixels
1481+
},
1482+
ncit: {
1483+
displayName: 'NCIt Code',
1484+
headerStyle: styles.cellPink,
1485+
width: 220 // <- width in pixels
1486+
},
1487+
ncitPV: {
1488+
displayName: 'NCIt PV',
1489+
headerStyle: styles.cellPink,
1490+
width: 220 // <- width in pixels
1491+
},
1492+
icdo3: {
1493+
displayName: 'ICDO3 Code',
1494+
headerStyle: styles.cellPink,
1495+
width: 220 // <- width in pixels
1496+
},
1497+
icdoS: {
1498+
displayName: 'ICDO3 String',
1499+
headerStyle: styles.cellPink,
1500+
width: 220 // <- width in pixels
1501+
}
1502+
}
1503+
1504+
// Define an array of merges. 1-1 = A:1
1505+
// The merges are independent of the data.
1506+
// A merge will overwrite all data _not_ in the top-left cell.
1507+
const merges = [];
1508+
1509+
// Create the excel report.
1510+
// This function will return Buffer
1511+
const report = export_excel.buildExport(
1512+
[ // <- Notice that this is an array. Pass multiple sheets to create multi sheet report
1513+
{
1514+
name: 'Report', // <- Specify sheet name (optional)
1515+
heading: heading, // <- Raw heading array (optional)
1516+
merges: merges, // <- Merge cell ranges
1517+
specification: specification, // <- Report specification
1518+
data: dataset // <-- Report data
1519+
}
1520+
]
1521+
);
1522+
1523+
// You can then return this straight
1524+
res.attachment('GDC_Values_Data_Mapping.xlsx'); // This is sails.js specific (in general you need to set headers)
1525+
res.send(report);
13761526
}
13771527

13781528

1529+
13791530
const generateCompareProperties = async function(req, res) {
13801531
try {
13811532
const datasetnew = {};
@@ -1959,7 +2110,8 @@ module.exports = {
19592110
compareAllWithGDCDictionary,
19602111
exportCompareResult,
19612112
exportAllCompareResult,
1962-
generateProperties,
2113+
generateGDCPropertiesReport,
2114+
generateGDCValuesReport,
19632115
generateCompareProperties,
19642116
generateCompareNodes,
19652117
updateGDCPropertyMappings,

server/service/search/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ router.get("/p/local/vs", controller.getGDCData);
2525
router.get('/compareAllWithGDCDictionary', controller.compareAllWithGDCDictionary);
2626
router.get('/exportCompareResult', controller.exportCompareResult);
2727
router.get('/exportAllCompareResult', controller.exportAllCompareResult);
28-
//router.get('/generateProperties', controller.generateProperties);
28+
//router.get('/generateGDCPropertiesReport', controller.generateGDCPropertiesReport);
29+
router.get('/generateGDCValuesReport', controller.generateGDCValuesReport);
2930
//router.get('/generateCompareProperties', controller.generateCompareProperties);
3031
//router.get('/generateCompareNodes', controller.generateCompareNodes);
3132
//router.get('/updateGDCPropertyMappings', controller.updateGDCPropertyMappings);

0 commit comments

Comments
 (0)