コード例 #1
0
ファイル: DiffEngine.java プロジェクト: raj76/gatk
  protected void printSummaryReport(List<Difference> sortedSummaries, SummaryReportParams params) {
    List<Difference> toShow = new ArrayList<Difference>();
    int count = 0, count1 = 0;
    for (Difference diff : sortedSummaries) {
      if (diff.getCount() < params.minSumDiffToShow)
        // in order, so break as soon as the count is too low
        break;

      if (params.maxItemsToDisplay != 0 && count++ > params.maxItemsToDisplay) break;

      if (diff.getCount() == 1) {
        count1++;
        if (params.maxCountOneItems != 0 && count1 > params.maxCountOneItems) break;
      }

      toShow.add(diff);
    }

    // if we want it in descending order, reverse the list
    if (!params.descending) {
      Collections.reverse(toShow);
    }

    // now that we have a specific list of values we want to show, display them
    GATKReport report = new GATKReport();
    final String tableName = "differences";
    report.addTable(
        tableName,
        "Summarized differences between the master and test files. See http://www.broadinstitute.org/gsa/wiki/index.php/DiffEngine for more information",
        false);
    GATKReportTable table = report.getTable(tableName);
    table.addPrimaryKey("Difference", true);
    table.addColumn("NumberOfOccurrences", 0);
    table.addColumn("ExampleDifference", 0);
    for (Difference diff : toShow) {
      table.set(diff.getPath(), "NumberOfOccurrences", diff.getCount());
      table.set(diff.getPath(), "ExampleDifference", diff.valueDiffString());
    }
    GATKReport output = new GATKReport(table);
    output.print(params.out);
  }
コード例 #2
0
  /**
   * Output the finalized report
   *
   * @param result an integer that doesn't get used for anything
   */
  public void onTraversalDone(Integer result) {
    logger.info("Finalizing variant report");

    for (StateKey stateKey : evaluationContexts.keySet()) {
      NewEvaluationContext nec = evaluationContexts.get(stateKey);

      for (VariantEvaluator ve : nec.getEvaluationClassList().values()) {
        ve.finalizeEvaluation();

        AnalysisModuleScanner scanner = new AnalysisModuleScanner(ve);
        Map<Field, DataPoint> datamap = scanner.getData();

        for (Field field : datamap.keySet()) {
          try {
            field.setAccessible(true);

            if (field.get(ve) instanceof TableType) {
              TableType t = (TableType) field.get(ve);

              String subTableName = ve.getClass().getSimpleName() + "." + field.getName();
              final DataPoint dataPointAnn = datamap.get(field);

              GATKReportTable table;
              if (!report.hasTable(subTableName)) {
                report.addTable(subTableName, dataPointAnn.description());
                table = report.getTable(subTableName);

                table.addPrimaryKey("entry", false);
                table.addColumn(subTableName, subTableName);

                for (VariantStratifier vs : stratificationObjects) {
                  table.addColumn(vs.getName(), "unknown");
                }

                table.addColumn("row", "unknown");

                for (Object o : t.getColumnKeys()) {
                  String c;

                  if (o instanceof String) {
                    c = (String) o;
                  } else {
                    c = o.toString();
                  }

                  table.addColumn(c, 0.0);
                }
              } else {
                table = report.getTable(subTableName);
              }

              for (int row = 0; row < t.getRowKeys().length; row++) {
                String r = (String) t.getRowKeys()[row];

                for (VariantStratifier vs : stratificationObjects) {
                  final String columnName = vs.getName();
                  table.set(stateKey.toString() + r, columnName, stateKey.get(columnName));
                }

                for (int col = 0; col < t.getColumnKeys().length; col++) {
                  String c;
                  if (t.getColumnKeys()[col] instanceof String) {
                    c = (String) t.getColumnKeys()[col];
                  } else {
                    c = t.getColumnKeys()[col].toString();
                  }

                  String newStateKey = stateKey.toString() + r;
                  table.set(newStateKey, c, t.getCell(row, col));

                  table.set(newStateKey, "row", r);
                }
              }
            } else {
              GATKReportTable table = report.getTable(ve.getClass().getSimpleName());

              for (VariantStratifier vs : stratificationObjects) {
                String columnName = vs.getName();

                table.set(stateKey.toString(), columnName, stateKey.get(vs.getName()));
              }

              table.set(stateKey.toString(), field.getName(), field.get(ve));
            }
          } catch (IllegalAccessException e) {
            throw new StingException("IllegalAccessException: " + e);
          }
        }
      }
    }

    report.print(out);
  }