Skip to content

Commit

Permalink
fix failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
takutosato committed Mar 21, 2019
1 parent ef56a86 commit 77b035c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public List<ReadFilter> getDefaultReadFilters() {

@Override
public void onTraversalStart() {
// TODO: extract a method
// Initialize for each reference the histogram of the counts of reference sites by depth
ALL_KMERS.forEach(context -> {
Histogram<Integer> emptyRefHistogram = F1R2FilterUtils.createRefHistogram(context, maxDepth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public class LearnReadOrientationModel extends CommandLineProgram {

@Override
protected void onStartup(){
Utils.validate(refHistogramFiles.size() == altDataTables.size() && altDataTables.size() == altHistogramFiles.size(),
"The numbers of ref histograms, alt histograms, and alt table files must all be the same");
Utils.validate(refHistogramFiles.size() == altDataTables.size(), "The same number of ref histograms and alt tables must be provided");
Utils.validate(altHistogramFiles.size() == 0 || altDataTables.size() == altHistogramFiles.size(), "If provided, the number of alt histograms must match others");
refHistograms = sumHistogramsFromFiles(refHistogramFiles, true);

if (altHistogramFiles != null) {
if (altHistogramFiles.size() > 0) {
altHistograms = sumHistogramsFromFiles(altHistogramFiles, false);
} else {
altHistograms = Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.*;
import java.util.stream.IntStream;

import static org.broadinstitute.hellbender.tools.walkers.readorientation.F1R2FilterConstants.ALL_KMERS;

public class LearnReadOrientationModelEngineUnitTest extends CommandLineProgramTest {
private static final double EPSILON = 1e-3;

Expand Down Expand Up @@ -224,27 +226,30 @@ public void testReverseComplement() throws IOException {

final List<AltSiteRecord> altDesignMatrix = new ArrayList<>();

final Map<String, Histogram<Integer>> refSiteHistograms = new HashMap<>(ALL_KMERS.size());
ALL_KMERS.forEach(context -> {
Histogram<Integer> emptyRefHistogram = F1R2FilterUtils.createRefHistogram(context, F1R2FilterConstants.DEFAULT_MAX_DEPTH);
refSiteHistograms.put(context, emptyRefHistogram);
});

for (final Triple<String, Nucleotide, ReadOrientation> transition : transitions) {
final String refContext = transition.getLeft();
final Nucleotide altAllele = transition.getMiddle();
final ReadOrientation f1r2 = transition.getRight();

final Histogram<Integer> refSiteHistogram = F1R2FilterUtils.createRefHistogram(refContext, F1R2FilterConstants.DEFAULT_MAX_DEPTH);

refSiteHistogram.increment(refDepth, numRefExamples);
refMetricsFile.addHistogram(refSiteHistogram);
refSiteHistograms.get(refContext).increment(refDepth, numRefExamples);

final int refF1R2 = refDepth / 2;
final int altF1R2 = f1r2 == ReadOrientation.F1R2 ? altDepth : 0;

IntStream.range(0, numArtifactExamples).forEach(i -> altDesignMatrix.add(new AltSiteRecord(refContext, refDepth, altDepth, refF1R2, altF1R2, altAllele)));
}

refSiteHistograms.values().forEach(hist -> refMetricsFile.addHistogram(hist));
refMetricsFile.write(refHistogramOutput);
altTableWriter.writeAllRecords(altDesignMatrix);
altTableWriter.close();


final File artifactPriorTable = GATKBaseTest.createTempFile("prior", ".tsv");
new Main().instanceMain(makeCommandLineArgs(
Arrays.asList(
Expand Down

0 comments on commit 77b035c

Please sign in to comment.