Skip to content

Commit

Permalink
Karyotype and tooltip plugin rewrites
Browse files Browse the repository at this point in the history
Added Chromosome track, which is used to draw the karyotype now, rather than using divs
Added jquery.tipsy in a separate file, so it can be used by both plugins
  • Loading branch information
simonbrent committed Apr 17, 2014
1 parent 12d1fb6 commit 07b1a74
Show file tree
Hide file tree
Showing 10 changed files with 985 additions and 461 deletions.
4 changes: 3 additions & 1 deletion bam.html
Expand Up @@ -16,6 +16,7 @@
<script type="text/javascript" src="js/lib/jquery-ui.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousehold.js"></script>
<script type="text/javascript" src="js/lib/jquery.tipsy.js"></script>

<script type="text/javascript" src="js/genomes/grch37.js"></script>

Expand All @@ -35,7 +36,8 @@

<script type="text/javascript" src="js/Track/Controller/Stranded.js"></script>
<script type="text/javascript" src="js/Track/Model/Stranded.js"></script>


<script type="text/javascript" src="js/Track/library/Chromosome.js"></script>
<script type="text/javascript" src="js/Track/library/Scaleline.js"></script>
<script type="text/javascript" src="js/Track/library/Scalebar.js"></script>
<script type="text/javascript" src="js/Track/library/Legend.js"></script>
Expand Down
129 changes: 34 additions & 95 deletions css/karyotype.css
@@ -1,115 +1,54 @@
.gv_karyotype_container {
height:50px;
overflow:hidden;
box-shadow: inset 0px 0px 33px -7px rgba(24, 36, 56, 0.97), inset 1px 1px 1px 0px black;
}

.gv_chromosome {
border: 1px solid white;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 0 5px 1px rgba(162, 161, 161, 0.71);
display: block;
height: 38%;
margin: 15px;
position: relative;
}

.gv_band {
display: block;
height: 100%;
position: absolute;
background-color: #7f7f7f;
height: 50px;
overflow: hidden;
font-size: 10px;
font-weight: bold;
font-family: Verdana, Tahoma;
line-height: 2em;
text-align: left;
vertical-align: bottom;
box-shadow: inset 0 0 33px -7px rgba(24, 36, 56, 0.97), inset 1px 1px 1px 0 black;
}

.gv_band.acen {
background-color: #708090;
}
.gv_band.acen:first-child {
border-radius: 0 10px 10px 0;
}
.gv_band.acen:not(:first-child) {
border-radius: 10px 0 0 10px;
.gv_karyotype_container .gv_wrapper {
border: 0;
}

.gv_band.gneg {
background-color: #ffffff;
color: #000000;
}
.gv_band.gpos {
background-color: #000000;
}
.gv_band.gpos100 {
background-color: #000000;
}
.gv_band.gpos25 {
background-color: #d9d9d9;
color: black;
}
.gv_band.gpos33 {
background-color: #bfbfbf;
color: black;
}
.gv_band.gpos50 {
background-color: #999999;
}
.gv_band.gpos66 {
background-color: #7f7f7f;
}
.gv_band.gpos75 {
background-color: #666666;
}
.gv_band.gvar {
background-color: #e0e0e0;
color: black;
}
.gv_band.mark {
background-color: #0000ff;
}
.gv_band.stalk {
background-color: #708090;
.gv_karyotype_container .gv_chromosome {
margin: 15px;
position: relative;
}
.gv_band.tip {
background-color: #000000;

.gv_karyotype_container .image_container {
box-shadow: 0 0 33px -7px #CCC inset;
}

.gv_karyotype_viewpoint {
.gv_karyotype_container .gv_karyotype_viewpoint {
background-color: rgba(222, 84, 35, 0.37);
border: 1px dashed #E6380D;
box-shadow: 0 0 3px 2px rgba(237, 237, 237, 0.4) inset, 0 0 4px 0 rgba(116, 116, 116, 0.7);
display: block;
height: 170%;
position: relative;
position: absolute;
top: -40%;
z-index: 50;
cursor:hand;
cursor:grab;
cursor:-moz-grab;
cursor:-webkit-grab;
cursor: hand;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}

.ui-resizable-e {
cursor: e-resize;
height: 100%;
right: -5px;
top: 0;
width: 7px;
.gv_karyotype_container .ui-resizable-e {
cursor: e-resize;
height: 100%;
right: -5px;
top: 0;
width: 7px;
}
.ui-resizable-w {
cursor: w-resize;
height: 100%;
left: -5px;
top: 0;
width: 7px;

.gv_karyotype_container .ui-resizable-w {
cursor: w-resize;
height: 100%;
left: -5px;
top: 0;
width: 7px;
}
.ui-resizable-handle {
display: block;
font-size: 0.1px;
position: absolute;

.gv_karyotype_container .ui-resizable-handle {
display: block;
font-size: 0.1px;
position: absolute;
}
4 changes: 3 additions & 1 deletion expanded.html
Expand Up @@ -16,6 +16,7 @@
<script type="text/javascript" src="js/lib/jquery-ui.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousehold.js"></script>
<script type="text/javascript" src="js/lib/jquery.tipsy.js"></script>

<script type="text/javascript" src="js/genomes/grch37.js"></script>

Expand All @@ -35,7 +36,8 @@

<script type="text/javascript" src="js/Track/Controller/Stranded.js"></script>
<script type="text/javascript" src="js/Track/Model/Stranded.js"></script>


<script type="text/javascript" src="js/Track/library/Chromosome.js"></script>
<script type="text/javascript" src="js/Track/library/Scaleline.js"></script>
<script type="text/javascript" src="js/Track/library/Scalebar.js"></script>
<script type="text/javascript" src="js/Track/library/Legend.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions ion.html
Expand Up @@ -17,6 +17,7 @@
<script type="text/javascript" src="js/lib/jquery-ui.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="js/lib/jquery.mousehold.js"></script>
<script type="text/javascript" src="js/lib/jquery.tipsy.js"></script>

<script type="text/javascript" src="js/genomes/grch37.js"></script>

Expand All @@ -37,6 +38,7 @@
<script type="text/javascript" src="js/Track/Controller/Stranded.js"></script>
<script type="text/javascript" src="js/Track/Model/Stranded.js"></script>

<script type="text/javascript" src="js/Track/library/Chromosome.js"></script>
<script type="text/javascript" src="js/Track/library/Scaleline.js"></script>
<script type="text/javascript" src="js/Track/library/Scalebar.js"></script>
<script type="text/javascript" src="js/Track/library/Legend.js"></script>
Expand Down
10 changes: 10 additions & 0 deletions js/Genoverse.js
Expand Up @@ -12,6 +12,7 @@ var Genoverse = Base.extend({
plugins : [],
dragAction : 'scroll', // options are: scroll, select, off
wheelAction : 'off', // options are: zoom, off
isStatic : false, // if true, will stop drag, select and zoom actions occurring
genome : undefined,
autoHideMessages : true,
trackAutoHeight : false,
Expand Down Expand Up @@ -128,6 +129,11 @@ var Genoverse = Base.extend({
this.addDomElements(width);
this.addUserEventHandlers();

if (this.isStatic) {
this.dragAction = this.wheelAction = 'off';
this.urlParamTemplate = false;
}

this.tracksById = {};
this.prev = {};
this.urlParamTemplate = this.urlParamTemplate || '';
Expand Down Expand Up @@ -232,6 +238,10 @@ var Genoverse = Base.extend({
}
},
dblclick: function (e) {
if (browser.isStatic) {
return true;
}

browser.hideMessages();
browser.mousewheelZoom(e, 1);
}
Expand Down
126 changes: 126 additions & 0 deletions js/Track/library/Chromosome.js
@@ -0,0 +1,126 @@
Genoverse.Track.Chromosome = Genoverse.Track.extend({
id : 'chromosome',
margin : 1,
featureMargin : { top: 0, right: 0, bottom: 0, left: 0 },
labels : 'overlay',
url : false,
allData : true,
colors : {
acen : '#708090',
gneg : '#FFFFFF',
gpos : '#000000',
gpos100 : '#000000',
gpos25 : '#D9D9D9',
gpos33 : '#BFBFBF',
gpos50 : '#999999',
gpos66 : '#7F7F7F',
gpos75 : '#666666',
gvar : '#E0E0E0',
stalk : '#708090'
},
labelColors: {
gneg : '#000000',
gvar : '#000000',
gpos25 : '#000000',
gpos33 : '#000000'
},

getData: function (start, end) {
this.receiveData([].slice.call(grch37[this.browser.chr].bands), start, end);
return $.Deferred().resolveWith(this);
},

insertFeature: function (feature) {
feature.label = feature.type === 'acen' || feature.type === 'stalk' ? false : feature.id;
feature.color = this.prop('colors')[feature.type];
feature.labelColor = this.prop('labelColors')[feature.type] || '#FFFFFF';

this.base(feature);
},

drawFeature: function (feature, featureContext, labelContext, scale) {
if (feature.type === 'acen') {
featureContext.fillStyle = feature.color;
featureContext.strokeStyle = '#000000';

featureContext.beginPath();

if (feature.sort === 1) {
featureContext.moveTo(feature.x, 0);
featureContext.lineTo(feature.x + feature.width, feature.height / 2);
featureContext.lineTo(feature.x, feature.height + 0.5);
} else {
featureContext.moveTo(feature.x + feature.width, 0);
featureContext.lineTo(feature.x + feature.width, feature.height + 0.5);
featureContext.lineTo(feature.x, feature.height / 2);
}

featureContext.closePath();
featureContext.fill();
featureContext.stroke();
} else if (feature.type === 'stalk') {
featureContext.fillStyle = feature.color;
featureContext.strokeStyle = '#000000';

for (var i = 0; i < 2; i++) {
featureContext.beginPath();

featureContext.moveTo(feature.x, 0);
featureContext.lineTo(feature.x + feature.width * 0.25, feature.height * 0.25 + 0.5);
featureContext.lineTo(feature.x + feature.width * 0.75, feature.height * 0.25 + 0.5);
featureContext.lineTo(feature.x + feature.width, 0);

featureContext[i ? 'moveTo' : 'lineTo'](feature.x + feature.width, feature.height);
featureContext.lineTo(feature.x + feature.width * 0.75, feature.height * 0.75 - 0.5);
featureContext.lineTo(feature.x + feature.width * 0.25, feature.height * 0.75 - 0.5);
featureContext.lineTo(feature.x, feature.height);

featureContext[i ? 'stroke' : 'fill']();
};
} else {
this.base(feature, featureContext, labelContext, scale);

featureContext.strokeStyle = '#000000';

featureContext.beginPath();

if (feature.start === 1) {
featureContext.clearRect(0, 0, 5, this.prop('height'));

featureContext.fillStyle = feature.color;
featureContext.moveTo(5, 0.5);
featureContext.lineTo(feature.x + feature.width, 0.5);
featureContext.moveTo(5, feature.height + 0.5);
featureContext.lineTo(feature.x + feature.width, feature.height + 0.5);
featureContext.moveTo(5, 0.5);
featureContext.bezierCurveTo(-1, 0.5, -1, feature.height + 0.5, 5, feature.height + 0.5);
featureContext.fill();
} else if (feature.end === this.browser.chromosomeSize) {
featureContext.clearRect(feature.x + feature.width - 5, 0, 10, this.prop('height'));

featureContext.fillStyle = feature.color;
featureContext.moveTo(feature.x, 0.5);
featureContext.lineTo(feature.x + feature.width - 5, 0.5);
featureContext.moveTo(feature.x, feature.height + 0.5);
featureContext.lineTo(feature.x + feature.width - 5, feature.height + 0.5);
featureContext.moveTo(feature.x + feature.width - 5, 0.5);
featureContext.bezierCurveTo(this.width + 1, 0.5, this.width + 1, feature.height + 0.5, feature.x + feature.width - 5, feature.height + 0.5);
featureContext.fill();
} else {
featureContext.moveTo(feature.x, 0.5);
featureContext.lineTo(feature.x + feature.width, 0.5);
featureContext.moveTo(feature.x, feature.height + 0.5);
featureContext.lineTo(feature.x + feature.width, feature.height + 0.5);
}

featureContext.stroke();
}
},

populateMenu: function (feature) {
return {
title : feature.id,
Position : this.browser.chr + ':' + feature.start + '-' + feature.end
};
}
});

0 comments on commit 07b1a74

Please sign in to comment.