/// <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, () => Interval.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));
        }
Beispiel #2
0
        public void TranscriptRegion_EndToEnd()
        {
            var expectedResults = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 13, 100, 200, 300, 400),
                new TranscriptRegion(TranscriptRegionType.Gap, 0, 120, 230, 10, 20),
                new TranscriptRegion(TranscriptRegionType.Intron, 14, 130, 230, 330, 430)
            };

            var observedResults = new ITranscriptRegion[expectedResults.Length];

            using (var ms = new MemoryStream())
            {
                using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true))
                {
                    foreach (var region in expectedResults)
                    {
                        region.Write(writer);
                    }
                }

                ms.Position = 0;

                using (var reader = new BufferedBinaryReader(ms))
                {
                    for (int i = 0; i < expectedResults.Length; i++)
                    {
                        observedResults[i] = TranscriptRegion.Read(reader);
                    }
                }
            }

            var comparer = new TranscriptRegionComparer();

            Assert.Equal(expectedResults, observedResults, comparer);
        }