Esempio n. 1
0
  public String toString(
      String tabs, double thresholdEntropy, double thresholdP, int thresholdCount) {
    if (getTotalCount() == 0) return "";

    StringBuilder sb = new StringBuilder();
    double p[] = p();
    for (int idx = 0; idx < 4; idx++) {
      char base = BASES[idx];
      AcgtTree n = nodes[idx];
      if (n != null) {
        sb.append(
            String.format(
                "%s%s%s: %d\te:%4.3f\tp:%4.2f\n",
                tabs, name, base, counts[idx], n.entropy(), p[idx]));

        if (((n.entropy() <= thresholdEntropy) || (p[idx] >= thresholdP)) //
            && (counts[idx] >= thresholdCount) //
        ) {
          Gpr.debug(
              "Name:"
                  + n.name
                  + "\tIdx:"
                  + +idx
                  + "\tEntropy: "
                  + n.entropy()
                  + "\tP:"
                  + p[idx]
                  + "\tCount:"
                  + counts[idx]);
          sb.append(n.toString(tabs + "\t", thresholdEntropy, thresholdP, thresholdCount));
        }
      }
    }

    return sb.toString();
  }
Esempio n. 2
0
  /** Find node names that are within the thresholds */
  public List<String> findNodeNames(
      double thresholdEntropy, double thresholdP, int thresholdCount) {
    ArrayList<String> names = new ArrayList<String>();
    if (getTotalCount() == 0) return names;

    double p[] = p();
    for (int idx = 0; idx < 4; idx++) {
      AcgtTree n = nodes[idx];
      if (n != null) {
        if (((parent == null)
                || (parent.entropy() <= thresholdEntropy)) // Parent's entropy is low enough?
            && (p[idx] >= thresholdP) // Probability is high enough?
            && (counts[idx] >= thresholdCount) // Do we have enough counts?
        ) {
          names.add(n.name);
        }

        names.addAll(n.findNodeNames(thresholdEntropy, thresholdP, thresholdCount));
      }
    }

    return names;
  }