/** Adds all items to the overlap detector. */ public void addAll(List<T> objects, List<Interval> intervals) { if (objects.size() != intervals.size()) { throw new IllegalArgumentException("Objects and intervals must be the same size."); } for (int i=0; i<objects.size(); ++i) { addLhs(objects.get(i), intervals.get(i)); } }
/** * Adds all items to the overlap detector. * * The order of the lists matters only in the sense that it needs to be the same for the intervals * and the corresponding objects. */ public void addAll(final List<T> objects, final List<? extends Locatable> intervals) { if (objects == null) { throw new IllegalArgumentException("null objects"); } if (intervals == null) { throw new IllegalArgumentException("null intervals"); } if (objects.size() != intervals.size()) { throw new IllegalArgumentException("Objects and intervals must be the same size but were " + objects.size() + " and " + intervals.size()); } for (int i=0; i<objects.size(); ++i) { addLhs(objects.get(i), intervals.get(i)); } }
/** * Adds all items to the overlap detector. * * The order of the lists matters only in the sense that it needs to be the same for the intervals * and the corresponding objects. */ public void addAll(final List<T> objects, final List<? extends Locatable> intervals) { if (objects == null) { throw new IllegalArgumentException("null objects"); } if (intervals == null) { throw new IllegalArgumentException("null intervals"); } if (objects.size() != intervals.size()) { throw new IllegalArgumentException("Objects and intervals must be the same size but were " + objects.size() + " and " + intervals.size()); } for (int i=0; i<objects.size(); ++i) { addLhs(objects.get(i), intervals.get(i)); } }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final Set<Integer> ids = new HashSet<Integer>(); BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { if (ids.contains(chain.id)) { throw new SAMException("Chain id " + chain.id + " appears more than once in chain file."); } ids.add(chain.id); ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
/** * Read all the chains and load into an OverlapDetector. * @param chainFile File in UCSC chain format. * @return OverlapDetector will all Chains from reader loaded into it. */ static OverlapDetector<Chain> loadChains(final File chainFile) { final BufferedLineReader reader = new BufferedLineReader(IOUtil.openFileForReading(chainFile)); final OverlapDetector<Chain> ret = new OverlapDetector<Chain>(0, 0); Chain chain; while ((chain = Chain.loadChain(reader, chainFile.toString())) != null) { ret.addLhs(chain, chain.interval); } reader.close(); return ret; }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullObjectAddLHS() throws Exception { final List<Locatable> input = Arrays.asList( new Interval("1",10,100) ); final OverlapDetector<Locatable> targetDetector = OverlapDetector.create(input); targetDetector.addLhs(null, new Interval("2",10,100)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullIntervalAddLHS() throws Exception { final List<Locatable> input = Arrays.asList( new Interval("1",10,100) ); final OverlapDetector<Locatable> targetDetector = OverlapDetector.create(input); targetDetector.addLhs(new Interval("2",10,100), null); }
@Test public void ensureOverlapExclusionTest() { final OverlapDetector<Interval> oneTinyIntervalDetector = new OverlapDetector<Interval>(0, 0); final Interval theInterval = new Interval("1", 5, 10); oneTinyIntervalDetector.addLhs(theInterval, theInterval); final VcfFileSegmentGenerator noFilter = VcfFileSegmentGenerator.byWholeContigSubdividingWithWidth(TEN_MILLION); Assert.assertEquals(Iterables.size(noFilter.forVcf(VCF_WITH_LOGS_OF_GAPS)), 382); // The number of subdivisions of 10 million of this vcf final VcfFileSegmentGenerator allFiltered = VcfFileSegmentGenerator.excludingNonOverlaps(noFilter, oneTinyIntervalDetector); Assert.assertEquals(Iterables.size(allFiltered.forVcf(VCF_WITH_LOGS_OF_GAPS)), 1); } }
final OverlapDetector<VcfFileSegment> vcfSpecificDetector = multiSegmentDetectorPerFile.get(segment.vcf()); if (vcfSpecificDetector.getOverlaps(segmentInterval).isEmpty()) { vcfSpecificDetector.addLhs(segment, new Interval(segment.contig(), segment.start(), segment.stop())); } else { throw new IllegalArgumentException(String.format(
final OverlapDetector<VcfFileSegment> vcfSpecificDetector = multiSegmentDetectorPerFile.get(segment.vcf()); if (vcfSpecificDetector.getOverlaps(segmentInterval).isEmpty()) { vcfSpecificDetector.addLhs(segment, new Interval(segment.contig(), segment.start(), segment.stop())); } else { throw new IllegalArgumentException(String.format(
try { final Gene gene = makeGeneFromRefFlatLines(transcriptLines); overlapDetector.addLhs(gene, gene); if (gene.length() > longestInterval) longestInterval = gene.length(); if (gene.length() > 1000000) ++numIntervalsOver1MB;
try { final Gene gene = makeGeneFromRefFlatLines(transcriptLines); overlapDetector.addLhs(gene, gene); if (gene.length() > longestInterval) longestInterval = gene.length(); if (gene.length() > 1000000) ++numIntervalsOver1MB;
final int dummy = -1; // NB: since we don't actually use the returned objects, we can use a dummy value for (final Interval interval : overlapIntervals.sorted().uniqued()) { detector.addLhs(dummy, interval);
final int dummy = -1; // NB: since we don't actually use the returned objects, we can use a dummy value for (final Interval interval : overlapIntervals.sorted().uniqued()) { detector.addLhs(dummy, interval);