Commit 3871afa8 authored by sauloal's avatar sauloal
Browse files

2016-04-19 23:28:35+02:00 ::

parent 44b60f95
...@@ -23,11 +23,12 @@ var bionano_parser = function() { ...@@ -23,11 +23,12 @@ var bionano_parser = function() {
bionano_parser.prototype.add_file = function(file) { bionano_parser.prototype.add_file = function(file) {
console.log('adding file', file); console.log('adding file', file);
for ( var ext in this.acceptedExtensions ) { for ( var ext in this.acceptedExtensions ) {
console.log('ext', ext); console.log('ext', ext);
if ( file.name.endsWith(ext) ) { if ( file.name.endsWith(ext) ) {
this.files[this.acceptedExtensions[ext]] = file; this.files[this.acceptedExtensions[ext]] = file;
break break;
} }
} }
} }
...@@ -65,9 +66,7 @@ bionano_parser.prototype.report = function(self, clbk) { ...@@ -65,9 +66,7 @@ bionano_parser.prototype.report = function(self, clbk) {
} }
//https://genome.ucsc.edu/FAQ/FAQformat.html#format1 bionano_parser.prototype.report_cmap = function(self, ldata, desc, track_name, clbk) {
bionano_parser.prototype.report_r_cmap = function(self, clbk) {
var ldata = self.data['r_cmap' ];
var filename = ldata['filename' ]; // var filename = ldata['filename' ]; //
var header = ldata['header' ]; // [] var header = ldata['header' ]; // []
var data = ldata['data' ]; // {} var data = ldata['data' ]; // {}
...@@ -84,7 +83,7 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) { ...@@ -84,7 +83,7 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) {
var chrom_names = {}; var chrom_names = {};
var chrom_sizes = {}; var chrom_sizes = {};
for (var chrid in self.data['key_file']['data' ]) { for (var chrid in self.data['key_file']['data' ]) {
var cdata = self.data['key_file']['data' ][chrid]; var cdata = self.data['key_file']['data' ][chrid];
var chrom_name = cdata[0]; var chrom_name = cdata[0];
var chrom_size = cdata[1]; var chrom_size = cdata[1];
...@@ -103,13 +102,13 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) { ...@@ -103,13 +102,13 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) {
var indexOfOccurrence = col_names.indexOf('Occurrence' ); var indexOfOccurrence = col_names.indexOf('Occurrence' );
var outdata_bed = [ var outdata_bed = [
'#track name=referenceNicking description="BioNano Genomics Reference Nicking Pattern" useScore=1' '#track name="'+track_name+'" description="'+desc+'" useScore=1 src="'+filename+'"'
]; ];
//http://genome.ucsc.edu/goldenPath/help/wiggle.html //http://genome.ucsc.edu/goldenPath/help/wiggle.html
var outdata_wig = []; var outdata_wig = [];
for ( var chromnum in chroms ) { for ( var chromnum in chroms ) {
var chrom_name = chroms[chromnum]; var chrom_name = chroms[chromnum];
var chrom_size = chrom_sizes[chrom_name]; var chrom_size = chrom_sizes[chrom_name];
...@@ -124,8 +123,8 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) { ...@@ -124,8 +123,8 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) {
//console.log(' cdata ', cdata ); //console.log(' cdata ', cdata );
outdata_wig.push( "browser position "+chrom_name+":0-"+(chrom_size - 1) ); outdata_wig.push( '#browser position '+chrom_name+':0-'+(chrom_size - 1) );
outdata_wig.push( 'track type=wiggle_0 name="reference" description="BioNano Genomics Reference Nicking Pattern" visibility=full autoScale=off viewLimits=0.0:1.0 color=0,255,00 altColor=255,0,0 alwaysZero=on graphType=bar smoothingWindow=off priority=10' ); outdata_wig.push( '#track type=wiggle_0 name="reference" description="BioNano Genomics Reference Nicking Pattern" visibility=full autoScale=off viewLimits=0.0:1.0 color=0,255,00 altColor=255,0,0 alwaysZero=on graphType=bar smoothingWindow=off priority=10' );
outdata_wig.push( 'variableStep chrom='+chrom_name+' span='+nick_sites[Object.keys(nick_sites)[0]][1] ); outdata_wig.push( 'variableStep chrom='+chrom_name+' span='+nick_sites[Object.keys(nick_sites)[0]][1] );
var out_row_bed = [ var out_row_bed = [
...@@ -195,6 +194,7 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) { ...@@ -195,6 +194,7 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) {
out_row_bed = out_row_bed.join("\t"); out_row_bed = out_row_bed.join("\t");
outdata_bed.push(out_row_bed); outdata_bed.push(out_row_bed);
} }
console.log('outdata_bed', outdata_bed); console.log('outdata_bed', outdata_bed);
clbk(filename + '.bed', outdata_bed.join("\n")); clbk(filename + '.bed', outdata_bed.join("\n"));
...@@ -202,15 +202,25 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) { ...@@ -202,15 +202,25 @@ bionano_parser.prototype.report_r_cmap = function(self, clbk) {
clbk(filename + '.wig', outdata_wig.join("\n")); clbk(filename + '.wig', outdata_wig.join("\n"));
} }
//https://genome.ucsc.edu/FAQ/FAQformat.html#format1
bionano_parser.prototype.report_r_cmap = function(self, clbk) {
desc = "BioNano Genomics - Reference Nicking Pattern";
track_name = "referenceNicking";
var ldata = self.data['r_cmap' ];
self.report_cmap(self, ldata, desc, track_name);
}
bionano_parser.prototype.report_q_cmap = function(self, clbk) { bionano_parser.prototype.report_q_cmap = function(self, clbk) {
var ldata = self.data['r_cmap' ]; desc = "BioNano Genomics - Genomic Mapping Nicking Pattern";
var header = ldata['header' ]; // [] track_name = "MappingNicking";
var data = ldata['data' ]; // {}
var chr_size = ldata['chr_size' ]; // {} var ldata = self.data['q_cmap' ];
var chr_sites = ldata['chr_sites' ]; // {}
var total_sites = ldata['total_sites']; // 0 self.report_cmap(self, ldata, desc, track_name);
} }
bionano_parser.prototype.report_xmap = function(self, clbk) { bionano_parser.prototype.report_xmap = function(self, clbk) {
...@@ -306,7 +316,7 @@ bionano_parser.prototype.parse_key_file = function(self, clbk) { ...@@ -306,7 +316,7 @@ bionano_parser.prototype.parse_key_file = function(self, clbk) {
} else { //data } else { //data
datanum++; datanum++;
if ( datanum == 1 ) { // col names if ( datanum == 1 ) { // col names
var dfl = "CompntId CompntName CompntLength"; var dfl = "CompntId\tCompntName\tCompntLength";
var hdl = line; var hdl = line;
assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")"); assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")");
...@@ -378,7 +388,7 @@ bionano_parser.prototype.parse_r_cmap = function(self, clbk) { ...@@ -378,7 +388,7 @@ bionano_parser.prototype.parse_r_cmap = function(self, clbk) {
} else { //data } else { //data
datanum++; datanum++;
if ( datanum == 1 ) { // col names if ( datanum == 1 ) { // col names
var dfl = "#h CMapId ContigLength NumSites SiteID LabelChannel Position StdDev Coverage Occurrence"; var dfl = "#h CMapId\tContigLength\tNumSites\tSiteID\tLabelChannel\tPosition\tStdDev\tCoverage\tOccurrence";
var hdl = ldata['header'][ldata['header'].length-2]; var hdl = ldata['header'][ldata['header'].length-2];
//console.log(ldata['header']); //console.log(ldata['header']);
assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")"); assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")");
...@@ -457,7 +467,7 @@ bionano_parser.prototype.parse_q_cmap = function(self, clbk) { ...@@ -457,7 +467,7 @@ bionano_parser.prototype.parse_q_cmap = function(self, clbk) {
} else { //data } else { //data
datanum++; datanum++;
if ( datanum == 1 ) { // col names if ( datanum == 1 ) { // col names
var dfl = "#h CMapId ContigLength NumSites SiteID LabelChannel Position StdDev Coverage Occurrence"; var dfl = "#h CMapId\tContigLength\tNumSites\tSiteID\tLabelChannel\tPosition\tStdDev\tCoverage\tOccurrence";
var hdl = ldata['header'][ldata['header'].length-2]; var hdl = ldata['header'][ldata['header'].length-2];
assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")"); assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")");
self.parse_header(ldata); self.parse_header(ldata);
...@@ -532,7 +542,7 @@ bionano_parser.prototype.parse_xmap = function(self, clbk) { ...@@ -532,7 +542,7 @@ bionano_parser.prototype.parse_xmap = function(self, clbk) {
datanum++; datanum++;
if ( datanum == 1 ) { // col names if ( datanum == 1 ) { // col names
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13
var dfl = "#h XmapEntryID QryContigID RefContigID QryStartPos QryEndPos RefStartPos RefEndPos Orientation Confidence HitEnum QryLen RefLen LabelChannel Alignment"; var dfl = "#h XmapEntryID\tQryContigID\tRefContigID\tQryStartPos\tQryEndPos\tRefStartPos\tRefEndPos\tOrientation\tConfidence\tHitEnum\tQryLen\tRefLen\tLabelChannel\tAlignment";
var hdl = self.data['xmap']['header'][self.data['xmap']['header'].length-2]; var hdl = self.data['xmap']['header'][self.data['xmap']['header'].length-2];
assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")"); assert(hdl == dfl, "line: '" + hdl + "' ("+hdl.length+") != " + "'"+dfl+"' ("+dfl.length+")");
self.parse_header(ldata); self.parse_header(ldata);
......
...@@ -18,7 +18,6 @@ progress:after { content: '%'; } ...@@ -18,7 +18,6 @@ progress:after { content: '%'; }
<body> <body>
<div id="holder"></div> <div id="holder"></div>
<p>Drag an image from your desktop on to the drop zone above to see the browser both render the preview, but also upload automatically to this server.</p> <p>Drag an image from your desktop on to the drop zone above to see the browser both render the preview, but also upload automatically to this server.</p>
<p>Or select them here: <input type="file" id="fileinput" multiple="multiple"/></p>
</body> </body>
<footer>
</footer>
</html> </html>
...@@ -52,7 +52,7 @@ function parse_files(files) { ...@@ -52,7 +52,7 @@ function parse_files(files) {
} }
parse.report(parse, clbk2); parse.report(parse, clbk2);
*/ */
parse.report(create_file); parse.report(parse, create_file);
} }
parse.parse(clbk); parse.parse(clbk);
...@@ -60,44 +60,59 @@ function parse_files(files) { ...@@ -60,44 +60,59 @@ function parse_files(files) {
document.addEventListener("DOMContentLoaded", function(event) {
if (dndSupported() && window.File && window.FileReader && window.FileList && window.Blob) { if (dndSupported() && window.File && window.FileReader && window.FileList && window.Blob) {
console.warn('drag and drop is supported'); console.warn('drag and drop is supported');
doc.ondragover = function () {
this.className = 'hover';
//console.log('drag start');
return false;
};
doc.ondragend = function () {
this.className = '' ;
console.log('drag end');
return false;
};
doc.ondrop = function (event) {
event.preventDefault && event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.;
this.className = ''; doc.ondragover = function () {
this.className = 'hover';
//console.log('drag start');
return false;
};
console.log('dropped'); doc.ondragend = function () {
// now do something with: this.className = '' ;
var files = event.dataTransfer.files; console.log('drag end');
console.log('files',files); return false;
};
parse_files(files); doc.ondrop = function (event) {
event.preventDefault && event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.;
this.className = '';
console.log('dropped');
// now do something with:
var files = event.dataTransfer.files;
console.log('files',files);
parse_files(files);
return false;
};
return false; document.getElementById('fileinput').addEventListener('change', function(){
}; for(var i = 0; i<this.files.length; i++){
} else { var file = this.files[i];
console.warn('drag and drop not supported'); // This code is only for demo ...
// take alternative route console.group("File "+i);
/* console.log("name : " + file.name);
document.getElementById('upload').onchange = function (event) { console.log("size : " + file.size);
// `this` refers to the element the event fired upon console.log("type : " + file.type);
var files = this.files; console.log("date : " + file.lastModified);
}; console.groupEnd();
*/ }
} parse_files(this.files);
\ No newline at end of file }, false);
} else {
console.warn('drag and drop not supported');
// take alternative route
/*
document.getElementById('upload').onchange = function (event) {
// `this` refers to the element the event fired upon
var files = this.files;
};
*/
}
});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment