Skip to content

Commit

Permalink
Cleanup of adapter code
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Oct 31, 2018
1 parent a379c39 commit b109d0d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/JBrowse/Store/SeqFeature/BAM.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ class PairedBamRead {
return Math.max(this.read1._get('end'), this.read2._get('end'))
} else if(field === 'name') {
return this.read1._get('name')
} else if(field === 'pair_orientation') {
return this.read1._get('pair_orientation')
}
}
getPairOrientation() {
const s1 = this.read1._get('strand') === 1 ? 'F1' : 'R1';
const s2 = this.read2._get('strand') === 1 ? 'F2' : 'R2';
return s1 + s2;
}
pairedFeature() { return true }
children() {}
}
Expand Down
20 changes: 14 additions & 6 deletions src/JBrowse/View/FeatureGlyph/Alignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ define([
MismatchesMixin
) {

// adapted from igv.js, illumina standard --> <-- pairs are fr https://software.broadinstitute.org/software/igv/interpreting_pair_orientations
var orientationTypes = {
"fr": {

Expand Down Expand Up @@ -82,9 +81,15 @@ return declare( [BoxGlyph,MismatchesMixin], {
return track.colorForBase('reference');
}
else if(track.config.colorByOrientation) {
const type = orientationTypes[track.config.orientationType]
const orientation = type[feature.get('pair_orientation')]
return {"LR": "grey", "RR": "navy", "RL": "teal", "LL": "green" }[orientation];
const type = orientationTypes[track.config.orientationType]
const orientation = type[feature.get('pair_orientation')]
const map = {
'LR': 'color_pair_lr',
'RR': 'color_pair_rr',
'RL': 'color_pair_rl',
'LL': 'color_pair_ll'
};
return glyph.getStyle( feature, map[orientation] || 'color_nostrand' );
}
else if(track.config.useXS) {
var xs = feature.get('xs')
Expand Down Expand Up @@ -144,17 +149,20 @@ return declare( [BoxGlyph,MismatchesMixin], {
color_rev_missing_mate: '#1919D1',
color_fwd_diff_chr: '#000000',
color_rev_diff_chr: '#969696',
color_pair_lr: 'grey',
color_pair_rr: 'navy',
color_pair_rl: 'teal',
color_pair_ll: 'green',
color_nostrand: '#999999',
border_color: null,

strandArrow: false,
strandInlay: true,

height: 7,
marginBottom: 1,
showMismatches: true,
mismatchFont: 'bold 10px Courier New,monospace',
orientationType: 'fr'
orientationType: 'fr' // default illumina adapter sequence --> <--
}
}
);
Expand Down
2 changes: 2 additions & 0 deletions src/JBrowse/View/FeatureGlyph/PairedAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function(
lang,
Alignment
) {


return declare(Alignment, {

renderFeature( context, fRect ) {
Expand Down
69 changes: 66 additions & 3 deletions src/JBrowse/View/FeatureGlyph/PairedArc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,79 @@ function(
lang,
FeatureGlyph
) {
var orientationTypes = {
"fr": {

"F1R2": "LR",
"F2R1": "LR",

"F1F2": "LL",
"F2F1": "LL",

"R1R2": "RR",
"R2R1": "RR",

"R1F2": "RL",
"R2F1": "RL"
},

"rf": {

"R1F2": "LR",
"R2F1": "LR",

"R1R2": "LL",
"R2R1": "LL",

"F1F2": "RR",
"F2F1": "RR",

"F1R2": "RL",
"F2R1": "RL"
},

"ff": {

"F2F1": "LR",
"R1R2": "LR",

"F2R1": "LL",
"R1F2": "LL",

"R2F1": "RR",
"F1R2": "RR",

"R2R1": "RL",
"F1F2": "RL"
}
};
return declare(FeatureGlyph, {

_defaultConfig: function() {
return this._mergeConfigs(lang.clone(this.inherited(arguments)), {
style: {
color: function(feature, score) {
color: function( feature, score, glyph, track ) {
if(track.config.colorByOrientation) {
const type = orientationTypes[track.config.orientationType]
const orientation = type[feature.get('pair_orientation')]
const map = {
'LR': 'color_pair_lr',
'RR': 'color_pair_rr',
'RL': 'color_pair_rl',
'LL': 'color_pair_ll'
};
return glyph.getStyle( feature, map[orientation] || 'color_nostrand' );
}
return 'hsl(' + Math.abs(score / 10) + ',50%,50%)';
},
color_pair_lr: 'grey',
color_pair_rr: 'navy',
color_pair_rl: 'teal',
color_pair_ll: 'green',
color_nostrand: '#999999',
mouseovercolor: 'rgba(0,0,0,0)',
strandArrow: false
strandArrow: false,
orientationType: 'fr' // default illumina adapter sequence --> <--
}
});
},
Expand All @@ -30,7 +93,7 @@ function(
return;
}
context.beginPath();
context.strokeStyle = this.getConf('style.color', [fRect.f, r.span]);
context.strokeStyle = this.getConf('style.color', [fRect.f, r.span, this, this.track]);
context.arc(r.drawTo + r.r, 0, Math.abs(r.r), 0, Math.PI);
context.stroke();
},
Expand Down
3 changes: 0 additions & 3 deletions src/JBrowse/View/Track/Alignments2.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
}
});

console.log(this.config.viewAsPairs == false && this.config.readCloud == false)
displayOptions.push({
label: 'View normal',
onClick: function(event) {
Expand All @@ -104,8 +103,6 @@ return declare( [ CanvasFeatureTrack, AlignmentsMixin ], {
}
});


console.log('t1',this.config.viewAsPairs == true && this.config.readCloud == false)
displayOptions.push({
label: 'View as pairs',
onClick: function(event) {
Expand Down

0 comments on commit b109d0d

Please sign in to comment.