Example #1
0
  public void wirteChainsIntoAGffFile(
      ArrayList<Double> PDScores, String blockId, String pathToChainsDir, double scoreThreshold)
      throws IOException {
    String blockSpecfications[] = blockId.split("_");
    String Chr = blockSpecfications[0];
    String gffoutputFileName = pathToChainsDir + "/" + blockId + ".gff";
    PrintWriter pw = new PrintWriter(new FileWriter(gffoutputFileName));
    final GFFWriter gffw = new GFFWriter(pw);
    int numberOfPDScores = PDScores.size();
    int oneStart = 0;
    int oneEnd = 0;
    int dummyPos = 0;

    for (int i = 0; i < numberOfPDScores - 1; i++) {
      double thisScore = PDScores.get(i);
      double nextScore = PDScores.get(i + 1);
      if (PDScores.get(0) >= scoreThreshold) {
        thisScore = thisScore - 0.001;
      }
      if (thisScore < scoreThreshold && nextScore >= scoreThreshold) {
        oneStart = i + 1;
        dummyPos = i + 1;
        double sum = 0;
        while (PDScores.get(dummyPos) >= scoreThreshold && dummyPos < numberOfPDScores - 1) {
          sum = sum + PDScores.get(dummyPos + 1);
          dummyPos++;
        } /*while*/
        // System.out.println("                      start = " + oneStart + " end = " + dummyPos);
        oneEnd = dummyPos;
        int oneChainLength = oneEnd - oneStart;
        SimpleGFFRecord oneRecord = new SimpleGFFRecord();
        oneRecord.setStart(oneStart + 1);
        oneRecord.setEnd(oneEnd);
        oneRecord.setSeqName(Chr);
        oneRecord.setScore(sum / oneChainLength); // oneRecord.setScore(sum/oneChainLength+1);
        oneRecord.setSource("composure");
        oneRecord.setFeature("chainFromPD");

        int minChainLength = getMinPeakLengths();
        if (oneChainLength > 5) {
          // System.out.println(Chr + "\t" + oneStart + "\t" + oneEnd + "\t" +  oneChainLength);
          gffw.recordLine(oneRecord);
        }
        i = oneEnd - 1;
      } /*if*/
    } /*for*/

    pw.flush();
  } /*wirteChainsIntoAGffFile*/