Skip to content

Commit

Permalink
All files can be read. go2gene is slow as hell.
Browse files Browse the repository at this point in the history
  • Loading branch information
dns-mcdaid committed Aug 4, 2016
1 parent 55e66ce commit 9354c34
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 60 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"nodemon": "^1.9.2",
"p5": "~0.5.2",
"seedrandom": "^2.4.2",
"serve-favicon": "~2.3.0"
"serve-favicon": "~2.3.0",
"underscore": "~1.8.0"
}
}
55 changes: 32 additions & 23 deletions public/javascripts/data/dataReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ DataReader.prototype = {
var pub = s[0];
var desc = s[1];
var g = new Gene(pub, desc);
// if (i < 10) {
// console.log(g);
// }
genes[pub.toLowerCase()] = g;
} catch (e) {
console.log("Offending line: " + line);
Expand Down Expand Up @@ -133,9 +130,6 @@ DataReader.prototype = {
if (i == lines.length-1) {
callback();
}
// if (i < 10) {
// console.log(terms[f[0]]);
// }
} catch (e) {
console.log("Offending line: " + line);
throw new ParseException("parse error at line " + i + " of " + listU, line, e);
Expand Down Expand Up @@ -187,7 +181,6 @@ DataReader.prototype = {
}
}
var rootsTArray = rootsT.toArray();
console.log(rootsTArray);
for (var k = 0; k < rootsTArray.length; k++) {
rootsV.push(rootsTArray[k]);
}
Expand All @@ -209,43 +202,58 @@ DataReader.prototype = {
} else {
DataReader.openURL(assocU, function(response) {
// parse GO / gene correspondence
var missingGene = new TreeSet();
var missingTerm = new TreeSet();
var missingGene = new SortedSet();
var missingTerm = new SortedSet();
var lines = response.split("\n");
DataReader.parseHeader(response, a, "correspondence");
for (var i = 0; i < response.length; i++) {
var line = response[i];
console.log(line);
try {
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
console.log(i + "/" + lines.length);
if (line.length < 1) {
continue;
}
// try {
var f = line.split(DataReader.SEP);
var s = f.length < 3 ? [] : f[2].trim().split(DataReader.FSEP);
var tn = f[0].trim();
var t = terms[tn];

if (t == null || typeof t == 'undefined') {
missingTerm.add(tn);
missingTerm.push(tn);
continue;
}
var p_t = Number(f[1].trim());
// if ( i == 246 ) {
// // console.log("F: " + f);
// // console.log("S: " + s);
// console.log("TN: " + tn);
// console.log("T: " + t);
// console.log("p_t: " + p_t);
// }
t.setRatio(p_t);
for (var k = 0; k < s.length; k++) {
var gn = s[k].trim();
var g = genes[gn.toLowerCase()];
if (g === null || typeof g === 'undefined') {
missingGene.add(gn);
missingGene.push(gn);
} else {
var genev = geneToGo[g];
if (genev === null || typeof genev === 'undefined') {
genev = [];
}
// console.log("Genev: " + i + ": " + k + "/" + s.length + ": " + genev);
genev.push(t);
t.addGene(g);
geneToGo[g] = genev;
}
}
} catch (e) {
console.log("Offending line: " + line);
throw new ParseException("parse error at line" + i + " of " + assocU, line, e);
}
// } catch (e) {
// console.log("Offending line: " + line);
// console.log(e);
// throw new ParseException("parse error at line" + i + " of " + assocU, line, e);
// }
}
callback();
});
}
},
Expand All @@ -269,16 +277,16 @@ DataReader.prototype = {
DataReader.openURL(sungearU, function(response) {
DataReader.parseHeader(response, a, "sungear");
// title line
var line = response[0];
var lines = response.split('\n');
var line = lines[0];
var f = DataReader.trimAll(line.split(DataReader.SEP));
var i = 0;
for (i = 0; i < f.length-1; i++) {
anchors.push(new Anchor(f[i]));
}
var exp = [];
for (i = 1; i < response.length; i++) {
line = response[i];
console.log(line);
for (i = 1; i < lines.length; i++) {
line = lines[i];
try {
if (line == "") {
continue;
Expand All @@ -304,6 +312,7 @@ DataReader.prototype = {
throw new ParseException("parse error at line " + i + " of " + sungearU, line, e);
}
}
callback();
});
}
},
Expand Down
87 changes: 51 additions & 36 deletions public/javascripts/data/dataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ DataSource.prototype = {
if (typeof callback === 'undefined') {
this.set(attrib, null, status);
} else {
var numOfFiles = 0;
var geneU = attrib.get("geneU");
var listU = attrib.get("listU");
var hierU = attrib.get("hierU");
Expand All @@ -157,60 +156,76 @@ DataSource.prototype = {
if (status !== null) {
status.updateStatus("Reading Items List", 0);
}

if (this.geneSrc === null || this.geneSrc != geneU) {
console.log("Attempting to readGenes:");
this.reader.readGenes(geneU, function() {
console.log("Back from readGenes!");
numOfFiles++;
this.geneSrc = geneU;
if (numOfFiles == 5) {
callback();
}
this.readTerms(listU, hierU, assocU, sungearU, function() {
console.log("Back!");
}.bind(this));
}.bind(this));
}
if (status !== null) {
status.updateStatus("Reading Categories", 1);
}
if (this.glSrc === null || this.glSrc != listU || this.ghSrc === null || this.ghSrc != hierU) {
this.reader.readTerms(listU, function() {
console.log("back from readTerms!");
this.glSrc = listU;
this.ghSrc = hierU;
numOfFiles++;
this.reader.readHierarchy(hierU, function() {
console.log("back from readHierarchy!");
numOfFiles++;
if (numOfFiles == 5) {
callback();
}
});
}.bind(this));

if (status !== null) {
var iL = attrib.get("itemsLabel", "items");
var cL = attrib.get("categoriesLabel", "categories");
status.updateStatus("Reading " + cL + " / " + iL + " Associations", 2);
}

if (status !== null) {
status.updateStatus("Reading Sungear Data", 3);
}
// if (status !== null) {
// var iL = attrib.get("itemsLabel", "items");
// var cL = attrib.get("categoriesLabel", "categories");
// status.updateStatus("Reading " + cL + " / " + iL + " Associations", 2);
// }
// if (this.ggSrc === null || this.ggSrc != assocU) {
// this.reader.readGeneToGo(assocU);
// this.ggSrc = assocU;
// }
// if (status !== null) {
// status.updateStatus("Reading Sungear Data", 3);
// }
// this.reader.readSungear(sungearU);
// this.sunSrc = sungearU;
// callback();
}
},
readTerms : function(listU, hierU, assocU, sungearU, callback) {
console.log("Mmmmkay");
console.log(this.glSrc);
console.log(listU);
if (this.glSrc === null || this.glSrc != listU || this.ghSrc === null || this.ghSrc != hierU) {
this.reader.readTerms(listU, function() {
console.log("back from readTerms!");
this.glSrc = listU;
this.readHierarchy(hierU, assocU, sungearU, function() {
callback();
});
}.bind(this));
}
},
readHierarchy : function(hierU, assocU, sungearU, callback) {
this.reader.readHierarchy(hierU, function() {
console.log("back from readHierarchy!");
this.ghSrc = hierU;
this.readGeneToGo(assocU, sungearU, function() {
callback();
});
}.bind(this));
},
readGeneToGo : function(assocU, sungearU, callback) {
this.reader.readGeneToGo(assocU, function() {
console.log("Back from Gene to Go!");
this.ggSrc = assocU;
this.readSungear(sungearU, function() {
callback();
});
}.bind(this));
},
readSungear : function(sungearU, callback) {
this.reader.readSungear(sungearU, function() {
console.log("Back from SunGear");
this.sunSrc = sungearU;
callback();
}.bind(this));
},
/**
* Returns the current data reader
* @return the data reader
*/
getReader : function() {
return this.reader;

}
};

Expand Down

0 comments on commit 9354c34

Please sign in to comment.