public void ReadAndWriteTests()
        {
            using (var reader = new CustomIntervalReader(_randomPath))
            {
                var observedType    = reader.GetIntervalType();
                var observedRefName = reader.GetReferenceName();

                Assert.Equal(_intervalType, observedType);
                Assert.Equal("chr1", observedRefName);



                for (var i = 0; i < _totalIntervals; i++)
                {
                    var observedInterval = reader.GetNextCustomInterval();

                    Assert.Equal(_expectedCustomIntervals[i].ReferenceName, observedInterval.ReferenceName);
                    Assert.Equal(_expectedCustomIntervals[i].Start, observedInterval.Start);
                    Assert.Equal(_expectedCustomIntervals[i].End, observedInterval.End);
                    if (i > 0)
                    {
                        Assert.Equal(_expectedCustomIntervals[i].StringValues, observedInterval.StringValues);
                        Assert.Equal(_expectedCustomIntervals[i].NonStringValues, observedInterval.NonStringValues);
                    }
                    else
                    {
                        Assert.Null(observedInterval.StringValues);
                        Assert.Null(observedInterval.NonStringValues);
                    }
                }
            }
        }
Пример #2
0
        public int Extract()
        {
            var count    = 0;
            var interval = _reader.GetNextCustomInterval();

            while (interval != null)
            {
                if (Overlap.Partial(interval.Start, interval.End, _begin, _end))
                {
                    _writer.WriteInterval(interval);
                    count++;
                }

                interval = _reader.GetNextCustomInterval();
            }
            _writer.Dispose();
            return(count);
        }
        public void EndofFile()
        {
            // read the supplementary annotation file
            using (var reader = new CustomIntervalReader(_randomPath))
            {
                for (var i = 0; i < _totalIntervals; i++)
                {
                    reader.GetNextCustomInterval();
                }

                var observerdInterval = reader.GetNextCustomInterval();

                Assert.Null(observerdInterval);

                var observerdInterval2 = reader.GetNextCustomInterval();

                Assert.Null(observerdInterval2);
            }
        }
Пример #4
0
        public void ReadCustomIntervals()
        {
            var customFile   = new FileInfo(Resources.TopPath("chr1.nci"));
            var customReader = new CustomIntervalReader(customFile.FullName);
            var intervals    = new List <VariantAnnotation.DataStructures.CustomInterval>();

            var customInterval = customReader.GetNextCustomInterval();

            while (customInterval != null)
            {
                intervals.Add(customInterval);
                customInterval = customReader.GetNextCustomInterval();
            }

            Assert.Equal(11, intervals.Count); // 11 custom intervals were written.

            Assert.Equal(2, intervals[0].StringValues.Count);
            Assert.Equal(2, intervals[0].NonStringValues.Count);

            Assert.Equal("NOC2L", intervals[2].StringValues["gene"]);
        }
Пример #5
0
        public MockCustomIntervalProvider(Stream stream, ChromosomeRenamer renamer)
        {
            var intervals = new List <ICustomInterval>();

            using (var reader = new CustomIntervalReader(stream))
            {
                while (true)
                {
                    var interval = reader.GetNextCustomInterval();
                    if (interval == null)
                    {
                        break;
                    }
                    intervals.Add(interval);
                }
            }

            _hasIntervals   = intervals.Count > 0;
            _intervalForest = IntervalArrayFactory.CreateIntervalArray(intervals, renamer);
        }