Skip to content

Commit

Permalink
misc minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmirob committed Mar 6, 2013
1 parent dc6715b commit 686fde5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
17 changes: 11 additions & 6 deletions src/JBrowse/Store/SeqFeature/Boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ getFeatures: function( query, featCallback, doneCallback, errorCallback ) {
// reduce the display, mask, and invMask objects into arrays
var masks = [];
for ( var feats in featureArrays.mask ) {
masks = thisB.orSpan( masks, thisB.toSpan( featureArrays.mask[feats] ) );
masks = thisB.orSpan( masks, thisB.toSpan( featureArrays.mask[feats], query ) );
}
masks = thisB.notSpan( masks, query );
var invMasks = [];
for ( var feats in featureArrays.invMask ) {
invMasks = thisB.orSpan( invMasks, thisB.toSpan( featureArrays.invMask[feats] ) );
invMasks = thisB.orSpan( invMasks, thisB.toSpan( featureArrays.invMask[feats], query ) );
}
var features = [];
for ( var feats in featureArrays.display ) {
Expand Down Expand Up @@ -183,12 +183,12 @@ makeSpan: function( args ) {
// given a list of pseudo-features, outputs a list of non-overlapping spans
var features = args.features || [];
var spans = args.spans || [];
if ( features.length == 0 ) { return spans; }
if ( features.length == 0 ) { return spans.sort(function(a,b){return a.start-b.start}); }
// if the span is empty, the function does nothing
if( spans.length == 0 ) {
spans.push({ start: features[0].start, end: features[0].end });
features.splice(0,1);
if ( features.length == 0 ) { return spans; }
if ( features.length == 0 ) { return spans.sort(function(a,b){return a.start-b.start}); }
}
for (var span in spans) {
if (spans.hasOwnProperty(span)) {
Expand All @@ -213,12 +213,13 @@ inSpan: function( feature, span ) {

},

toSpan: function( features ) {
toSpan: function( features, query ) {
// given a set of features, makes a set of span objects with the same start and end points (a.k.a. pseudo-features)
var spans = [];
for (var feature in features) {
if (features.hasOwnProperty(feature)) {
spans.push( { start: features[feature].get('start'), end: features[feature].get('end') } );
spans.push( { start: Math.max( features[feature].get('start'), query.start ),
end: Math.min( features[feature].get('end'), query.end ) } );
}}
return spans;
},
Expand Down Expand Up @@ -273,6 +274,10 @@ notSpan: function( spans, query ) {
invSpan[i] = { start: span.end };
}}
invSpan[i].end = query.end;
if (invSpan[i].end <= invSpan[i].start) {
invSpan.splice(i,1); }
if (invSpan[0].end <= invSpan[0].start) {
invSpan.splice(0,1); }
return invSpan;
},

Expand Down
10 changes: 5 additions & 5 deletions src/JBrowse/View/Track/SNPCoverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,22 @@ return declare( [Wiggle, MismatchesMixin],
}
});
}, this );
return context;
},

// Overwrites the method from WiggleBase
_draw: function( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale, pixels, spans ) {
// Note: pixels currently has no meaning, as the function that generates it is not yet defined for this track
this._preDraw( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale );
var context = this._drawFeatures( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale, spans );
this._drawFeatures( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale );
if ( spans ) {
this._maskBySpans( scale, leftBase, canvas, context, spans );
this._maskBySpans( scale, leftBase, canvas, spans );
}
this._postDraw( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale );
},

/* If it's a boolean track, mask accordingly */
_maskBySpans: function( scale, leftBase, canvas, context, spans ) {
_maskBySpans: function( scale, leftBase, canvas, spans ) {
var context = canvas.getContext('2d');
var canvasHeight = canvas.height;
var booleanAlpha = this.config.style.masked_transparancy || 45;
this.config.style.masked_transparancy = booleanAlpha;
Expand All @@ -311,7 +311,7 @@ return declare( [Wiggle, MismatchesMixin],
var img = context.getImageData(l, 0, w, canvasHeight);
var pixels = img.data;
for ( var i = 0, n = pixels.length; i < n; i += 4 ) {
/* Note: the default calnvas values are transparent black,
/* Note: the default canvas values are transparent black,
* so we don't want to change the opacity of transparent pixels */
if ( pixels[i+3] != 0 ) { pixels[i+3] = booleanAlpha;}
}
Expand Down
6 changes: 3 additions & 3 deletions src/JBrowse/View/Track/Wiggle/Density.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ return declare( WiggleBase,
if (spans.hasOwnProperty(index)) {
var w = Math.ceil(( spans[index].end - spans[index].start ) * scale );
var l = Math.round(( spans[index].start - leftBase ) * scale );
context.fillRect( l, 0, w-1, canvasHeight );
context.clearRect( l, 0, w-1, canvasHeight/3);
context.clearRect( l, (2/3)*canvasHeight, w-1, canvasHeight/3);
context.fillRect( l, 0, w, canvasHeight );
context.clearRect( l, 0, w, canvasHeight/3);
context.clearRect( l, (2/3)*canvasHeight, w, canvasHeight/3);
}}
dojo.forEach( pixels, function(p,i) {
if (!p) {
Expand Down

0 comments on commit 686fde5

Please sign in to comment.