Genome browser for phamerator.org
forked from scresawn's block: genome browser
forked from BDAguila's block: genome browser
forked from ericamartel's block: genome browser
forked from anonymous's block: genome browser
forked from BrandonStroud's block: genome browser
forked from anonymous's block: genome browser
forked from BrandonStroud's block: genome browser
forked from ericamartel's block: genome browser
forked from ericamartel's block: genome browser
xxxxxxxxxx
-
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://d3js.org/d3.v2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
<script src="jquery-1.11.2.js"></script>
<style>query
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 12px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
}
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
.d3-tip.n:after {
margin: -1px 0 0 0;
top: 100%;
left: 0;
}
<script data-require="d3@3.5.3" data-semver="3.5.3" src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.js"></script>
<script type="text/javascript" src="https://d3js.org/d3.v2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
path.link {
fill: none;
stroke: #666;
stroke-width: 1.5px;
}
path.link.licensing {
stroke: green;
}
path.link.resolved {
stroke-dasharray: 0,2 1;
}
marker#licensing {
fill: green;
}
marker#suit,
marker#resolved {
fill: black;
}
text {
font: 10px sans-serif;
pointer-events: none;
}
text.shadow {
stroke: #fff;
stroke-width: 3px;
stroke-opacity: .8;
}
body,
.container {
background-color: white;
margin: 0px;
}
.graphContainer {
text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;
}
#sidebar{
position: absolute;
z-index: 2;
background-color: #FFF;
padding: 10px;
margin: 5px;
border: 1px solid #6895b4;
min-height: 3px;
min-width: 8px;
}
.item-group {
margin-bottom: 5px;
}
.item-group .item-label {
width: 90px;
text-align: right;
font-family: Arial,sans-serif;
font-size: 14px;
font-weight: bold;
position: relative;
min-height: 1px;
margin-top: 5px;
display: inline;
padding-right: 5px;
font-size: .90em;
}
.checkbox-interaction-group {
margin-left: 10px;
margin-top: 5px;
clear: both;
}
.checkbox-container {
display: block;
min-height: 22px;
vertical-align: middle;
margin-left: 10px;
}
.checkbox-container label{
display:inline;
margin-bottom: 0px;
}
</style>
</head>
<body class="container">
<div id="sidebar" style="display: ">
<div class="item-group">
<label class="item-label">Pham Filter</label>
<div id="filterContainer" class="filterContainer checkbox-interaction-group"> </div>
</div>
</div>
<input type="checkbox" class="pham" id="filled-in-box" checked="checked" />
<label for="filled-in-box">Phamily 1</label>
</html>
<body>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<script>
var svg = d3.select("body").append("svg").attr("height", 1000);
d3.json("genes.json.txt", function(error, json) {
if (error) return console.warn(error);
svg.attr("width", function (d) {
return d3.max(json, function(d) {
return d.genomelength/10;
})
});
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return d.sequence;
})
svg.call(tip);
var phage = svg.selectAll(".genomes")
.data(json)
.enter()
.append("g");
phage.attr("transform", function(d, i) { return "translate(0," + (100 + (i*225)) + ")"; });
phage.append("rect")
.attr({x: 0, y: 0, width: function(d) { return d.genomelength/10; }, height: 30})
.style({"stroke-width": "2px", "fill": "white", "stroke": "black"})
.attr("stroke-opacity", 0)
.transition().duration(1000)
.attr("stroke-opacity", 1);
var group = phage.selectAll(".thousandticks")
.data(function (d) {
ticks = [];
genome_positions = d3.range(d.genomelength);
genome_positions.forEach(function (currentValue, index, myArray) {
if (currentValue % 1000 === 0) {
ticks.push(currentValue);
}
});
return ticks;
}
)
.enter()
.append("g");
group.append("rect")
.style({"fill": "black"})
.attr({x: function (d) { return d/10; }, y: 0, width: "1px", height: 30})
.attr({"fill-opacity": 0})
.transition().duration(1500)
.attr({"fill-opacity": 1});
group.append("text") // kbp label
.attr("x", function(d) {return (d/10) + 3;})
.attr("y", 12)
.attr("font-family", "sans-serif")
.attr("font-size", "14px")
.attr("fill", "green")
.style("text-anchor", "start")
.text(function(d) { return d/1000; })
.attr({"fill-opacity": 0})
.transition().duration(1500)
.attr({"fill-opacity": 1});
var group2 = phage.selectAll(".fivehundredticks")
.data(function (d) {
ticks = [];
genome_positions = d3.range(d.genomelength);
genome_positions.forEach(function (currentValue, index, myArray) {
if (currentValue % 500 === 0 & currentValue % 1000 !== 0) {
ticks.push(currentValue);
}
})
return ticks;
})
.enter()
.append("g");
group2.append("rect")
.style({"fill": "black"})
.attr({x: function(d) {return d/10;}, y: 0, width: "1px", height: 15})
.attr({"fill-opacity": 0})
.transition().duration(1500)
.attr({"fill-opacity": 1});
var group3 = phage.selectAll(".onehundredticks")
.data(function (d) {
ticks = [];
genome_positions = d3.range(d.genomelength);
genome_positions.forEach(function (currentValue, index, myArray) {
if (currentValue % 100 === 0 & currentValue % 1000 !== 0 & currentValue % 500 !== 0) {
ticks.push(currentValue);
}
})
return ticks;
})
.enter()
.append("g");
group3.append("rect")
.style({"fill": "black"})
.attr({x: function (d) { return d/10; }, y: 15, width: "1px", height: 15})
.attr("fill-opacity", 0)
.transition().duration(1500)
.attr("fill-opacity", 1);
gene = phage.selectAll(".genes")
.data(function(d, i) { console.log(i, d); return d.genes;})
.enter()
.append("g");
function createFilter()
{d3.select(".filledContainer").selectAll("div")
.data(json)
.enter()
.append("div")
.attr("class","checkbox-container")
.append("label")
.each(function(d){
d3.select(this).append("input")
.attr("type","checkbox")
.attr("id", function(d,i){return "chk_" + d.pham })
.attr("checked", true)
.on("click", function (d,i){
var lVisibility = this.checked ? "visible" : "hidden";
filterGraph(d.pham, lVisibility);
})
d3.select(this).append("span")
.text(function(d){return d.pham;});
})
$("#sidebar").show(); }
var phamcheckbox = d3.selectAll("pham")
.attr('class','pham')
.data (json)
.enter()
.append('div')
.text(function(d,i){return d.pham + '';})
//document.getElementsByClassName("pham")
// for (var i = 0; i < json.length; i++)
// {gene.append ("input")}
//loop through checkboxes
//.html("<input id= 'phamily 1' type='checkbox' class='pham'>");
// .attr ("fill", function (d) {
// if (clicked == true) {
// return "red";
// }
// else {
// return "gray";
// }
//input id="Phamily 1" type="checkbox" class="pham" ><label for="Phamily 1">Phamily 1</label>
// .getElementbyClass('pham')
gene.append("rect")
.on('mouseover', tip.show)
.on('mouseout', tip.hide)
.attr("y", function (d) {
if (d.direction == "forward") {
if (d.name % 2 === 0) {
return -70;
}
else { return -30;}
}
else if (d.direction == "reverse") {
if (d.name % 2 === 0) {
return 30;
}
else { return 60;}
}
})
.attr("x", function (d) {
if (d.direction === "forward") {
return (0 - ((d.stop-d.start)/10)) - 2;
}
else if (d.direction === "reverse") {
w = d3.select("svg").style("width");
return w;
}
})
.attr("height", function (d) {return 30;})
.attr("width", function (d) { return (d.stop-d.start)/10; })
.style({"stroke":"black", "stroke-width": "2px"})
.attr("fill", function (d) {
if (d.direction == "forward") {
return "purple";
}
else if (d.direction == "reverse") {
return "blue";
}
else {
return "black";
}
})
.transition().delay(1000).duration(1500)
.attr("x", function (d) { return d.start/10; });
// var fillcolor = document.getElementsByClassName("pham")
//console.log(fillcolor);
//if (pham.clicked == true) {
// d.genes.style.fill ="red";
// }
// else {
// d.genes.style.fill ="gray";
// }
//
gene.append("text")
.attr("x", function(d) { return ((d.start + d.stop)/2)/10;})
.attr("y", function (d) {
if (d.direction == "forward") {
if (d.name % 2 === 0) {
return -50;
}
else { return -10;}
}
else if (d.direction == "reverse") {
if (d.name % 2 === 0) {
return 50;
}
else { return 80;}
}
})
.style({"text-anchor": "middle", "fill": "white"})
.attr("font-family", "sans-serif")
.text(function(d) {return d.name})
.attr("fill-opacity", 0)
.transition().delay(2000).duration(1500)
.attr("fill-opacity", 1);
gene.append("text") // pham name
.attr("x", function(d) { return ((d.start + d.stop)/2)/10;})
.attr("y", function (d) {
if (d.direction == "forward") {
if (d.name % 2 === 0) {
return -80;
}
else { return -40;}
}
else if (d.direction == "reverse") {
if (d.name % 2 === 0) {
return 80;
}
else { return 110;}
}
})
.style({"text-anchor": "middle", "fill": "blue"})
.attr("font-family", "sans-serif")
.text(function(d) {return d.pham})
.attr("fill-opacity", 0)
.transition().delay(3500).duration(1500)
.attr("fill-opacity", 1);
});
</script>
</body>
Modified http://d3js.org/d3.v2.min.js to a secure url
Modified http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js to a secure url
Modified http://d3js.org/d3.v2.min.js to a secure url
https://d3js.org/d3.v2.min.js
https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js
https://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js
https://code.jquery.com/jquery-2.1.1.min.js
https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.js
https://d3js.org/d3.v2.min.js
https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js
https://code.jquery.com/jquery-2.1.1.min.js
https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js