Skip to content

Commit

Permalink
Fixed the problems caused by the merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
NAnguiano committed Feb 26, 2015
1 parent 38d2ee0 commit ab87706
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
74 changes: 40 additions & 34 deletions server/controllers/spreadsheet-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,43 +171,49 @@ checkGeneLength = function(errorArray, genesList) {
module.exports = function (app) {
if (app) {

//parse the incoming form data, then parse the spreadsheet. Finally, send back json.
app.post('/upload', function (req, res) {
//TODO: Add file validation
(new multiparty.Form()).parse(req, function (err, fields, files) {
if (err) {
return res.json(400, "There was a problem uploading your file. Please try again.");
}

try {
var input = files.file[0].path;
} catch (err) {
return res.json(400, "No upload file selected.");
}

if (path.extname(input) !== ".xlsx") {
return res.json(400, "This file cannot be loaded because:<br><br> The file is not in a format GRnsight can read." +
"<br>Please select an Excel Workbook (.xlsx) file. Note that Excel 97-2003 Workbook (.xls) files are not " +
" able to be read by GRNsight.");
}

return processGRNmap(input, res, app);
//parse the incoming form data, then parse the spreadsheet. Finally, send back json.
app.post('/upload', function (req, res) {
//TODO: Add file validation
(new multiparty.Form()).parse(req, function (err, fields, files) {
if (err) {
return res.json(400, "There was a problem uploading your file. Please try again.");
}

try {
var input = files.file[0].path;
} catch (err) {
return res.json(400, "No upload file selected.");
}

if (path.extname(input) !== ".xlsx") {
return res.json(400, "This file cannot be loaded because:<br><br> The file is not in a format GRnsight can read." +
"<br>Please select an Excel Workbook (.xlsx) file. Note that Excel 97-2003 Workbook (.xls) files are not " +
" able to be read by GRNsight.");
}

return processGRNmap(input, res, app);
});
});
});

app.get('/demo/unweighted', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_50-edges_Dahlquist-data_input.xlsx", res, app);
});
app.get('/demo/unweighted', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_50-edges_Dahlquist-data_input.xlsx", res, app);
});

app.get('/demo/weighted', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_50-edges_Dahlquist-data_estimation_output.xlsx", res, app);x
});
app.get('/demo/weighted', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_50-edges_Dahlquist-data_estimation_output.xlsx", res, app);x
});

app.get('/demo/schadeInput', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_31-edges_Schade-data_input.xlsx", res, app);
});
app.get('/demo/schadeInput', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_31-edges_Schade-data_input.xlsx", res, app);
});

app.get('/demo/schadeOutput', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_31-edges_Schade-data_estimation_output.xlsx", res, app);
});
app.get('/demo/schadeOutput', function (req, res) {
return processGRNmap("../test-files/demo-files/21-genes_31-edges_Schade-data_estimation_output.xlsx", res, app);
});
}

//exporting parseSheet for use in testing
return {
parseSheet: parseSheet
};
}
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ var assert = require('chai').assert,
xlsx = require('node-xlsx');

var spreadsheetController = require(__dirname + '/../server/controllers' + '/spreadsheet-controller')();
console.log(spreadsheetController);

describe('gene-name-modifications', function () {
describe('duplicate-gene-top-output', function () {
it('should return 1 duplicate gene error', function () {
var sheet = xlsx.parse('test-files/gene-name-modifications/duplicate-gene-top-output.xlsx');
console.log(sheet);
var network = spreadsheetController.parseSheet(sheet);
var sheet = xlsx.parse('test-files/gene-name-modifications/duplicate-gene-top-output.xlsx'),
network = spreadsheetController.parseSheet(sheet);

assert.equal(1, network.errors.length);
assert.equal(
Expand Down

0 comments on commit ab87706

Please sign in to comment.