Exemplo n.º 1
0
  /**
   * This uses a fixed window size and is much faster
   *
   * @param cpg Must be streamed in serially.
   */
  protected void streamCpgFixedWind(Cpg[] cpg) {
    int newPos = cpg[0].chromPos;
    Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).fine(String.format("Found Cpg: %d\n", newPos));

    // Add this Cpg to the head of the queue
    window.add(cpg);
    if (useSummarizers) {
      for (int t = 0; t < this.numTables(); t++) {
        methSummarizer.get(t).streamCpg(cpg[t]);
        methSummarizerFw.get(t).streamCpg(cpg[t]);
        methSummarizerRev.get(t).streamCpg(cpg[t]);
      }
    }

    // Remove cpgs from the tail
    boolean done = false;
    Cpg[] endCpg, secondCpg;
    //		while (!done && ((endCpg = window.peek()) != null))
    //		{
    //			if ((newPos - endCpg[0].chromPos) < this.walkParams.maxScanningWindSize)
    //			{
    //				done = true;
    //			}
    while (!done && (window.size() > 1)) {
      endCpg = window.get(0);
      secondCpg = window.get(1);
      if ((newPos - secondCpg[0].chromPos) < this.walkParams.minScanningWindSize) {
        done = true;
      } else {
        window.remove();
        if (useSummarizers) {
          for (int t = 0; t < this.numTables(); t++) {
            methSummarizer.get(t).removeCpg(endCpg[t]);
            methSummarizerFw.get(t).removeCpg(endCpg[t]);
            methSummarizerRev.get(t).removeCpg(endCpg[t]);
          }
        }
      }
    }

    //		System.err.printf("\tFixed wind checking %s (id=%d)\n",this.windStr(),this.hashCode());

    // And process the window
    if ((window.size() >= walkParams.minScanningWindCpgs)
        && ((CpgWalker.windEnd(window, false) - CpgWalker.windStart(window, false))
            >= walkParams.minScanningWindSize)) {
      //			System.err.println("\t\t Sufficient Cpgs: " + window.size());
      //			double mean = this.methSummarizer.getValMean(true);
      //			System.err.println("\t\t Mean meth=" + mean);
      //			if (mean < 0.7)
      //			System.out.println(MethylDbUtils.bedLine("chr11", windStart(), windEnd(), ".", mean));
      this.processWindow(this.window, true);
    } else {
      //			System.err.println("\t\t Not enough Cpgs");
    }
  }