From 16777e387527d8d2a63ce59f8de3383c63b118ef Mon Sep 17 00:00:00 2001 From: aaron Date: Tue, 12 Jan 2010 18:47:43 +0000 Subject: [PATCH] more fixes for the empty interval list problem; you can now run LocusWindow traversals with an empty interval list, but the GATK will give you a warning (unless you're running in unsafe mode). git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2563 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/GenomeAnalysisEngine.java | 5 +++-- .../shards/IntervalShardStrategy.java | 19 ++----------------- .../shards/IntervalShardStrategyTest.java | 4 ++-- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index d6d0528ea..10ef3d375 100755 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -626,8 +626,9 @@ public class GenomeAnalysisEngine { SHARD_SIZE, maxIterations); } } else if (walker instanceof LocusWindowWalker) { - if (intervals == null || intervals.isEmpty()) - throw new StingException("Unable to shard: walker is of type LocusWindow, but no intervals were provided"); + if ((intervals == null || intervals.isEmpty()) && !this.argCollection.unsafe) + Utils.warnUser("walker is of type LocusWindow (which operates over intervals), but no intervals were provided." + + "This may be unintentional, check your command-line arguments."); shardStrategy = ShardStrategyFactory.shatter(ShardStrategyFactory.SHATTER_STRATEGY.INTERVAL, drivingDataSource.getSequenceDictionary(), SHARD_SIZE, diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java index 1cc1eb34d..51d18f728 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategy.java @@ -57,7 +57,7 @@ public class IntervalShardStrategy implements ShardStrategy { * @param size the next recommended shard size. */ public void adjustNextShardSize( long size ) { - this.size = size; + this.size = size; // we don't do anything with the size in this case, but we should store it anyway } /** @@ -67,26 +67,11 @@ public class IntervalShardStrategy implements ShardStrategy { * @param locations */ IntervalShardStrategy( long size, GenomeLocSortedSet locations, Shard.ShardType shardType ) { - if (locations == null || locations.isEmpty()) { - throw new StingException("IntervalShardStrategy: genomic regions list is empty."); - } type = shardType; - this.regions = locations.clone(); + this.regions = locations == null ? new GenomeLocSortedSet() : locations.clone(); this.size = size; } - /** - * the default constructor - * - * @param dict the sequence dictionary to use - */ - IntervalShardStrategy( SAMSequenceDictionary dict, GenomeLocSortedSet locations ) { - if (locations == null || locations.isEmpty()) { - throw new StingException("IntervalShardStrategy: genomic regions list is empty."); - } - this.regions = locations.clone(); - } - /** * returns true if there are additional shards * diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategyTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategyTest.java index cca28ad85..e94a4d908 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategyTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/shards/IntervalShardStrategyTest.java @@ -65,8 +65,8 @@ public class IntervalShardStrategyTest extends BaseTest { mSortedSet = new GenomeLocSortedSet(); } - @Test(expected = StingException.class) - public void testExceptionOnEmpty() { + @Test + public void testNoExceptionOnEmpty() { IntervalShardStrategy strat = new IntervalShardStrategy(100, mSortedSet,Shard.ShardType.LOCUS_INTERVAL); }