@Override IntervalList act(final List<IntervalList> list1, final List<IntervalList> list2) { return IntervalList.subtract(list1, list2); } },
@Override IntervalList act(final List<IntervalList> list1, final List<IntervalList> list2) { return IntervalList.subtract(list1, list2); } },
/** * A utility function for subtracting a single IntervalList from another. Resulting loci are those that are in the first List * but not the second. * * @param lhs the IntervalList from which to subtract intervals * @param rhs the IntervalList to subtract * @return an IntervalList comprising all loci that are in first IntervalList but not the second. lhs-rhs=answer */ public static IntervalList subtract(final IntervalList lhs, final IntervalList rhs) { return subtract(Collections.singletonList(lhs), Collections.singletonList(rhs)); }
/** * A utility function for finding the difference between two IntervalLists. * * @param lists1 the first collection of IntervalLists * @param lists2 the second collection of IntervalLists * @return the difference between the two intervals, i.e. the loci that are only in one IntervalList but not both */ public static IntervalList difference(final Collection<IntervalList> lists1, final Collection<IntervalList> lists2) { return union( subtract(lists1, lists2), subtract(lists2, lists1)); }
/** * A utility function for finding the difference between two IntervalLists. * * @param lists1 the first collection of IntervalLists * @param lists2 the second collection of IntervalLists * @return the difference between the two intervals, i.e. the loci that are only in one IntervalList but not both */ public static IntervalList difference(final Collection<IntervalList> lists1, final Collection<IntervalList> lists2) { return union( subtract(lists1, lists2), subtract(lists2, lists1)); }
/** * A utility function for subtracting a single IntervalList from another. Resulting loci are those that are in the first List * but not the second. * * @param lhs the IntervalList from which to subtract intervals * @param rhs the IntervalList to subtract * @return an IntervalList comprising all loci that are in first IntervalList but not the second. lhs-rhs=answer */ public static IntervalList subtract(final IntervalList lhs, final IntervalList rhs) { return subtract(Collections.singletonList(lhs), Collections.singletonList(rhs)); }
/** * A utility function for finding the difference between two IntervalLists. * * @param lists1 the first collection of IntervalLists * @param lists2 the second collection of IntervalLists * @return the difference between the two intervals, i.e. the loci that are only in one IntervalList but not both */ public static IntervalList difference(final Collection<IntervalList> lists1, final Collection<IntervalList> lists2) { return union( subtract(lists1, lists2), subtract(lists2, lists1)); }
@Test(dataProvider = "subtractSingletonData") public void testSubtractSingletonAsListIntervalList(final IntervalList fromLists, final IntervalList whatLists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.subtract(Collections.singletonList(fromLists), Collections.singletonList(whatLists)).iterator()), CollectionUtil.makeCollection(list.iterator())); }
@Test(dataProvider = "subtractData") public void testSubtractIntervalLists(final List<IntervalList> fromLists, final List<IntervalList> whatLists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.subtract(fromLists, whatLists).iterator()), CollectionUtil.makeCollection(list.iterator())); }
@Test(dataProvider = "subtractSingletonData") public void testSubtractSingletonIntervalLists(final IntervalList fromLists, final IntervalList whatLists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.subtract(fromLists, whatLists).iterator()), CollectionUtil.makeCollection(list.iterator())); }
@Test(expectedExceptions = IllegalArgumentException.class) public void changeHeader() { SAMFileHeader clonedHeader = fileHeader.clone(); clonedHeader.addSequence(new SAMSequenceRecord("4", 1000)); IntervalList usingClone1 = new IntervalList(clonedHeader); usingClone1.add(new Interval("4", 1, 100)); IntervalList usingClone2 = new IntervalList(clonedHeader); usingClone2.add(new Interval("4", 10, 20)); IntervalList expected = new IntervalList(clonedHeader); expected.add(new Interval("4", 1, 9)); expected.add(new Interval("4", 21, 100)); //pull rug from underneath (one call will change all the headers, since there's actually only one) usingClone1.getHeader().setSequenceDictionary(fileHeader.getSequenceDictionary()); //now interval lists are in "illegal state" since they contain contigs that are not in the header. //this next step should fail IntervalList.subtract(usingClone1, usingClone2); Assert.assertTrue(false); }