Skip to content

Commit a5867c9

Browse files
committed
nt scale for selection box
1 parent 111e877 commit a5867c9

File tree

2 files changed

+11
-70
lines changed

2 files changed

+11
-70
lines changed

anvio/data/interactive/css/genomeview.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ g.scale rect.background{
4848
pointer-events: all;
4949
}
5050

51-
.brush .extent {
52-
stroke: black;
53-
fill-opacity: .125;
54-
shape-rendering: crispEdges;
55-
}
56-
57-
rect.background {
58-
fill: rgba(0,0,0,0.1);
59-
visibility: visible !important;
60-
pointer-events: all;
61-
}
62-
6351
#tooltip-body{
6452
height: 300px;
6553
width: 300px;

anvio/data/interactive/js/genomeview.js

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
// Settings vars
2929
// TODO migrate below variables to kvp in state
30-
var stateData = {};
31-
var calculatedSpacing; // like spacing, but calculated ;)
30+
var state = {};
3231
var spacing = 30; // vertical spacing between genomes
3332
var showLabels = true; // show genome labels?
3433
var genomeLabelSize = 15; // font size of genome labels
@@ -39,7 +38,7 @@
3938
var showScale = true; // show nt scale?
4039
var scaleInterval = 100; // nt scale intervals
4140
var scaleFactor = 1; // widths of all objects are scaled by this value to zoom in/out
42-
41+
4342
var alignToGC = null;
4443

4544
var arrowStyle = 1; // gene arrow cosmetics. 1 (default) = 'inspect-page', 2 = thicker arrows, 3 = pentagon
@@ -54,7 +53,7 @@ var genomeData;
5453
$(document).ready(function() {
5554
initData();
5655
// loadState();
57-
processState('default', stateData) // lifted here until loadState is hooked in from backend
56+
processState('default', {}) // lifted here until loadState is hooked in from backend
5857
loadAll();
5958
});
6059

@@ -148,26 +147,6 @@ function processState(stateName, stateData){
148147
'ordering' : 'beaks to tails'
149148
}
150149
]
151-
stateData['additional-data-layers'] = []
152-
153-
calculateMaxGenomeLength()
154-
155-
for(let i = 0; i < genomeData.genomes.length; i++){ // generate mock additional data layer content
156-
let gcContent = []
157-
let coverage = []
158-
159-
for(let j = 0; j < genomeMax; j++){
160-
gcContent.push(Math.floor(Math.random() * 25))
161-
coverage.push(Math.floor(Math.random() * 25))
162-
}
163-
let genomeLabel = Object.keys(genomeData.genomes[i][1]['contigs']['info'])[0];
164-
let additionalDataObject = {
165-
'genome' : genomeLabel,
166-
'coverage' : coverage,
167-
'gcContent' : gcContent
168-
}
169-
stateData['additional-data-layers'].push(additionalDataObject)
170-
}
171150

172151
if(stateData['genome-order-method']){
173152
stateData['genome-order-method'].forEach(orderMethod => {
@@ -189,8 +168,11 @@ function loadAll() {
189168
canvas.setWidth(VIEWER_WIDTH * 0.85);
190169

191170
// Find max length genome
192-
calculateMaxGenomeLength()
193-
calculatedSpacing = calculateSpacingForGroups()
171+
for(genome of genomeData.genomes) {
172+
genome = genome[1].genes.gene_calls;
173+
let genomeEnd = genome[Object.keys(genome).length-1].stop;
174+
if(genomeEnd > genomeMax) genomeMax = genomeEnd;
175+
}
194176

195177
var scaleWidth = canvas.getWidth();
196178
var scaleHeight = 200;
@@ -211,12 +193,13 @@ function loadAll() {
211193
.x(xScale)
212194
.on("brushend", onBrush);
213195

214-
$("#scaleSvg").attr("width", scaleWidth);
196+
$("#scaleSvg").attr("width", scaleWidth + 10);
215197

216198
var scaleBox = d3.select("#scaleSvg").append("g")
217199
.attr("id", "scaleBox")
218200
.attr("class","scale")
219-
.attr("y", 230); // rather than 80 from 50?
201+
.attr("y", 230) // rather than 80 from 50?
202+
.attr("transform", "translate(5,0)");
220203

221204
scaleBox.append("g")
222205
.attr("class", "x axis top noselect")
@@ -234,7 +217,6 @@ function loadAll() {
234217
$('#brush_end').val(Math.floor(scaleWidth));
235218

236219
function onBrush(){
237-
console.log("onBrush() called!");
238220
var b = brush.empty() ? xScale.domain() : brush.extent();
239221

240222
if (brush.empty()) {
@@ -461,7 +443,6 @@ function draw(scaleX=scaleFactor) {
461443
for(genome of genomeData.genomes) {
462444
let label = genome[1].genes.gene_calls[0].contig;
463445
addGenome(label, genome[1].genes.gene_calls, genome[0], y, scaleX=scaleX)
464-
addLayers(label, genome[1], genome[0])
465446
labelSpacing += 30
466447
y++;
467448
}
@@ -701,17 +682,6 @@ function addGenome(label, gene_list, genomeID, y, scaleX=1) {
701682
//geneGroup.destroy();
702683
}
703684

704-
function addLayers(label, genome, genomeID){ // this will work alongside addGenome to render out any additional data layers associated with each group (genome)
705-
706-
let additionalDataLayers = stateData['additional-data-layers'].find(group => group.genome = label)
707-
if(additionalDataLayers['coverage']){
708-
// process for rendering coverage
709-
}
710-
if(additionalDataLayers['gcContent']){
711-
//process for rendering GC content
712-
}
713-
}
714-
715685
function geneArrow(gene, geneID, functions, y, genomeID, style, scaleX=1) {
716686
var cag = null;
717687
var color = 'gray';
@@ -855,23 +825,6 @@ function changeGenomeOrder(updatedOrder){
855825
draw()
856826
}
857827

858-
function calculateMaxGenomeLength(){
859-
for(genome of genomeData.genomes) {
860-
genome = genome[1].genes.gene_calls;
861-
let genomeEnd = genome[Object.keys(genome).length-1].stop;
862-
if(genomeEnd > genomeMax) genomeMax = genomeEnd;
863-
}
864-
}
865-
866-
function calculateSpacingForGroups(){ // to be used for setting vertical spacing
867-
let maxGroupSize = 1; // default, as each group will always have at minimum a 'genome' layer
868-
stateData['additional-data-layers'].map(group => {
869-
Object.keys(group).length > maxGroupSize ? maxGroupSize = Object.keys(group).length : null
870-
})
871-
let spacing = 500 / [maxGroupSize * genomeData.genomes.length] // 500 is hardcoded main canvas height
872-
return spacing
873-
}
874-
875828
var fixHelperModified = function(e, tr) { // ripped from utils.js instead of importing the whole file
876829
var $originals = tr.children();
877830
var $helper = tr.clone();

0 commit comments

Comments
 (0)