Skip to content

Commit

Permalink
Fixing issue #1072.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntran18 committed Jan 23, 2024
1 parent 09a4467 commit f93d155
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
12 changes: 12 additions & 0 deletions server/controllers/importers/sif.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -134,6 +145,7 @@ module.exports = function (sif) {
errors: errors,
warnings: warnings,
sheetType: workbookType.sheetType,
networkMode: workbookType.networkMode,
positiveWeights: [],
negativeWeights: [],
meta: {},
Expand Down
16 changes: 11 additions & 5 deletions test/import-sif-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ var expectedUnweightedWorkbook = initWorkbook({
negativeWeights: [],
sheetType: "unweighted",
meta: {},
expression:{}
expression:{},
networkMode: "grn"
});

var expectedWeightedWorkbook = initWorkbook({
Expand All @@ -50,6 +51,7 @@ var expectedWeightedWorkbook = initWorkbook({
negativeWeights: [],
sheetType: "weighted",
meta: {},
networkMode: "grn",
expression:{}
});

Expand All @@ -76,7 +78,8 @@ var expectedUnweightedWorkbookWithCycle = initWorkbook({
negativeWeights: [],
sheetType: "unweighted",
meta: {},
expression:{}
expression:{},
networkMode: "grn"
});

var expectedWeightedWorkbookWithCycle = initWorkbook({
Expand All @@ -102,7 +105,8 @@ var expectedWeightedWorkbookWithCycle = initWorkbook({
negativeWeights: [],
sheetType: "weighted",
meta: {},
expression:{}
expression:{},
networkMode: "grn"
});

// Unweighted SIF
Expand Down Expand Up @@ -350,7 +354,8 @@ describe("Import from SIF", function () {
negativeWeights: [],
sheetType: "unweighted",
meta: {},
expression:{}
expression:{},
networkMode: "grn"
}));
});

Expand All @@ -368,7 +373,8 @@ describe("Import from SIF", function () {
negativeWeights: [],
sheetType: "weighted",
meta: {},
expression:{}
expression:{},
networkMode: "grn"
}));
});

Expand Down
11 changes: 8 additions & 3 deletions web-client/public/js/setup-load-and-import-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f93d155

Please sign in to comment.