Beispiel #1
0
  @Override
  public void draw() {
    String path = getConfig().getString(CONFIG_GENOME_DB_PATH, "");
    String trackBaseURL = "utgb-core/Sequence.txt?path=" + path + "&%q";

    String newURL = getTrackURL(trackBaseURL);
    // replace track group properties
    TrackWindow w = getTrackWindow();
    final int startSeq = w.getStartOnGenome();

    final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, newURL);

    try {
      rb.sendRequest(
          null,
          new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {
              String strSeqarr = response.getText();
              geneCanvas.setSequencetxt(strSeqarr);
              geneCanvas.setStartSeq(startSeq);

              char[] chrSeqarr = strSeqarr.toCharArray();
              if (!chrSeqarr.equals(null)) {
                geneCanvas.setSequencetxt(chrSeqarr);
                geneCanvas.setReadStyle(style);

                geneCanvas.draw();
                getFrame().loadingDone();
              }
            }

            public void onError(Request request, Throwable exception) {
              // NOTE: we should output an error message to user
            }
          });
    } catch (Exception e) {
      //
    }
  }
Beispiel #2
0
  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();
              }
            });
  }