Added functionality of outputting sorted GATKReport Tables
- Added an optional argument to BaseRecalibrator to produce sorted GATKReport Tables - Modified BSQR Integration Tests to include the optional argument. Tests now produce sorted tables
This commit is contained in:
parent
b0cb513793
commit
b491c177ff
|
|
@ -38,7 +38,8 @@ public class BQSRIntegrationTest extends WalkerTest {
|
|||
args +
|
||||
" -knownSites " + (reference.equals(b36KGReference) ? b36dbSNP129 : hg18dbSNP132) +
|
||||
" --allow_potentially_misencoded_quality_scores" + // TODO -- remove me when we get new SOLiD bams
|
||||
" -o %s";
|
||||
" -o %s" +
|
||||
" -sortAllCols";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -52,21 +53,21 @@ public class BQSRIntegrationTest extends WalkerTest {
|
|||
String HiSeqBam = privateTestDir + "HiSeq.1mb.1RG.bam";
|
||||
String HiSeqInterval = "chr1:10,000,000-10,100,000";
|
||||
return new Object[][]{
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, "", "4fd3c9ad97e6ac58cba644a76564c9f7")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --no_standard_covs -cov ContextCovariate", "2620f734cce20f70ce13afd880e46e5c")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --no_standard_covs -cov CycleCovariate", "5eb3b94e767da19a4c037ee132e4b19a")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --indels_context_size 4", "ab261d291b107a3da7897759c0e4fa89")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --low_quality_tail 5", "292303f649fbb19dc05d4a0197a49eeb")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --quantizing_levels 6", "8ced9d1094493f17fb1876b818a64541")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --mismatches_context_size 4", "abb838131e403d39820dbd66932d1ed0")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", "", "f70d8b5358bc2f76696f14b7a807ede0")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "1:10,000,000-10,200,000", "", "4c0f63e06830681560a1e9f9aad9fe98")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.1RG.bam", "1:10,000,000-10,200,000", "", "8f62aa0e75770204c98d8299793cc53c")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "originalQuals.1kg.chr1.1-1K.1RG.bam", "1:1-1,000", " -OQ", "03c29a0c1d21f72b12daf51cec111599")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "1:10,000,000-20,000,000", " --solid_recal_mode REMOVE_REF_BIAS", "7080b2cad02ec6e67ebc766b2dccebf8")},
|
||||
{new BQSRTest(b36KGReference, privateTestDir + "NA19240.chr1.BFAST.SOLID.hasCSNoCall.bam", "1:50,000-80,000", " --solid_nocall_strategy LEAVE_READ_UNRECALIBRATED", "30e76055c16843b6e33e5b9bd8ced57c")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", " -knownSites:anyNameABCD,VCF " + privateTestDir + "vcfexample3.vcf", "f70d8b5358bc2f76696f14b7a807ede0")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", " -knownSites:bed " + validationDataLocation + "bqsrKnownTest.bed", "5e657fd6a44dcdc7674b6e5a2de5dc83")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, "", "2f250fecb930e0dfe0f63fe0fed3960b")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --no_standard_covs -cov ContextCovariate", "26c8d7226139a040557b1d3b1c8792f0")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --no_standard_covs -cov CycleCovariate", "9b43a1839cb6ea03aec1d96f15ca8efb")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --indels_context_size 4", "3159a9d136c45e4a65d46a23dc8fd3b5")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --low_quality_tail 5", "bb7262829effbbdbc8d88dd36f480368")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --quantizing_levels 6", "fbb002fa2b9197c4b555852dccc11562")},
|
||||
{new BQSRTest(hg18Reference, HiSeqBam, HiSeqInterval, " --mismatches_context_size 4", "7392acb71131a60a527ca32715fc59be")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", "", "49d4383896a90795d94138db1410a7df")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "1:10,000,000-10,200,000", "", "427448eff98cf194cc7217c0b1401e79")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.1RG.bam", "1:10,000,000-10,200,000", "", "50cd1a10b6ecb3d09f90f1e4a66da95d")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "originalQuals.1kg.chr1.1-1K.1RG.bam", "1:1-1,000", " -OQ", "1dc71561c9d0fb56f9876cb5043c5376")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "1:10,000,000-20,000,000", " --solid_recal_mode REMOVE_REF_BIAS", "13e8f032e76340b114847c90af0a1f8a")},
|
||||
{new BQSRTest(b36KGReference, privateTestDir + "NA19240.chr1.BFAST.SOLID.hasCSNoCall.bam", "1:50,000-80,000", " --solid_nocall_strategy LEAVE_READ_UNRECALIBRATED", "03f58ae4f9d203034e895a3636fc108f")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", " -knownSites:anyNameABCD,VCF " + privateTestDir + "vcfexample3.vcf", "49d4383896a90795d94138db1410a7df")},
|
||||
{new BQSRTest(b36KGReference, validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.1Mb.1RG.bam", "1:10,000,000-10,200,000", " -knownSites:bed " + validationDataLocation + "bqsrKnownTest.bed", "2db2ef8c2d63e167663d70340182f49a")},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +101,7 @@ public class BQSRIntegrationTest extends WalkerTest {
|
|||
" -knownSites " + b36dbSNP129 +
|
||||
" -L 1:10,000,000-10,200,000" +
|
||||
" -o /dev/null" +
|
||||
" -sortAllCols" +
|
||||
" --plot_pdf_file /dev/null" +
|
||||
" --intermediate_csv_file %s",
|
||||
Arrays.asList("d1c38a3418979400630e2bca1140689c"));
|
||||
|
|
@ -114,7 +116,8 @@ public class BQSRIntegrationTest extends WalkerTest {
|
|||
" -I " + privateTestDir + "NA19240.chr1.BFAST.SOLID.hasCSNoCall.bam" +
|
||||
" -L 1:50,000-80,000" +
|
||||
" --allow_potentially_misencoded_quality_scores" + // TODO -- remove me when we get new SOLiD bams
|
||||
" -o %s",
|
||||
" -o %s" +
|
||||
" -sortAllCols",
|
||||
1, // just one output file
|
||||
UserException.class);
|
||||
executeTest("testBQSRFailWithSolidNoCall", spec);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class GATKReport {
|
|||
* @param numColumns the number of columns in this table
|
||||
*/
|
||||
public void addTable(final String tableName, final String tableDescription, final int numColumns) {
|
||||
addTable(tableName, tableDescription, numColumns, false);
|
||||
addTable(tableName, tableDescription, numColumns, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,9 +127,10 @@ public class GATKReport {
|
|||
* @param tableDescription the description of the table
|
||||
* @param numColumns the number of columns in this table
|
||||
* @param sortByRowID whether to sort the rows by the row ID
|
||||
* @param sortByAllColumns whether to sort the rows by all columns starting from leftmost column
|
||||
*/
|
||||
public void addTable(final String tableName, final String tableDescription, final int numColumns, final boolean sortByRowID) {
|
||||
GATKReportTable table = new GATKReportTable(tableName, tableDescription, numColumns, sortByRowID);
|
||||
public void addTable(final String tableName, final String tableDescription, final int numColumns, final boolean sortByRowID, final boolean sortByAllColumns) {
|
||||
GATKReportTable table = new GATKReportTable(tableName, tableDescription, numColumns, sortByRowID, sortByAllColumns);
|
||||
tables.put(tableName, table);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class GATKReportTable {
|
|||
private final String tableDescription;
|
||||
|
||||
private final boolean sortByRowID;
|
||||
private final boolean sortByAllColumns;
|
||||
|
||||
private List<Object[]> underlyingData;
|
||||
private final List<GATKReportColumn> columnInfo;
|
||||
|
|
@ -108,6 +109,9 @@ public class GATKReportTable {
|
|||
// when reading from a file, we do not re-sort the rows
|
||||
sortByRowID = false;
|
||||
|
||||
// when reading from a file, we do not re-sort the rows
|
||||
sortByAllColumns = false;
|
||||
|
||||
// initialize the data
|
||||
final int nColumns = Integer.parseInt(tableData[TableDataHeaderFields.COLS.index()]);
|
||||
final int nRows = Integer.parseInt(tableData[TableDataHeaderFields.ROWS.index()]);
|
||||
|
|
@ -177,7 +181,7 @@ public class GATKReportTable {
|
|||
* @param numColumns the number of columns in this table
|
||||
*/
|
||||
public GATKReportTable(final String tableName, final String tableDescription, final int numColumns) {
|
||||
this(tableName, tableDescription, numColumns, true);
|
||||
this(tableName, tableDescription, numColumns, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -187,8 +191,9 @@ public class GATKReportTable {
|
|||
* @param tableDescription the description of the table
|
||||
* @param numColumns the number of columns in this table
|
||||
* @param sortByRowID whether to sort rows by the row ID (instead of the order in which they were added)
|
||||
* @param sortByAllColumns whether to sort rows by all columns (instead of the order in which they were added)
|
||||
*/
|
||||
public GATKReportTable(final String tableName, final String tableDescription, final int numColumns, final boolean sortByRowID) {
|
||||
public GATKReportTable(final String tableName, final String tableDescription, final int numColumns, final boolean sortByRowID, final boolean sortByAllColumns) {
|
||||
if ( !isValidName(tableName) ) {
|
||||
throw new ReviewedStingException("Attempted to set a GATKReportTable name of '" + tableName + "'. GATKReportTable names must be purely alphanumeric - no spaces or special characters are allowed.");
|
||||
}
|
||||
|
|
@ -200,6 +205,7 @@ public class GATKReportTable {
|
|||
this.tableName = tableName;
|
||||
this.tableDescription = tableDescription;
|
||||
this.sortByRowID = sortByRowID;
|
||||
this.sortByAllColumns = sortByAllColumns;
|
||||
|
||||
underlyingData = new ArrayList<Object[]>(INITITAL_ARRAY_SIZE);
|
||||
columnInfo = new ArrayList<GATKReportColumn>(numColumns);
|
||||
|
|
@ -212,7 +218,7 @@ public class GATKReportTable {
|
|||
* @param tableToCopy
|
||||
*/
|
||||
public GATKReportTable(final GATKReportTable tableToCopy, final boolean copyData) {
|
||||
this(tableToCopy.getTableName(), tableToCopy.getTableDescription(), tableToCopy.getNumColumns(), tableToCopy.sortByRowID);
|
||||
this(tableToCopy.getTableName(), tableToCopy.getTableDescription(), tableToCopy.getNumColumns(), tableToCopy.sortByRowID, tableToCopy.sortByAllColumns);
|
||||
for ( final GATKReportColumn column : tableToCopy.getColumnInfo() )
|
||||
addColumn(column.getColumnName(), column.getFormat());
|
||||
if ( copyData )
|
||||
|
|
@ -559,30 +565,62 @@ public class GATKReportTable {
|
|||
needsPadding = true;
|
||||
|
||||
out.printf(column.getColumnFormat().getNameFormat(), column.getColumnName());
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
out.println();
|
||||
|
||||
// write the table body
|
||||
if ( sortByRowID ) {
|
||||
// make sure that there are exactly the correct number of ID mappings
|
||||
if ( rowIdToIndex.size() != underlyingData.size() )
|
||||
throw new ReviewedStingException("There isn't a 1-to-1 mapping from row ID to index; this can happen when rows are not created consistently");
|
||||
// write the table body
|
||||
if ( sortByAllColumns ) {
|
||||
Collections.sort(underlyingData, new Comparator<Object[]>() {
|
||||
//INVARIANT the two arrays are of the same length and corresponding elements are of the same type
|
||||
@Override
|
||||
public int compare(Object[] objectArr1, Object[] objectArr2) {
|
||||
final int EQUAL = 0;
|
||||
|
||||
final TreeMap<Object, Integer> sortedMap;
|
||||
try {
|
||||
sortedMap = new TreeMap<Object, Integer>(rowIdToIndex);
|
||||
} catch (ClassCastException e) {
|
||||
throw new ReviewedStingException("Unable to sort the rows based on the row IDs because the ID Objects are of different types");
|
||||
}
|
||||
for ( final Map.Entry<Object, Integer> rowKey : sortedMap.entrySet() )
|
||||
writeRow(out, underlyingData.get(rowKey.getValue()));
|
||||
} else {
|
||||
for ( final Object[] row : underlyingData )
|
||||
writeRow(out, row);
|
||||
}
|
||||
int result = EQUAL;
|
||||
|
||||
out.println();
|
||||
}
|
||||
int l = objectArr1.length;
|
||||
for (int x = 0; x < l; x++) {
|
||||
if (objectArr1[x] instanceof Integer) {
|
||||
result = ((Integer)objectArr1[x]).compareTo((Integer)objectArr2[x]);
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
} else if (objectArr1[x] instanceof Double) {
|
||||
result = ((Double)objectArr1[x]).compareTo((Double)objectArr2[x]);
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
} else { // default uses String comparison
|
||||
result = objectArr1[x].toString().compareTo(objectArr2[x].toString());
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
for ( final Object[] row : underlyingData )
|
||||
writeRow(out, row);
|
||||
} else if ( sortByRowID ) {
|
||||
// make sure that there are exactly the correct number of ID mappings
|
||||
if ( rowIdToIndex.size() != underlyingData.size() )
|
||||
throw new ReviewedStingException("There isn't a 1-to-1 mapping from row ID to index; this can happen when rows are not created consistently");
|
||||
|
||||
final TreeMap<Object, Integer> sortedMap;
|
||||
try {
|
||||
sortedMap = new TreeMap<Object, Integer>(rowIdToIndex);
|
||||
} catch (ClassCastException e) {
|
||||
throw new ReviewedStingException("Unable to sort the rows based on the row IDs because the ID Objects are of different types");
|
||||
}
|
||||
for ( final Map.Entry<Object, Integer> rowKey : sortedMap.entrySet() )
|
||||
writeRow(out, underlyingData.get(rowKey.getValue()));
|
||||
} else {
|
||||
for ( final Object[] row : underlyingData )
|
||||
writeRow(out, row);
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
|
||||
private void writeRow(final PrintStream out, final Object[] row) {
|
||||
boolean needsPadding = false;
|
||||
|
|
@ -697,8 +735,41 @@ public class GATKReportTable {
|
|||
}
|
||||
|
||||
private List<Object[]> getOrderedRows() {
|
||||
if ( !sortByRowID )
|
||||
if ( sortByAllColumns ) {
|
||||
Collections.sort(underlyingData, new Comparator<Object[]>() {
|
||||
//INVARIANT the two arrays are of the same length and corresponding elements are of the same type
|
||||
@Override
|
||||
public int compare(Object[] objectArr1, Object[] objectArr2) {
|
||||
final int EQUAL = 0;
|
||||
|
||||
int result = EQUAL;
|
||||
|
||||
int l = objectArr1.length;
|
||||
for (int x = 0; x < l; x++) {
|
||||
if (objectArr1[x] instanceof Integer) {
|
||||
result = ((Integer)objectArr1[x]).compareTo((Integer)objectArr2[x]);
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
} else if (objectArr1[x] instanceof Double) {
|
||||
result = ((Double)objectArr1[x]).compareTo((Double)objectArr2[x]);
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
} else { // default uses String comparison
|
||||
result = objectArr1[x].toString().compareTo(objectArr2[x].toString());
|
||||
if( result != EQUAL) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
return underlyingData;
|
||||
} else if ( !sortByRowID ) {
|
||||
return underlyingData;
|
||||
}
|
||||
|
||||
final TreeMap<Object, Integer> sortedMap;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -481,6 +481,6 @@ public class BaseRecalibrator extends ReadWalker<Long, Long> implements NanoSche
|
|||
}
|
||||
|
||||
private void generateReport() {
|
||||
RecalUtils.outputRecalibrationReport(RAC, quantizationInfo, recalibrationTables, requestedCovariates);
|
||||
RecalUtils.outputRecalibrationReport(RAC, quantizationInfo, recalibrationTables, requestedCovariates, RAC.SORT_BY_ALL_COLUMNS);
|
||||
}
|
||||
}
|
||||
|
|
@ -180,6 +180,11 @@ public class RecalibrationArgumentCollection {
|
|||
@Argument(fullName = "binary_tag_name", shortName = "bintag", required = false, doc = "the binary tag covariate name if using it")
|
||||
public String BINARY_TAG_NAME = null;
|
||||
|
||||
/*
|
||||
* whether GATK report tables should have rows in sorted order, starting from leftmost column
|
||||
*/
|
||||
@Argument(fullName = "sort_by_all_columns", shortName = "sortAllCols", doc = "Sort the rows in the tables of reports", required = false)
|
||||
public Boolean SORT_BY_ALL_COLUMNS = false;
|
||||
|
||||
/////////////////////////////
|
||||
// Debugging-only Arguments
|
||||
|
|
@ -200,7 +205,12 @@ public class RecalibrationArgumentCollection {
|
|||
public File existingRecalibrationReport = null;
|
||||
|
||||
public GATKReportTable generateReportTable(final String covariateNames) {
|
||||
GATKReportTable argumentsTable = new GATKReportTable("Arguments", "Recalibration argument collection values used in this run", 2);
|
||||
GATKReportTable argumentsTable;
|
||||
if(SORT_BY_ALL_COLUMNS) {
|
||||
argumentsTable = new GATKReportTable("Arguments", "Recalibration argument collection values used in this run", 2, false, true);
|
||||
} else {
|
||||
argumentsTable = new GATKReportTable("Arguments", "Recalibration argument collection values used in this run", 2);
|
||||
}
|
||||
argumentsTable.addColumn("Argument");
|
||||
argumentsTable.addColumn(RecalUtils.ARGUMENT_VALUE_COLUMN_NAME);
|
||||
argumentsTable.addRowID("covariate", true);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class ErrorRatePerCycle extends LocusWalker<Integer, Integer> {
|
|||
|
||||
public void initialize() {
|
||||
report = new GATKReport();
|
||||
report.addTable(reportName, reportDescription, 6, true);
|
||||
report.addTable(reportName, reportDescription, 6, true, false);
|
||||
table = report.getTable(reportName);
|
||||
table.addColumn("readgroup");
|
||||
table.addColumn("cycle");
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public class VariantEvalReportWriter {
|
|||
// create the table
|
||||
final String tableName = ve.getSimpleName();
|
||||
final String tableDesc = ve.getClass().getAnnotation(Analysis.class).description();
|
||||
report.addTable(tableName, tableDesc, 1 + stratifiers.size() + (scanner.hasMoltenField() ? 2 : datamap.size()), true);
|
||||
report.addTable(tableName, tableDesc, 1 + stratifiers.size() + (scanner.hasMoltenField() ? 2 : datamap.size()), true, false);
|
||||
|
||||
// grab the table, and add the columns we need to it
|
||||
final GATKReportTable table = report.getTable(tableName);
|
||||
|
|
|
|||
|
|
@ -67,8 +67,13 @@ public class QuantizationInfo {
|
|||
return quantizationLevels;
|
||||
}
|
||||
|
||||
public GATKReportTable generateReportTable() {
|
||||
GATKReportTable quantizedTable = new GATKReportTable(RecalUtils.QUANTIZED_REPORT_TABLE_TITLE, "Quality quantization map", 3);
|
||||
public GATKReportTable generateReportTable(boolean sortBycols) {
|
||||
GATKReportTable quantizedTable;
|
||||
if(sortBycols) {
|
||||
quantizedTable = new GATKReportTable(RecalUtils.QUANTIZED_REPORT_TABLE_TITLE, "Quality quantization map", 3, false, true);
|
||||
} else {
|
||||
quantizedTable = new GATKReportTable(RecalUtils.QUANTIZED_REPORT_TABLE_TITLE, "Quality quantization map", 3);
|
||||
}
|
||||
quantizedTable.addColumn(RecalUtils.QUALITY_SCORE_COLUMN_NAME);
|
||||
quantizedTable.addColumn(RecalUtils.QUANTIZED_COUNT_COLUMN_NAME);
|
||||
quantizedTable.addColumn(RecalUtils.QUANTIZED_VALUE_COLUMN_NAME);
|
||||
|
|
|
|||
|
|
@ -257,11 +257,10 @@ public class RecalUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static List<GATKReportTable> generateReportTables(final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates) {
|
||||
private static List<GATKReportTable> generateReportTables(final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates, boolean sortByCols) {
|
||||
List<GATKReportTable> result = new LinkedList<GATKReportTable>();
|
||||
int reportTableIndex = 0;
|
||||
int rowIndex = 0;
|
||||
|
||||
final Map<Covariate, String> covariateNameMap = new HashMap<Covariate, String>(requestedCovariates.length);
|
||||
for (final Covariate covariate : requestedCovariates)
|
||||
covariateNameMap.put(covariate, parseCovariateName(covariate));
|
||||
|
|
@ -287,7 +286,11 @@ public class RecalUtils {
|
|||
|
||||
final GATKReportTable reportTable;
|
||||
if (tableIndex <= RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index) {
|
||||
reportTable = new GATKReportTable("RecalTable" + reportTableIndex++, "", columnNames.size());
|
||||
if(sortByCols) {
|
||||
reportTable = new GATKReportTable("RecalTable" + reportTableIndex++, "", columnNames.size(), false, true);
|
||||
} else {
|
||||
reportTable = new GATKReportTable("RecalTable" + reportTableIndex++, "", columnNames.size());
|
||||
}
|
||||
for (final Pair<String, String> columnName : columnNames)
|
||||
reportTable.addColumn(columnName.getFirst(), columnName.getSecond());
|
||||
rowIndex = 0; // reset the row index since we're starting with a new table
|
||||
|
|
@ -334,8 +337,8 @@ public class RecalUtils {
|
|||
return covariate.getClass().getSimpleName().split("Covariate")[0];
|
||||
}
|
||||
|
||||
public static void outputRecalibrationReport(final RecalibrationArgumentCollection RAC, final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates) {
|
||||
outputRecalibrationReport(RAC.generateReportTable(covariateNames(requestedCovariates)), quantizationInfo.generateReportTable(), generateReportTables(recalibrationTables, requestedCovariates), RAC.RECAL_TABLE);
|
||||
public static void outputRecalibrationReport(final RecalibrationArgumentCollection RAC, final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates, boolean sortByCols) {
|
||||
outputRecalibrationReport(RAC.generateReportTable(covariateNames(requestedCovariates)), quantizationInfo.generateReportTable(sortByCols), generateReportTables(recalibrationTables, requestedCovariates, sortByCols), RAC.RECAL_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -351,8 +354,8 @@ public class RecalUtils {
|
|||
return Utils.join(",", names);
|
||||
}
|
||||
|
||||
public static void outputRecalibrationReport(final GATKReportTable argumentTable, final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates, final PrintStream outputFile) {
|
||||
outputRecalibrationReport(argumentTable, quantizationInfo.generateReportTable(), generateReportTables(recalibrationTables, requestedCovariates), outputFile);
|
||||
public static void outputRecalibrationReport(final GATKReportTable argumentTable, final QuantizationInfo quantizationInfo, final RecalibrationTables recalibrationTables, final Covariate[] requestedCovariates, final PrintStream outputFile, boolean sortByCols) {
|
||||
outputRecalibrationReport(argumentTable, quantizationInfo.generateReportTable(sortByCols), generateReportTables(recalibrationTables, requestedCovariates, sortByCols), outputFile);
|
||||
}
|
||||
|
||||
private static void outputRecalibrationReport(final GATKReportTable argumentTable, final GATKReportTable quantizationTable, final List<GATKReportTable> recalTables, final PrintStream outputFile) {
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ public class RecalibrationReport {
|
|||
|
||||
else if (argument.equals("binary_tag_name"))
|
||||
RAC.BINARY_TAG_NAME = (value == null) ? null : (String) value;
|
||||
|
||||
else if (argument.equals("sort_by_all_columns"))
|
||||
RAC.SORT_BY_ALL_COLUMNS = Boolean.parseBoolean((String) value);
|
||||
}
|
||||
|
||||
return RAC;
|
||||
|
|
@ -318,7 +321,7 @@ public class RecalibrationReport {
|
|||
}
|
||||
|
||||
public void output(PrintStream output) {
|
||||
RecalUtils.outputRecalibrationReport(argumentTable, quantizationInfo, recalibrationTables, requestedCovariates, output);
|
||||
RecalUtils.outputRecalibrationReport(argumentTable, quantizationInfo, recalibrationTables, requestedCovariates, output, RAC.SORT_BY_ALL_COLUMNS);
|
||||
}
|
||||
|
||||
public RecalibrationArgumentCollection getRAC() {
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public class GATKReportUnitTest extends BaseTest {
|
|||
table.set("RZ", "SomeFloat", 535646345.657453464576);
|
||||
table.set("RZ", "TrueFalse", true);
|
||||
|
||||
report1.addTable("Table3", "blah", 1, true);
|
||||
report1.addTable("Table3", "blah", 1, true, false);
|
||||
report1.getTable("Table3").addColumn("a");
|
||||
report1.getTable("Table3").addRowIDMapping("q", 2);
|
||||
report1.getTable("Table3").addRowIDMapping("5", 3);
|
||||
|
|
|
|||
Loading…
Reference in New Issue