import d3 from 'd3'; import _ from 'underscore'; import Grapher from 'grapher'; import * as Helpers from './visualisation_helpers'; import Utils from './utils'; class Graph { static canCollapse() { return true; } static name() { return 'Graphical overview of aligning hit sequences to the query'; } static className() { return 'alignment-overview'; } static graphId(props) { return 'alignment_'+props.query.number; } static dataName(props) { return 'Alignment-Overview-'+props.query.id; } constructor($svgContainer, props) { this.svg_container = $svgContainer; var $queryDiv = $svgContainer.parents('.resultn'); var hits = this.extractData(props.query.hits, props.query.number); this.graphIt($queryDiv, $svgContainer, 0, 20, null, hits); } extractData(query_hits, number) { var hits = []; query_hits.map(function (hit) { var _hsps = []; var hsps = hit.hsps; _.each(hsps, function (hsp) { var _hsp = {}; _hsp.hspEvalue = hsp.evalue; _hsp.hspStart = hsp.qstart; _hsp.hspEnd = hsp.qend; _hsp.hspFrame = hsp.sframe; _hsp.hspId = 'Query_' + number + '_hit_' + hit.number + '_hsp_' + hsp.number; _hsp.hspIdentity = hsp.identity; _hsp.hspGaps = hsp.gaps; _hsp.hspPositives = hsp.positives; _hsp.hspLength = hsp.length; _hsps.push(_hsp); }); _hsps.hitId = hit.id; _hsps.hitDef = 'Query_'+number+'_hit_'+hit.number; _hsps.hitEvalue = hit.hsps[0].evalue; hits.push(_hsps); }); return hits; } setupTooltip() { this.svg_container.find('[data-toggle="tooltip"]').tooltip({ 'placement': 'top', 'container': 'body', 'html': 'true', 'delay': 0, 'white-space': 'nowrap' }); } setupClick($graphDiv) { $('a', $graphDiv).click(function (evt) { evt.preventDefault(); evt.stopPropagation(); window.location.hash = $(this).attr('href'); }); } graphControls($queryDiv, $graphDiv, isInit, opts, hits) { var MIN_HITS_TO_SHOW = 20; var totalHits, shownHits, lessButton, moreButton; var countHits = function () { totalHits = hits.length; shownHits = $queryDiv.find('.ghit > g').length; }; var setupButtons = function($queryDiv, $graphDiv) { $graphDiv .append( $('