Support for sorting the diff output in reverse order.

This commit is contained in:
Mark DePristo 2011-07-18 15:43:01 -04:00
parent 45702d3084
commit 782a05e9b5
2 changed files with 27 additions and 12 deletions

View File

@ -143,7 +143,7 @@ public class DiffEngine {
* Not that only pairs of the same length are considered as potentially equivalent
*
* @param params determines how we display the items
* @param diffs
* @param diffs the list of differences to summarize
*/
public void reportSummarizedDifferences(List<Difference> diffs, SummaryReportParams params ) {
printSummaryReport(summarizeDifferences(diffs), params );
@ -207,14 +207,7 @@ public class DiffEngine {
}
protected void printSummaryReport(List<Difference> sortedSummaries, SummaryReportParams params ) {
GATKReport report = new GATKReport();
final String tableName = "diffences";
report.addTable(tableName, "Summarized differences between the master and test files.\nSee http://www.broadinstitute.org/gsa/wiki/index.php/DiffEngine for more information");
GATKReportTable table = report.getTable(tableName);
table.addPrimaryKey("Difference", true);
table.addColumn("NumberOfOccurrences", 0);
table.addColumn("SpecificDifference", 0);
List<Difference> toShow = new ArrayList<Difference>();
int count = 0, count1 = 0;
for ( Difference diff : sortedSummaries ) {
if ( diff.getCount() < params.minSumDiffToShow )
@ -230,10 +223,26 @@ public class DiffEngine {
break;
}
table.set(diff.getPath(), "NumberOfOccurrences", diff.getCount());
table.set(diff.getPath(), "SpecificDifference", diff.valueDiffString());
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 = "diffences";
report.addTable(tableName, "Summarized differences between the master and test files.\nSee 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());
}
table.write(params.out);
}
@ -252,7 +261,7 @@ public class DiffEngine {
* commonPostfixLength: how many parts are shared at the end, suppose its 2
* We want to create a string *.*.C.D
*
* @param parts
* @param parts the separated path values [above without .]
* @param commonPostfixLength
* @return
*/
@ -351,6 +360,7 @@ public class DiffEngine {
int maxItemsToDisplay = 0;
int maxCountOneItems = 0;
int minSumDiffToShow = 0;
boolean descending = true;
public SummaryReportParams(PrintStream out, int maxItemsToDisplay, int maxCountOneItems, int minSumDiffToShow) {
this.out = out;
@ -358,5 +368,9 @@ public class DiffEngine {
this.maxCountOneItems = maxCountOneItems;
this.minSumDiffToShow = minSumDiffToShow;
}
public void setDescending(boolean descending) {
this.descending = descending;
}
}
}

View File

@ -112,6 +112,7 @@ public class DiffObjectsWalker extends RodWalker<Integer, Integer> {
}
DiffEngine.SummaryReportParams params = new DiffEngine.SummaryReportParams(out, MAX_DIFFS, MAX_COUNT1_DIFFS, minCountForDiff);
params.setDescending(false);
diffEngine.reportSummarizedDifferences(diffs, params);
}
}