Skip to content

Commit

Permalink
Add newick download to species tree; Remove unwanted text
Browse files Browse the repository at this point in the history
  • Loading branch information
jyothishnt committed Jul 27, 2017
1 parent 7f72f04 commit 95cd208
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion widgets/htdocs/components/95_speciestree.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ div.js_tree div.toolbar_menu div.current { background: url("/i/16/rev/che
div.toolbar_menu div.header { cursor: auto; }
div.tree_menu, div.resize_menu, div.filter_menu { display: none; }
div.js_tree div.resize { background-image: url("/i/16/rev/image_resize.png"); cursor: pointer; float: left; height: 16px; margin: 0 4px 2px; width: 16px; }
div.js_tree div.export { background-image: url("/i/16/rev/picture.png"); cursor: pointer; float: left; height: 16px; margin: 0 4px 2px; width: 16px; }
div.js_tree div.export { background-image: url("/i/16/rev/download.png"); cursor: pointer; float: left; height: 16px; margin: 0 4px 2px; width: 16px; }
div .tnt_tooltip { background-color: #eaeeff; border: 1px solid #eaeeff; box-shadow: 5px 5px 15px #666; font-size: 10px; font-weight: bold; opacity: 0.94; padding: 0px; text-align: left; white-space: normal; width: 210px; position: absolute !important; }
.tnt_zmenu { width: 210px; border-style: none;}
.tnt_zmenu_header { background-color: #667aa6; }
Expand Down
3 changes: 0 additions & 3 deletions widgets/htdocs/info/about/speciestree.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ <h1>Species Tree</h1>
<p>
The species tree is maintained by the <a href="/info/genome/compara/">Compara team</a>
(more information <a href="/info/genome/compara/index.html#species_tree">here</a> on how it is constructed).
Click the icons on the blue image bar below to interact with the tree or download the
<a href="species_tree.pdf" id="speciestree">Static image</a> in PDF.
You can download the data in Newick format from our GitHub repository:
</p>
<ul>
<li>Topology Only: <a href="https://github.com/Ensembl/ensembl-compara/blob/release/[[SPECIESDEFS::ENSEMBL_VERSION]]/scripts/pipeline/species_tree.ensembl.topology.nw">all species</a></li>
Expand Down
21 changes: 15 additions & 6 deletions widgets/htdocs/widgets/95_SpeciesTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,22 @@ Ensembl.SpeciesTree.tnt_theme_tree_simple_species_tree = function(species_detail
pdf.text(0.5, 0.5, tree_label || '');
pdf.save(filename);
}
else {
var download = document.getElementById('download');
else if(exportType == 'PNG') {
var a = document.createElement("a");
a.download = filename;
a.href = imgsrc;
document.body.appendChild(a);
a.click();
$(a).remove();
}
else {
var tree_type = d3.select(".tree_menu").select(".current").attr("class").replace(/current/g,'').replace(/tree_item/g,'').replace(/ /g,'');
var newick = species_details['trees'][tree_type].newick;
var a = document.createElement("a");
a.download = filename;
a.href="data:text/plain,"+encodeURIComponent(newick);
a.click();
}
element && $(element).html(exportType);
element && $(element).removeClass('loading');
};
Expand Down Expand Up @@ -324,13 +331,16 @@ Ensembl.SpeciesTree.tnt_theme_tree_simple_species_tree = function(species_detail
.attr("class", "header")
.text("Choose download type");


$.each(['Newick', 'PNG'], function(i, type) {
export_menu.append("div")
.attr("class", "Export_PNG")
.text('PNG')
.attr("class", "Export_" + type)
.text(type)
.on("click", function(){
var svgElement = $($('.js_tree'));
svgExport(svgElement[0], 'PNG', this);
svgExport(svgElement[0], type, this);
});
});

$.when(_jspdf).done(function() {
export_menu.append("div")
Expand All @@ -342,7 +352,6 @@ Ensembl.SpeciesTree.tnt_theme_tree_simple_species_tree = function(species_detail
});
})


var export_icon = d3.select(".image_toolbar")
.append("div")
.attr("class", "export")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ sub render {

if ($sp->{production_name}) {
my $sp_icon = $species_defs->ENSEMBL_WEBROOT . '/../public-plugins/ensembl/htdocs/i/species/48/' . $sp->{production_name} . '.png';
my $check = file_exists($sp_icon);
if (!$check->{'error'}) {
if (file_exists($sp_icon)) {
my $content = read_file($sp_icon);
if ($content) {
$sp->{icon} = 'data:image/png;base64,'.encode_base64($content);
Expand Down

0 comments on commit 95cd208

Please sign in to comment.