From e682460c1f7ff45aeec33cdaabfc44cd0f8db355 Mon Sep 17 00:00:00 2001 From: aaron Date: Thu, 15 Apr 2010 16:31:43 +0000 Subject: [PATCH] add a fix so that XL arguments won't cancel out -BTI arguments, fixed a bug for Ben where the ROD -> interval list conversion was throwing an exception, and some old code removal. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3174 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/GenomeAnalysisEngine.java | 16 ++++---- .../sting/utils/GenomeLocSortedSet.java | 37 ------------------- .../utils/GenomeLocSortedSetUnitTest.java | 27 -------------- 3 files changed, 9 insertions(+), 71 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index 7d0b79f03..81ac1b9bb 100755 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -184,7 +184,9 @@ public class GenomeAnalysisEngine { // if include argument isn't given, create new set of all possible intervals GenomeLocSortedSet includeSortedSet = (argCollection.intervals == null && argCollection.RODToInterval == null ? GenomeLocSortedSet.createSetFromSequenceDictionary(this.referenceDataSource.getSequenceDictionary()) : - loadIntervals(argCollection.intervals, argCollection.intervalMerging)); + loadIntervals(argCollection.intervals, + argCollection.intervalMerging, + GenomeLocParser.mergeIntervalLocations(checkRODToIntervalArgument(),argCollection.intervalMerging))); // if no exclude arguments, can return parseIntervalArguments directly if (argCollection.excludeIntervals == null) @@ -192,7 +194,7 @@ public class GenomeAnalysisEngine { // otherwise there are exclude arguments => must merge include and exclude GenomeLocSortedSets else { - GenomeLocSortedSet excludeSortedSet = loadIntervals(argCollection.excludeIntervals, argCollection.intervalMerging); + GenomeLocSortedSet excludeSortedSet = loadIntervals(argCollection.excludeIntervals, argCollection.intervalMerging, null); intervals = includeSortedSet.subtractRegions(excludeSortedSet); // logging messages only printed when exclude (-XL) arguments are given @@ -208,16 +210,16 @@ public class GenomeAnalysisEngine { } /** - * Loads the intervals relevant to + * Loads the intervals relevant to the current execution * @param argList String representation of arguments; might include 'all', filenames, intervals in samtools * notation, or a combination of the * @param mergingRule Technique to use when merging interval data. + * @param additionalIntervals a list of additional intervals to add to the returned set. Can be null. * @return A sorted, merged list of all intervals specified in this arg list. */ - private GenomeLocSortedSet loadIntervals(List argList, IntervalMergingRule mergingRule) { - List rawIntervals = new ArrayList(); // running list of raw GenomeLocs - // TODO: Aaron, how do we discriminate between RODs that are for inclusion and RODs that are for exclusion? - rawIntervals.addAll(checkRODToIntervalArgument()); // add any RODs-to-intervals we have + private GenomeLocSortedSet loadIntervals(List argList, IntervalMergingRule mergingRule, List additionalIntervals) { + List rawIntervals = (additionalIntervals == null) ? new ArrayList() : additionalIntervals; // running list of raw GenomeLocs + rawIntervals.addAll(IntervalUtils.parseIntervalArguments(argList)); // redundant check => default no arguments is null, not empty list diff --git a/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java b/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java index 8d7a98069..e34be715d 100755 --- a/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java +++ b/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java @@ -317,43 +317,6 @@ public class GenomeLocSortedSet extends AbstractSet { return ret; } - - public boolean addAllRegions(List locations) { - this.mArray.addAll(locations); - Collections.sort(this.mArray); - this.mArray = GenomeLocSortedSet.mergeOverlappingLocations(this.mArray); - return true; - } - -/** - * merge a list of genome locs that may be overlapping, returning the list of unique genomic locations - * - * @param raw the unchecked genome loc list - * - * @return the list of merged locations - */ - public static List mergeOverlappingLocations(final List raw) { - logger.debug(" Raw locations are: " + Utils.join(", ", raw)); - if (raw.size() <= 1) - return raw; - else { - ArrayList merged = new ArrayList(); - Iterator it = raw.iterator(); - GenomeLoc prev = it.next(); - while (it.hasNext()) { - GenomeLoc curr = it.next(); - if (prev.contiguousP(curr)) { - prev = prev.merge(curr); - } else { - merged.add(prev); - prev = curr; - } - } - merged.add(prev); - return merged; - } - } - /** * convert this object to a list * @return the lists diff --git a/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java b/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java index 0fdca4fc5..f28d3f350 100755 --- a/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java @@ -217,31 +217,4 @@ public class GenomeLocSortedSetUnitTest extends BaseTest { } assertTrue(seqNumber == GenomeLocSortedSetUnitTest.NUMBER_OF_CHROMOSOMES); } - - @Test - public void testAddAll() { - mSortedSet = GenomeLocSortedSet.createSetFromSequenceDictionary(this.header.getSequenceDictionary()); - GenomeLocSortedSet set = GenomeLocSortedSet.createSetFromSequenceDictionary(this.header.getSequenceDictionary()); - // we should have sequence - assertTrue(mSortedSet.size() == GenomeLocSortedSetUnitTest.NUMBER_OF_CHROMOSOMES); - mSortedSet.addAllRegions(set.toList()); - assertTrue(mSortedSet.size() == GenomeLocSortedSetUnitTest.NUMBER_OF_CHROMOSOMES); - } - - @Test - public void testAddAll2() { - mSortedSet = new GenomeLocSortedSet(); - GenomeLocSortedSet mSortedSet2 = new GenomeLocSortedSet(); - for (int x=0; x < 200; x = x + 2) { - mSortedSet.add(GenomeLocParser.createGenomeLoc(1,x)); - } - assertEquals(100, mSortedSet.size()); - for (int x=1; x < 201; x = x + 2) { - mSortedSet2.add(GenomeLocParser.createGenomeLoc(1,x)); - } - assertEquals(100, mSortedSet2.size()); - mSortedSet.addAllRegions(mSortedSet2.toList()); - assertEquals(1, mSortedSet.size()); - } - }