Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash bam features #1145

Merged
merged 4 commits into from Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/JBrowse/Digest/Crc32.js
Expand Up @@ -22,9 +22,27 @@ var Crc32 = {
return re;
},

crc32: function( str, crc ) {
crc32_raw: function( bytes, start, end, crc = 0 ) {
var n = 0; //a number between 0 and 255
var x = 0; //a hex number
var table = Crc32.crc32Table;

crc = crc ^ (-1);
for( var i = start, iTop = end; i < iTop; i++ ) {
n = ( crc ^ bytes[i] ) & 0xFF;
x = "0x" + table.substr( n * 9, 8 );
crc = ( crc >>> 8 ) ^ x;
}
crc = crc ^ (-1);
//convert to unsigned 32-bit int if needed
if (crc < 0) {
crc += 4294967296;
}
return crc;
},

crc32: function( str, crc = 0 ) {
var bytes = Crc32.stringToBytes(str);
if( crc == window.undefined ) crc = 0;
var n = 0; //a number between 0 and 255
var x = 0; //a hex number
var table = Crc32.crc32Table;
Expand Down Expand Up @@ -62,4 +80,4 @@ var Crc32 = {
};

return Crc32;
});
});
5 changes: 3 additions & 2 deletions src/JBrowse/Store/SeqFeature/BAM/LazyFeature.js
@@ -1,9 +1,10 @@
define( ['dojo/_base/array',
'JBrowse/Util',
'JBrowse/Digest/Crc32',
'./Util',
'JBrowse/Model/SimpleFeature'
],
function( array, Util, BAMUtil, SimpleFeature ) {
function( array, Util, Crc32, BAMUtil, SimpleFeature ) {

var SEQRET_DECODER = ['=', 'A', 'C', 'x', 'G', 'x', 'x', 'x', 'T', 'x', 'x', 'x', 'x', 'x', 'x', 'N'];
var CIGAR_DECODER = ['M', 'I', 'D', 'N', 'S', 'H', 'P', '=', 'X', '?', '?', '?', '?', '?', '?', '?'];
Expand Down Expand Up @@ -100,7 +101,7 @@ var Feature = Util.fastDeclare(
},

id: function() {
return this._get('name')+'/'+this._get('md')+'/'+this._get('cigar')+'/'+this._get('start')+'/'+this._get('multi_segment_next_segment_reversed');
return Crc32.crc32_raw(this.bytes.byteArray, this.bytes.start, this.bytes.end);
},

multi_segment_all_aligned: function() {
Expand Down
1 change: 1 addition & 0 deletions tests/data/duplicate_bam_features_tomato/seq/refSeqs.json
@@ -0,0 +1 @@
[{"end":13350063,"length":13350063,"name":"SL2.50ch03","start":0}]
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/data/duplicate_bam_features_tomato/tracks.conf
@@ -0,0 +1,4 @@
[tracks.tomato_bam]
urlTemplate=six_tomato_reads.bam
type=Alignments2
hideSecondary=false