Esempio n. 1
0
        public void Equals_SameIntervalStartAndEnd()
        {
            Interval <int> i1 = Interval.Create(5, 10);
            Interval <int> i2 = Interval.Create(5, 10);

            Assert.That(IntervalExtensions.Equals(i1, i2), Is.True);
        }
Esempio n. 2
0
        public void Equals_NullIntervalAndOther_ReturnsTrue()
        {
            Interval <int> i1 = null;
            Interval <int> i2 = null;

            Assert.That(IntervalExtensions.Equals(i1, i2), Is.True);
        }
Esempio n. 3
0
        public void Equals_DifferentIntervalStarts_ReturnsFalse()
        {
            Interval <int> i1 = Interval.Create(2, 10);
            Interval <int> i2 = Interval.Create(5, 10);

            Assert.That(IntervalExtensions.Equals(i1, i2), Is.False);
        }
Esempio n. 4
0
        public void Equals_NullOther_ReturnsFalse()
        {
            Interval <int> i1 = Interval.Create(5, 10);
            Interval <int> i2 = null;

            Assert.That(IntervalExtensions.Equals(i1, i2), Is.False);
        }
Esempio n. 5
0
        public void IsOverlapping_SameInterval_ReturnsTrue()
        {
            var interval = 10.IntervalTo(20);

            var output = IntervalExtensions.IsOverlapping(interval, interval);

            Assert.That(output, Is.True);
        }
Esempio n. 6
0
        public void Contains_WithTestCases_ProducesExpectedResults(int start, int end, int value, bool expected)
        {
            var interval = Interval.Create(start, end);

            var output = IntervalExtensions.Contains(interval, value);

            Assert.That(output, Is.EqualTo(expected));
        }
Esempio n. 7
0
        public void IsValid_WithTestCases_ProducesCorrectResults(int start, int end, bool expected)
        {
            var interval = new StupidInterval(start, end);

            var output = IntervalExtensions.IsValid(interval);

            Assert.That(output, Is.EqualTo(expected));
        }
Esempio n. 8
0
        public void IsOverlapping_WithTestCases_ProducesCorrectResults(int start1, int end1, int start2, int end2, bool expected)
        {
            Interval <int> interval = Interval.Create(start1, end1);
            Interval <int> other    = Interval.Create(start2, end2);

            var output = IntervalExtensions.IsOverlapping(interval, other);

            Assert.That(output, Is.EqualTo(expected));
        }
Esempio n. 9
0
        public void TryGetOverlappingIntervals_NullIntervalAndOther_ReturnsNull()
        {
            Interval <int> interval = null;
            Interval <int> other    = null;

            var output = IntervalExtensions.TryGetOverlappingInterval(interval, other);

            Assert.That(output, Is.Null);
        }
Esempio n. 10
0
        public void IsOverlapping_NullIntervalAndOther_ReturnsFalse()
        {
            Interval <int> interval = null;
            Interval <int> other    = null;

            var output = IntervalExtensions.IsOverlapping(interval, other);

            Assert.That(output, Is.False);
        }
Esempio n. 11
0
        /// <summary>
        /// parses the database cache file and populates the specified lists and interval trees
        /// </summary>
        public TranscriptCacheData Read(IDictionary <ushort, IChromosome> refIndexToChromosome)
        {
            var genes             = ReadItems(_reader, () => Gene.Read(_reader, refIndexToChromosome));
            var transcriptRegions = ReadItems(_reader, () => TranscriptRegion.Read(_reader));
            var mirnas            = ReadItems(_reader, () => IntervalExtensions.Read(_reader));
            var peptideSeqs       = ReadItems(_reader, () => _reader.ReadAsciiString());
            var regulatoryRegions = ReadIntervals(_reader, () => RegulatoryRegion.Read(_reader, refIndexToChromosome));
            var transcripts       = ReadIntervals(_reader, () => Transcript.Read(_reader, refIndexToChromosome, genes, transcriptRegions, mirnas, peptideSeqs));

            return(new TranscriptCacheData(Header, genes, transcriptRegions, mirnas, peptideSeqs, transcripts, regulatoryRegions));
        }
Esempio n. 12
0
 public void GetSpan_NullCases_ReturnsZero()
 {
     Assert.That(IntervalExtensions.GetSpan((IInterval <byte>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <short>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <int>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <long>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <double>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <float>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <decimal>)null), Is.EqualTo(0));
     Assert.That(IntervalExtensions.GetSpan((IInterval <DateTime>)null), Is.EqualTo(TimeSpan.Zero));
 }
Esempio n. 13
0
        public void TryGetOverlappingIntervals_WithTestCases_ProducesCorrectResults(int start1, int end1, int start2, int end2, int expectedStart, int expectedEnd)
        {
            Interval <int> interval = Interval.Create(start1, end1);
            Interval <int> other    = Interval.Create(start2, end2);

            Interval <int> expected = (expectedStart > expectedEnd) ? null : Interval.Create(expectedStart, expectedEnd);

            var output = IntervalExtensions.TryGetOverlappingInterval(interval, other);

            Assert.That(output, Is.EqualTo(expected).Using(IntervalEqualityComparer <int> .Default));
        }
Esempio n. 14
0
        public void Contains_NullInterval_ReturnsFalse()
        {
            var output = IntervalExtensions.Contains(null, 0);

            Assert.That(output, Is.False);
        }
Esempio n. 15
0
 public void IntervalToWithTag_StartAfterEnd_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => IntervalExtensions.IntervalTo(10, 5, "tag"));
 }
Esempio n. 16
0
 public void IsValid_NullInterval_ReturnsFalse()
 {
     Assert.That(IntervalExtensions.IsValid <int>(null), Is.False);
 }
Esempio n. 17
0
        public void IntervalToWithTag_StartLessThanEnd_ReturnsInterval()
        {
            var interval = IntervalExtensions.IntervalTo(5, 10, "tag");

            Assert.That(interval, Is.EqualTo(new Interval <int>(5, 10)).Using(IntervalEqualityComparer <int> .Default));
        }
Esempio n. 18
0
 public void Merge_NullIntervals_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => IntervalExtensions.Merge <int>(null));
 }