Example #1
0
  public synchronized void addProfile(Profile p) {
    if (p.isStranded()) {
      stranded = true;
    }
    if (p.length() != params.getNumBins()) {
      throw new IllegalArgumentException(
          String.format(
              "Profile length %d doesn't" + " match bin-length %d",
              p.length(), params.getNumBins()));
    }

    if (isNormalized()) {
      throw new IllegalArgumentException("Can't add profile to a normalized MetaProfile");
    }

    if (profiles.contains(p)) {
      /*throw new IllegalArgumentException(String.format(
      "Can't add same profile %s to MetaProfile",
      p.getName()));*/
    } else {

      profiles.add(p);
      p.addProfileListener(this);
      for (int i = 0; i < values.length; i++) {
        values[i] += p.value(i);
        max = Math.max(max, values[i]);
        min = Math.min(min, values[i]);
      }

      dispatchChange(new ProfileEvent(this, p));
    }
  }
Example #2
0
  protected void recalculate() {
    max = min = 0.0;
    for (int i = 0; i < values.length; i++) {
      values[i] = 0.0;
    }

    for (Profile p : profiles) {
      for (int i = 0; i < values.length; i++) {
        values[i] += p.value(i);
      }
    }

    if (isNormalized()) {
      for (int i = 0; i < values.length; i++) {
        values[i] /= normalization;
        max = Math.max(max, values[i]);
        min = Math.min(min, values[i]);
      }
    }
  }