Пример #1
0
        public void TranscriptCacheReader_EndToEnd()
        {
            TranscriptCacheData observedCache;

            using (var ms = new MemoryStream())
            {
                using (var writer = new TranscriptCacheWriter(ms, _expectedHeader, true))
                {
                    writer.Write(_expectedCacheData);
                }

                ms.Position = 0;

                using (var reader = new TranscriptCacheReader(ms))
                {
                    observedCache = reader.Read(_refIndexToChromosome);
                }
            }

            Assert.NotNull(observedCache);
            Assert.Equal(_expectedCacheData.PeptideSeqs, observedCache.PeptideSeqs);
            CheckChromosomeIntervals(_expectedCacheData.Genes, observedCache.Genes);
            CheckIntervalArrays(_expectedCacheData.RegulatoryRegionIntervalArrays, observedCache.RegulatoryRegionIntervalArrays);
            CheckIntervalArrays(_expectedCacheData.TranscriptIntervalArrays, observedCache.TranscriptIntervalArrays);
            CheckIntervals(_expectedCacheData.TranscriptRegions, observedCache.TranscriptRegions);
            CheckIntervals(_expectedCacheData.Mirnas, observedCache.Mirnas);
        }
Пример #2
0
        public void ReadItems_EndToEnd()
        {
            var expectedStrings = new[] { "Huey", "Duey", "Louie" };

            string[] observedStrings;

            using (var ms = new MemoryStream())
            {
                // ReSharper disable AccessToDisposedClosure
                using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true))
                {
                    TranscriptCacheWriter.WriteItems(writer, expectedStrings, x => writer.WriteOptAscii(x));
                }

                ms.Position = 0;

                using (var reader = new ExtendedBinaryReader(ms))
                {
                    observedStrings = TranscriptCacheReader.ReadItems(reader, () => reader.ReadAsciiString());
                }
                // ReSharper restore AccessToDisposedClosure
            }

            Assert.NotNull(observedStrings);
            Assert.Equal(expectedStrings, observedStrings);
        }
Пример #3
0
        public void CreateIndex_EmptyDictionary_WhenInputNull()
        {
            var dict = TranscriptCacheWriter.CreateIndex(null, EqualityComparer <string> .Default);

            Assert.NotNull(dict);
            Assert.Empty(dict);
        }
Пример #4
0
        public void CreateIndex_PopulatedDictionary()
        {
            var strings = new[] { "A", "B", "D", "P", "Z" };
            var dict    = TranscriptCacheWriter.CreateIndex(strings, EqualityComparer <string> .Default);

            Assert.NotNull(dict);
            Assert.Equal(3, dict["P"]);
        }
Пример #5
0
        private static Stream GetCacheStream()
        {
            const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38;

            var baseHeader     = new Header("test", 2, 3, Source.BothRefSeqAndEnsembl, 4, genomeAssembly);
            var customHeader   = new TranscriptCacheCustomHeader(1, 2);
            var expectedHeader = new CacheHeader(baseHeader, customHeader);

            var transcriptRegions = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 100, 199, 300, 399),
                new TranscriptRegion(TranscriptRegionType.Intron, 1, 200, 299, 399, 400),
                new TranscriptRegion(TranscriptRegionType.Exon, 2, 300, 399, 400, 499)
            };

            var mirnas = new IInterval[2];

            mirnas[0] = new Interval(100, 200);
            mirnas[1] = new Interval(300, 400);

            var peptideSeqs = new[] { "MASE*" };

            var genes = new IGene[1];

            genes[0] = new Gene(ChromosomeUtilities.Chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"),
                                CompactId.Convert("ENSG00000141510"));

            var regulatoryRegions = new IRegulatoryRegion[2];

            regulatoryRegions[0] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1200, 1300, CompactId.Convert("123"), RegulatoryRegionType.enhancer);
            regulatoryRegions[1] = new RegulatoryRegion(ChromosomeUtilities.Chr3, 1250, 1450, CompactId.Convert("456"), RegulatoryRegionType.enhancer);
            var regulatoryRegionIntervalArrays = regulatoryRegions.ToIntervalArrays(3);

            var transcripts = GetTranscripts(ChromosomeUtilities.Chr3, genes, transcriptRegions, mirnas);
            var transcriptIntervalArrays = transcripts.ToIntervalArrays(3);

            var expectedCacheData = new TranscriptCacheData(expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs,
                                                            transcriptIntervalArrays, regulatoryRegionIntervalArrays);

            var ms = new MemoryStream();

            using (var writer = new TranscriptCacheWriter(ms, expectedHeader, true))
            {
                writer.Write(expectedCacheData);
            }

            ms.Position = 0;

            return(ms);
        }