diff --git a/server/controllers/importers/sif.js b/server/controllers/importers/sif.js index 002046c9..5ef130b8 100644 --- a/server/controllers/importers/sif.js +++ b/server/controllers/importers/sif.js @@ -64,7 +64,18 @@ module.exports = function (sif) { var hasNumbers = relationships.some(isNumber); var allNumbers = relationships.every(isNumber); + + let networkMode = "grn"; + for (const relationship of relationships) { + if (relationship === "pp") { + networkMode = "protein-protein-physical-interaction"; + break; + } else if (relationship === "pd") { + break; + } + } return { + networkMode: networkMode, sheetType: allNumbers ? constants.WEIGHTED : constants.UNWEIGHTED, warnings: hasNumbers && !allNumbers ? constants.warnings.EDGES_WITHOUT_WEIGHTS : null, errors: errors @@ -134,6 +145,7 @@ module.exports = function (sif) { errors: errors, warnings: warnings, sheetType: workbookType.sheetType, + networkMode: workbookType.networkMode, positiveWeights: [], negativeWeights: [], meta: {}, diff --git a/test/import-sif-tests.js b/test/import-sif-tests.js index 2d1759db..cd5911e1 100644 --- a/test/import-sif-tests.js +++ b/test/import-sif-tests.js @@ -27,7 +27,8 @@ var expectedUnweightedWorkbook = initWorkbook({ negativeWeights: [], sheetType: "unweighted", meta: {}, - expression:{} + expression:{}, + networkMode: "grn" }); var expectedWeightedWorkbook = initWorkbook({ @@ -50,6 +51,7 @@ var expectedWeightedWorkbook = initWorkbook({ negativeWeights: [], sheetType: "weighted", meta: {}, + networkMode: "grn", expression:{} }); @@ -76,7 +78,8 @@ var expectedUnweightedWorkbookWithCycle = initWorkbook({ negativeWeights: [], sheetType: "unweighted", meta: {}, - expression:{} + expression:{}, + networkMode: "grn" }); var expectedWeightedWorkbookWithCycle = initWorkbook({ @@ -102,7 +105,8 @@ var expectedWeightedWorkbookWithCycle = initWorkbook({ negativeWeights: [], sheetType: "weighted", meta: {}, - expression:{} + expression:{}, + networkMode: "grn" }); // Unweighted SIF @@ -350,7 +354,8 @@ describe("Import from SIF", function () { negativeWeights: [], sheetType: "unweighted", meta: {}, - expression:{} + expression:{}, + networkMode: "grn" })); }); @@ -368,7 +373,8 @@ describe("Import from SIF", function () { negativeWeights: [], sheetType: "weighted", meta: {}, - expression:{} + expression:{}, + networkMode: "grn" })); }); diff --git a/web-client/public/js/setup-load-and-import-handlers.js b/web-client/public/js/setup-load-and-import-handlers.js index 7a7408c1..dfea2028 100644 --- a/web-client/public/js/setup-load-and-import-handlers.js +++ b/web-client/public/js/setup-load-and-import-handlers.js @@ -143,10 +143,15 @@ export const setupLoadAndImportHandlers = (grnState) => { break; } } - // TODO 👆🏼 The back end will add a `networkType` property to this object. - // The web app can then adjust various things based on that. grnState.workbook = workbook; - grnState.mode = workbook.meta.data.workbookType; + + if (grnState.name.includes(".sif")) { + grnState.mode = workbook.networkMode; + } else if (grnState.name.includes(".graphml")) { + grnState.mode = "grn"; + } else { + grnState.mode = workbook.meta.data.workbookType; + } grnState.workbook.expressionNames = Object.keys(workbook.expression); if (uploadRoute !== "upload") { grnState.annotateLinks();