)}
diff --git a/src/config.json b/src/config.json
index 89483970..e71eed1d 100644
--- a/src/config.json
+++ b/src/config.json
@@ -10,7 +10,8 @@
"region": "17:1-100",
"bedFile": "exampleData/internal/snp1kg-BRCA1.bed",
"dataType": "built-in",
- "simplify": false
+ "simplify": false,
+ "removeSequences": false
},
{
"name": "vg \"small\" example",
diff --git a/src/end-to-end.test.js b/src/end-to-end.test.js
index 923a3f80..2ac04be6 100644
--- a/src/end-to-end.test.js
+++ b/src/end-to-end.test.js
@@ -339,7 +339,7 @@ describe("When we wait for it to load", () => {
it("produces correct link for view before & after go is pressed", async () => {
// First test that after pressing go, the link reflects the dat form
const expectedLinkBRCA1 =
- "http://localhost?name=snp1kg-BRCA1&tracks[0][trackFile]=exampleData%2Finternal%2Fsnp1kg-BRCA1.vg.xg&tracks[0][trackType]=graph&tracks[0][trackColorSettings][mainPalette]=greys&tracks[0][trackColorSettings][auxPalette]=ygreys&tracks[1][trackFile]=exampleData%2Finternal%2FNA12878-BRCA1.sorted.gam&tracks[1][trackType]=read®ion=17%3A1-100&bedFile=exampleData%2Finternal%2Fsnp1kg-BRCA1.bed&dataType=built-in&simplify=false";
+ "http://localhost?name=snp1kg-BRCA1&tracks[0][trackFile]=exampleData%2Finternal%2Fsnp1kg-BRCA1.vg.xg&tracks[0][trackType]=graph&tracks[0][trackColorSettings][mainPalette]=greys&tracks[0][trackColorSettings][auxPalette]=ygreys&tracks[1][trackFile]=exampleData%2Finternal%2FNA12878-BRCA1.sorted.gam&tracks[1][trackType]=read®ion=17%3A1-100&bedFile=exampleData%2Finternal%2Fsnp1kg-BRCA1.bed&dataType=built-in&simplify=false&removeSequences=false";
// Set up dropdown
await act(async () => {
let dropdown = document.getElementById("dataSourceSelect");
@@ -373,7 +373,7 @@ it("produces correct link for view before & after go is pressed", async () => {
await clickCopyLink();
const expectedLinkCactus =
- "http://localhost?tracks[0][trackFile]=exampleData%2Fcactus.vg.xg&tracks[0][trackType]=graph&tracks[1][trackFile]=exampleData%2Fcactus-NA12879.sorted.gam&tracks[1][trackType]=read&bedFile=exampleData%2Fcactus.bed&name=cactus®ion=ref%3A1-100&dataType=built-in&simplify=false";
+ "http://localhost?tracks[0][trackFile]=exampleData%2Fcactus.vg.xg&tracks[0][trackType]=graph&tracks[1][trackFile]=exampleData%2Fcactus-NA12879.sorted.gam&tracks[1][trackType]=read&bedFile=exampleData%2Fcactus.bed&name=cactus®ion=ref%3A1-100&dataType=built-in&simplify=false&removeSequences=false";
// Make sure link has changed after pressing go
expect(fakeClipboard).toEqual(expectedLinkCactus);
}, 20000);
diff --git a/src/server.mjs b/src/server.mjs
index ed80e4d8..5c66b80b 100644
--- a/src/server.mjs
+++ b/src/server.mjs
@@ -382,6 +382,48 @@ api.post("/getChunkedData", (req, res, next) => {
});
});
+
+/*
+graph = {
+ node: [
+ {
+ sequence: "AGCT"
+ id: "1"
+ },
+ {
+ sequence: "AGCTAG"
+ id: "2"
+ }
+ ],
+ edge: [],
+ path: []
+}
+removing sequence would result in
+graph = {
+ node: [
+ {
+ id: "1"
+ },
+ {
+ id: "2"
+ }
+ ],
+ edge: [],
+ path: []
+}
+*/
+
+// read a graph object and remove "sequence" fields in place
+function removeNodeSequencesInPlace(graph){
+ console.log("graph:", graph)
+ if (!graph.node){
+ return;
+ }
+ graph.node.forEach(function(node) {
+ node.sequence = "";
+ })
+}
+
// Handle a chunked data (tube map view) request. Returns a promise. On error,
// either the promise rejects *or* next() is called with an error, or both.
// TODO: This is a terrible mixed design for error handling; we need to either
@@ -497,6 +539,15 @@ async function getChunkedData(req, res, next) {
req.simplify = true;
}
+ // client is going to send removeSequences = true if they don't want sequences of nodes to be displayed
+ req.removeSequences = false;
+ if (req.body.removeSequences) {
+ if (readsExist(req.body.tracks)) {
+ throw new BadRequestError("Can't remove node sequences if read tracks exist.");
+ }
+ req.removeSequences = true;
+ }
+
// check the bed file if this region has been pre-fetched
let chunkPath = "";
if (req.withBed) {
@@ -746,6 +797,9 @@ async function getChunkedData(req, res, next) {
return;
}
req.graph = JSON.parse(graphAsString);
+ if (req.removeSequences){
+ removeNodeSequencesInPlace(req.graph)
+ }
req.region = [rangeRegion.start, rangeRegion.end];
// vg chunk always puts the path we reference on first automatically
if (!sentResponse) {
@@ -855,6 +909,10 @@ async function getChunkedData(req, res, next) {
return;
}
req.graph = JSON.parse(graphAsString);
+ if (req.removeSequences){
+ removeNodeSequencesInPlace(req.graph)
+ }
+ console.log("remove sequences? ", req.graph)
req.region = [rangeRegion.start, rangeRegion.end];
// We might not have the path we are referencing on appearing first.