Ejemplo n.º 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));
    }
  }
Ejemplo n.º 2
0
 public MetaProfile(String n, BinningParameters bps) {
   name = n;
   params = bps;
   values = new double[params.getNumBins()];
   max = min = 0.0;
   profiles = new Vector<Profile>();
   normalization = null;
 }
Ejemplo n.º 3
0
  public void saveToFile(String fileName) {
    if (profiles.size() > 0) {
      try {
        FileWriter fout = new FileWriter(fileName);
        int start = (-1 * (params.getWindowSize() / 2)) + params.getBinSize() / 2;
        int step = params.getWindowSize() / params.getNumBins();

        fout.write(name + "\n");
        int k = start;
        for (int i = 0; i < values.length; i++) {
          fout.write(k + "\t" + values[i] + "\n");
          k += step;
        }
        fout.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      System.err.println("Empty MetaProfile: nothing to write to file");
    }
  }