コード例 #1
0
ファイル: MetaProfile.java プロジェクト: gifford-lab/GEM
  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));
    }
  }
コード例 #2
0
ファイル: MetaProfile.java プロジェクト: gifford-lab/GEM
 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;
 }
コード例 #3
0
ファイル: MetaProfile.java プロジェクト: gifford-lab/GEM
  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");
    }
  }