Merge pull request #160 from broadinstitute/rp_bqsr_gatherer_works_with_empty_tables
Updating BQSR RecalibrationEngine to work correctly with empty BQSR tabl...
This commit is contained in:
commit
35293cde49
|
|
@ -65,7 +65,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class BQSRGatherer extends Gatherer {
|
public class BQSRGatherer extends Gatherer {
|
||||||
|
|
||||||
private static final String EMPTY_INPUT_LIST = "list of inputs files is empty";
|
private static final String EMPTY_INPUT_LIST = "list of inputs files is empty or there is no usable data in any input file";
|
||||||
private static final String MISSING_OUTPUT_FILE = "missing output file name";
|
private static final String MISSING_OUTPUT_FILE = "missing output file name";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -80,6 +80,8 @@ public class BQSRGatherer extends Gatherer {
|
||||||
RecalibrationReport generalReport = null;
|
RecalibrationReport generalReport = null;
|
||||||
for (File input : inputs) {
|
for (File input : inputs) {
|
||||||
final RecalibrationReport inputReport = new RecalibrationReport(input);
|
final RecalibrationReport inputReport = new RecalibrationReport(input);
|
||||||
|
if( inputReport.isEmpty() ) { continue; }
|
||||||
|
|
||||||
if (generalReport == null)
|
if (generalReport == null)
|
||||||
generalReport = inputReport;
|
generalReport = inputReport;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ public class RecalibrationEngine {
|
||||||
final NestedIntegerArray<RecalDatum> byQualTable = finalRecalibrationTables.getQualityScoreTable();
|
final NestedIntegerArray<RecalDatum> byQualTable = finalRecalibrationTables.getQualityScoreTable();
|
||||||
|
|
||||||
// iterate over all values in the qual table
|
// iterate over all values in the qual table
|
||||||
for ( NestedIntegerArray.Leaf<RecalDatum> leaf : byQualTable.getAllLeaves() ) {
|
for ( final NestedIntegerArray.Leaf<RecalDatum> leaf : byQualTable.getAllLeaves() ) {
|
||||||
final int rgKey = leaf.keys[0];
|
final int rgKey = leaf.keys[0];
|
||||||
final int eventIndex = leaf.keys[2];
|
final int eventIndex = leaf.keys[2];
|
||||||
final RecalDatum rgDatum = byReadGroupTable.get(rgKey, eventIndex);
|
final RecalDatum rgDatum = byReadGroupTable.get(rgKey, eventIndex);
|
||||||
|
|
@ -206,7 +206,9 @@ public class RecalibrationEngine {
|
||||||
*/
|
*/
|
||||||
@Requires("! finalized")
|
@Requires("! finalized")
|
||||||
private RecalibrationTables mergeThreadLocalRecalibrationTables() {
|
private RecalibrationTables mergeThreadLocalRecalibrationTables() {
|
||||||
if ( recalibrationTablesList.isEmpty() ) throw new IllegalStateException("recalibration tables list is empty");
|
if ( recalibrationTablesList.isEmpty() ) {
|
||||||
|
recalibrationTablesList.add( new RecalibrationTables(covariates, numReadGroups, maybeLogStream) );
|
||||||
|
}
|
||||||
|
|
||||||
RecalibrationTables merged = null;
|
RecalibrationTables merged = null;
|
||||||
for ( final RecalibrationTables table : recalibrationTablesList ) {
|
for ( final RecalibrationTables table : recalibrationTablesList ) {
|
||||||
|
|
|
||||||
|
|
@ -372,4 +372,11 @@ public class RecalibrationReport {
|
||||||
public Covariate[] getCovariates() {
|
public Covariate[] getCovariates() {
|
||||||
return requestedCovariates;
|
return requestedCovariates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the report has no data
|
||||||
|
*/
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return recalibrationTables.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,16 @@ public final class RecalibrationTables {
|
||||||
return tables.size();
|
return tables.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if all the tables contain no RecalDatums
|
||||||
|
*/
|
||||||
|
public boolean isEmpty() {
|
||||||
|
for( final NestedIntegerArray<RecalDatum> table : tables ) {
|
||||||
|
if( !table.getAllValues().isEmpty() ) { return false; }
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new quality score table, based on requested parameters
|
* Allocate a new quality score table, based on requested parameters
|
||||||
* in this set of tables, without any data in it. The return result
|
* in this set of tables, without any data in it. The return result
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ public class BQSRGathererUnitTest extends BaseTest {
|
||||||
private static File recal3 = new File(privateTestDir + "HiSeq.1mb.1RG.sg3.table");
|
private static File recal3 = new File(privateTestDir + "HiSeq.1mb.1RG.sg3.table");
|
||||||
private static File recal4 = new File(privateTestDir + "HiSeq.1mb.1RG.sg4.table");
|
private static File recal4 = new File(privateTestDir + "HiSeq.1mb.1RG.sg4.table");
|
||||||
private static File recal5 = new File(privateTestDir + "HiSeq.1mb.1RG.sg5.table");
|
private static File recal5 = new File(privateTestDir + "HiSeq.1mb.1RG.sg5.table");
|
||||||
|
private static File recalEmpty = new File(privateTestDir + "HiSeq.1mb.1RG.empty.table");
|
||||||
|
|
||||||
private static File recal_original = new File(privateTestDir + "HiSeq.1mb.1RG.noSG.table");
|
private static File recal_original = new File(privateTestDir + "HiSeq.1mb.1RG.noSG.table");
|
||||||
|
|
||||||
|
|
@ -110,6 +111,26 @@ public class BQSRGathererUnitTest extends BaseTest {
|
||||||
testReports(originalReport, calculatedReport);
|
testReports(originalReport, calculatedReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true)
|
||||||
|
public void testGatherBQSRWithEmptyFile() {
|
||||||
|
BQSRGatherer gatherer = new BQSRGatherer();
|
||||||
|
List<File> recalFiles = new LinkedList<File> ();
|
||||||
|
final File output = BaseTest.createTempFile("BQSRgathererTest", ".table");
|
||||||
|
|
||||||
|
recalFiles.add(recal1);
|
||||||
|
recalFiles.add(recal2);
|
||||||
|
recalFiles.add(recal3);
|
||||||
|
recalFiles.add(recal4);
|
||||||
|
recalFiles.add(recal5);
|
||||||
|
recalFiles.add(recalEmpty);
|
||||||
|
gatherer.gather(recalFiles, output);
|
||||||
|
|
||||||
|
GATKReport originalReport = new GATKReport(recal_original);
|
||||||
|
GATKReport calculatedReport = new GATKReport(output);
|
||||||
|
|
||||||
|
testReports(originalReport, calculatedReport);
|
||||||
|
}
|
||||||
|
|
||||||
private void testReports(final GATKReport originalReport, final GATKReport calculatedReport) {
|
private void testReports(final GATKReport originalReport, final GATKReport calculatedReport) {
|
||||||
|
|
||||||
// test the Arguments table
|
// test the Arguments table
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue