Skip to content

Commit

Permalink
Merge pull request #657 from erasche/extra-starts
Browse files Browse the repository at this point in the history
Allow overriding start/stop characters for highlighting in refseq track
  • Loading branch information
cmdcolin committed Dec 8, 2015
2 parents 380dd78 + 22838cb commit bec318c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions css/sequence.css
Expand Up @@ -81,11 +81,11 @@ table.sequence.big .base {
border-right-color: #5f5f5f;
}

.translatedSequence td.aminoAcid_\* {
.translatedSequence td.aminoAcid_stop {
background-color: #FF0000;
}

.translatedSequence td.aminoAcid_m {
.translatedSequence td.aminoAcid_start {
background-color: #00FF00;
}

Expand Down
12 changes: 11 additions & 1 deletion src/JBrowse/CodonTable.js
Expand Up @@ -3,6 +3,16 @@ define( ['dojo/_base/declare'],

return declare(null, {

defaultStarts: [
'ATG',
'CTG',
'GTG',
],
defaultStops: [
'TAA',
'TAG',
'TGA',
],
defaultCodonTable: {

"TCA" : "S",
Expand Down Expand Up @@ -75,7 +85,7 @@ generateCodonTable:function(table) {
/**
* take CodonTable above and generate larger codon table that includes
* all permutations of upper and lower case nucleotides
*/
*/
var tempCodonTable = { };
for (var codon in table) {
// looping through codon table, make sure not hitting generic properties...
Expand Down
16 changes: 15 additions & 1 deletion src/JBrowse/View/Track/Sequence.js
Expand Up @@ -38,6 +38,8 @@ return declare( [BlockBased, ExportMixin, CodonTable],
constructor: function( args ) {
this._charMeasurements = {};
this._codonTable = this.generateCodonTable(lang.mixin(this.defaultCodonTable,this.config.codonTable));
this._codonStarts = this.config.codonStarts || this.defaultStarts
this._codonStops = this.config.codonStops || this.defaultStops
},

_defaultConfig: function() {
Expand Down Expand Up @@ -198,10 +200,11 @@ return declare( [BlockBased, ExportMixin, CodonTable],
for( var i = 0; i < seqSliced.length; i += 3 ) {
var nextCodon = seqSliced.slice(i, i + 3);
var aminoAcid = this._codonTable[nextCodon] || this.nbsp;
translated = translated + aminoAcid;
translated += aminoAcid;
}

translated = reverse ? translated.split("").reverse().join("") : translated; // Flip the translated seq for left-to-right rendering
orientedSeqSliced = reverse ? seqSliced.split("").reverse().join("") : seqSliced

var charSize = this.getCharacterMeasurements("aminoAcid");
var bigTiles = scale > charSize.w + 4; // whether to add .big styles to the base tiles
Expand Down Expand Up @@ -232,7 +235,18 @@ return declare( [BlockBased, ExportMixin, CodonTable],

for( var i=0; i<translated.length; i++ ) {
var aminoAcidSpan = document.createElement('td');
var originalCodon = orientedSeqSliced.slice(3 * i, 3 * i + 3)
originalCodon = reverse ? originalCodon.split("").reverse().join("") : originalCodon;
aminoAcidSpan.className = 'aminoAcid aminoAcid_'+translated.charAt(i).toLowerCase();

// However, if it's known to be a start/stop, apply those CSS classes instead.
if (this._codonStarts.indexOf(originalCodon.toUpperCase()) != -1) {
aminoAcidSpan.className = 'aminoAcid aminoAcid_start'
}
if (this._codonStops.indexOf(originalCodon.toUpperCase()) != -1) {
aminoAcidSpan.className = 'aminoAcid aminoAcid_stop'
}

aminoAcidSpan.style.width = charWidth;
if( drawChars ) {
aminoAcidSpan.innerHTML = translated.charAt( i );
Expand Down

0 comments on commit bec318c

Please sign in to comment.