@Override IntervalList act(final List<IntervalList> list, final List<IntervalList> unused) { return IntervalList.intersection(list); } },
@Override IntervalList act(final List<IntervalList> list, final List<IntervalList> unused) { return IntervalList.intersection(list); } },
/** * A utility function for intersecting a list of IntervalLists, checks for equal dictionaries. * * @param lists the list of IntervalList * @return the intersection of all the IntervalLists in lists. */ public static IntervalList intersection(final Collection<IntervalList> lists) { IntervalList intersection = null; for (final IntervalList list : lists) { if (intersection == null) { intersection = list; } else { intersection = intersection(intersection, list); } } return intersection; }
/** * A utility function for intersecting a list of IntervalLists, checks for equal dictionaries. * * @param lists the list of IntervalList * @return the intersection of all the IntervalLists in lists. */ public static IntervalList intersection(final Collection<IntervalList> lists) { IntervalList intersection = null; for (final IntervalList list : lists) { if (intersection == null) { intersection = list; } else { intersection = intersection(intersection, list); } } return intersection; }
/** * A utility function for intersecting a list of IntervalLists, checks for equal dictionaries. * * @param lists the list of IntervalList * @return the intersection of all the IntervalLists in lists. */ public static IntervalList intersection(final Collection<IntervalList> lists) { IntervalList intersection = null; for (final IntervalList list : lists) { if(intersection == null){ intersection = list; } else{ intersection = intersection(intersection, list); } } return intersection; }
/** * A utility function for subtracting a collection of IntervalLists from another. Resulting loci are those that are in the first collection * but not the second. * * @param lhs the collection of IntervalList from which to subtract intervals * @param rhs the collection of intervals to subtract * @return an IntervalList comprising all loci that are in the first collection but not the second lhs-rhs=answer. */ public static IntervalList subtract(final Collection<IntervalList> lhs, final Collection<IntervalList> rhs) { return intersection( union(lhs), invert(union(rhs))); }
/** * A utility function for subtracting a collection of IntervalLists from another. Resulting loci are those that are in the first collection * but not the second. * * @param lhs the collection of IntervalList from which to subtract intervals * @param rhs the collection of intervals to subtract * @return an IntervalList comprising all loci that are in the first collection but not the second lhs-rhs=answer. */ public static IntervalList subtract(final Collection<IntervalList> lhs, final Collection<IntervalList> rhs) { return intersection( union(lhs), invert(union(rhs))); }
/** * A utility function for subtracting a collection of IntervalLists from another. Resulting loci are those that are in the first collection * but not the second. * * @param listsToSubtractFrom the collection of IntervalList from which to subtract intervals * @param listsToSubtract the collection of intervals to subtract * @return an IntervalLists comprising all loci that are in first collection but not second. */ public static IntervalList subtract(final Collection<IntervalList> listsToSubtractFrom, final Collection<IntervalList> listsToSubtract) { return intersection( union(listsToSubtractFrom), invert(union(listsToSubtract))); }
/** * Reads Interprets intervals from the input INTERVALS, if there's a file with that name, it opens the file, otherwise * it tries to parse it, checks that their dictionaries all agree with the input SequenceDictionary and returns the * intersection of all the lists. * * @param sequenceDictionary a {@link SAMSequenceDictionary} to parse the intervals against. * @return the intersection of the interval lists pointed to by the input parameter INTERVALS */ private IntervalList getIntervals(final SAMSequenceDictionary sequenceDictionary) { IntervalList regionOfInterest = null; for (final File intervalListFile : INTERVALS) { if (!intervalListFile.exists()) { throw new IllegalArgumentException("Input file " + intervalListFile + " doesn't seem to exist. "); } log.info("Reading IntervalList ", intervalListFile, "."); final IntervalList temp = IntervalList.fromFile(intervalListFile); sequenceDictionary.assertSameDictionary(temp.getHeader().getSequenceDictionary()); if (regionOfInterest == null) { regionOfInterest = temp; } else { log.info("Intersecting interval_list: ", intervalListFile, "."); regionOfInterest = IntervalList.intersection(regionOfInterest, temp); } } return regionOfInterest; }
/** * Reads Interprets intervals from the input INTERVALS, if there's a file with that name, it opens the file, otherwise * it tries to parse it, checks that their dictionaries all agree with the input SequenceDictionary and returns the * intersection of all the lists. * * @param sequenceDictionary a {@link SAMSequenceDictionary} to parse the intervals against. * @return the intersection of the interval lists pointed to by the input parameter INTERVALS */ private IntervalList getIntervals(final SAMSequenceDictionary sequenceDictionary) { IntervalList regionOfInterest = null; for (final File intervalListFile : INTERVALS) { if (!intervalListFile.exists()) { throw new IllegalArgumentException("Input file " + intervalListFile + " doesn't seem to exist. "); } log.info("Reading IntervalList ", intervalListFile, "."); final IntervalList temp = IntervalList.fromFile(intervalListFile); sequenceDictionary.assertSameDictionary(temp.getHeader().getSequenceDictionary()); if (regionOfInterest == null) { regionOfInterest = temp; } else { log.info("Intersecting interval_list: ", intervalListFile, "."); regionOfInterest = IntervalList.intersection(regionOfInterest, temp); } } return regionOfInterest; }
@Test(dataProvider = "intersectData") public void testIntersectIntervalLists(final List<IntervalList> lists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.intersection(lists).iterator()), CollectionUtil.makeCollection(list.iterator())); }
else if (INTERSECT_INTERVALS) intervals = IntervalList.intersection(intervals, tmpIntervalList); else intervals = IntervalList.union(intervals, tmpIntervalList);
else if (INTERSECT_INTERVALS) intervals = IntervalList.intersection(intervals, tmpIntervalList); else intervals = IntervalList.union(intervals, tmpIntervalList);