private void updateClickAction() { String clickAction = getConfig().getParameter(CONFIG_ONCLICK_ACTION); if (clickAction == null) return; if ("none".equals(clickAction)) { geneCanvas.setLocusClickHandler(null); } else if ("link".equals(clickAction)) { geneCanvas.setLocusClickHandler( new LocusClickHandler() { public void onClick(int x, int y, GenomeRange locus) { String url = getConfig().getParameter(CONFIG_ONCLICK_URL); url = resolveURL(url, locus); Window.open(url, "locus", ""); } }); } else if ("info".equals(clickAction)) { geneCanvas.setLocusClickHandler( new LocusClickHandler() { public void onClick(int x, int y, GenomeRange locus) { geneCanvas.displayInfo(x, y, locus); } }); } else if ("set".equals(clickAction)) { geneCanvas.setLocusClickHandler( new LocusClickHandler() { public void onClick(int clientX, int clientY, GenomeRange locus) { String key = getConfig().getParameter(CONFIG_ONCLICK_P_KEY); if (key == null) return; // parse name:%q,chr:%chr String[] actions = key.split(","); if (actions == null) return; Properties prop = new Properties(); for (String each : actions) { String[] keyAndValue = each.split(":"); if (keyAndValue == null || keyAndValue.length != 2) continue; String value = resolveURL(keyAndValue[1].trim(), locus); if (value == null) return; prop.put(keyAndValue[0].trim(), value); } getTrackGroup().getPropertyWriter().setProperty(prop); } }); } }
@Override public void setUp(TrackFrame trackFrame, TrackGroup group) { geneCanvas.setTrackGroup(group); update(group.getTrackWindow(), true); TrackConfig config = getConfig(); config.addConfig("DB Path", new StringType(CONFIG_PATH), ""); config.addConfig("WIG DB Path", new StringType(CONFIG_WIG_PATH), ""); ValueDomain windowFuncitionTypes = ValueDomain.createNewValueDomain(new String[] {"MAX", "MIN", "MEDIAN", "AVG"}); config.addConfig( "Window Function", new StringType(CONFIG_GRAPH_WINDOW, windowFuncitionTypes), "MEDIAN"); config.addHiddenConfig(CONFIG_DB_TYPE, "AUTO"); style.setup(config); ValueDomain actionTypes = ValueDomain.createNewValueDomain(new String[] {"none", "link", "info", "set"}); config.addConfig("On Click Action", new StringType(CONFIG_ONCLICK_ACTION, actionTypes), "none"); config.addConfig( "On Click URL", new StringType(CONFIG_ONCLICK_URL), "http://www.google.com/search?q=%q"); config.addConfig( "On Click Set (key:value, ...)", new StringType(CONFIG_ONCLICK_P_KEY), "read:%q"); config.addConfig("Genome DB Path", new StringType(CONFIG_GENOME_DB_PATH), ""); updateClickAction(); }
@Override public void onChangeTrackGroupProperty(TrackGroupPropertyChange change) { if (change.containsOneOf( new String[] {UTGBProperty.SPECIES, UTGBProperty.REVISION, UTGBProperty.TARGET})) { geneCanvas.clear(); update(change.getTrackWindow(), false); } }
protected void update(TrackWindow newWindow, boolean forceReload) { current = newWindow; if (!forceReload && geneCanvas.hasCacheCovering(newWindow)) { if (!needUpdateForGraphicRefinement) { geneCanvas.setTrackWindow(newWindow, false); refresh(); return; } } geneCanvas.setTrackWindow(newWindow, true); // retrieve gene data from the API TrackWindow prefetchWindow = geneCanvas.getPrefetchWindow(); String chr = getTrackGroupProperty(UTGBProperty.TARGET); ReadQueryConfig queryConfig = new ReadQueryConfig( prefetchWindow.getPixelWidth(), BrowserInfo.isCanvasSupported(), Layout.valueOf(Layout.class, style.layout.toUpperCase()), style.numReadsMax, getWIGPath()); queryConfig.window = GraphWindow.valueOf( GraphWindow.class, getConfig().getString(CONFIG_GRAPH_WINDOW, "MEDIAN")); getFrame().setNowLoading(); getBrowserService() .getOnGenomeData( getGenomeDB(), new ChrLoc(chr, prefetchWindow.getStartOnGenome(), prefetchWindow.getEndOnGenome()), queryConfig, new AsyncCallback<List<GenomeRange>>() { public void onFailure(Throwable e) { GWT.log("failed to retrieve gene data", e); UTGBEntryPointBase.showErrorMessage( "read data retrieval failed: " + e.getMessage()); needUpdateForGraphicRefinement = true; getFrame().loadingDone(); } public void onSuccess(List<GenomeRange> dataSet) { if ("pileup".equals(style.layout) && dataSet.size() > 0 && DataChecker.isReadCoverage(dataSet.get(0))) { needUpdateForGraphicRefinement = true; // narrow down the prefetch range float prefetchFactor = geneCanvas.getPrefetchFactor(); prefetchFactor /= 2.0; geneCanvas.setPrefetchFactor(prefetchFactor); } else { float newPrefetchFactor = geneCanvas.getPrefetchFactor() * 2.0f; if (newPrefetchFactor > 1.0f) newPrefetchFactor = 1.0f; // broaden the prefetch range upon successful read data retrieval geneCanvas.setPrefetchFactor(newPrefetchFactor); needUpdateForGraphicRefinement = false; } geneCanvas.resetData(dataSet); refresh(); } }); }