From e440c9be987868a84a7bf152fc88db1b1854048e Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 14 Mar 2012 14:59:31 -0400 Subject: [PATCH] Clean up logic for adding reads to ART cache -- No longer has duplicate code --- .../traversals/TraverseActiveRegions.java | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/traversals/TraverseActiveRegions.java b/public/java/src/org/broadinstitute/sting/gatk/traversals/TraverseActiveRegions.java index c0fc78e3c..ff376fcd2 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/traversals/TraverseActiveRegions.java +++ b/public/java/src/org/broadinstitute/sting/gatk/traversals/TraverseActiveRegions.java @@ -94,19 +94,12 @@ public class TraverseActiveRegions extends TraversalEngine extends TraversalEngine activeRegions = bandPassFiltered.createActiveRegions( activeRegionExtension ); - logger.debug("Integrated " + profile.size() + " isActive calls into " + activeRegions.size() + " regions." ); - // add to work queue - if( walker.activeRegionOutStream == null ) { - workQueue.addAll( activeRegions ); - } else { // Just want to output the active regions to a file, not actually process them - for( final ActiveRegion activeRegion : activeRegions ) { - if( activeRegion.isActive ) { - walker.activeRegionOutStream.println( activeRegion.getLocation() ); - } - } - } + // add active regions to queue of regions to process + workQueue.addAll( activeRegions ); + logger.debug("Integrated " + profile.size() + " isActive calls into " + activeRegions.size() + " regions." ); // now go and process all of the active regions sum = processActiveRegions(walker, sum, minStart, dataProvider.getLocus().getContig()); @@ -170,6 +155,29 @@ public class TraverseActiveRegions extends TraversalEngine walker, T sum, final int minStart, final String currentContig ) { + if( walker.activeRegionOutStream != null ) { + writeActiveRegionsToStream(walker); + return sum; + } else { + return callWalkerMapOnActiveRegions(walker, sum, minStart, currentContig); + } + } + + /** + * Write out each active region to the walker activeRegionOutStream + * + * @param walker + */ + private void writeActiveRegionsToStream( final ActiveRegionWalker walker ) { + // Just want to output the active regions to a file, not actually process them + for( final ActiveRegion activeRegion : workQueue ) { + if( activeRegion.isActive ) { + walker.activeRegionOutStream.println( activeRegion.getLocation() ); + } + } + } + + private T callWalkerMapOnActiveRegions( final ActiveRegionWalker walker, T sum, final int minStart, final String currentContig ) { // Since we've traversed sufficiently past this point (or this contig!) in the workQueue we can unload those regions and process them while( workQueue.peek() != null ) { final GenomeLoc extendedLoc = workQueue.peek().getExtendedLoc();