private void AddRegulatoryRegion(IAnnotatedVariant annotatedVariant)
        {
            var regulatoryRegion = new RegulatoryRegion(_chromosome, 103, 104, CompactId.Convert("7157"),
                                                        RegulatoryRegionType.TF_binding_site);
            var consequences = new List <ConsequenceTag> {
                ConsequenceTag.regulatory_region_amplification
            };

            annotatedVariant.RegulatoryRegions.Add(new AnnotatedRegulatoryRegion(regulatoryRegion, consequences));
        }
        /// <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 #3
0
 private IRegulatoryRegion[] GetRegulatoryRegions()
 {
     var regulatoryRegions = new IRegulatoryRegion[7];
     regulatoryRegions[0] = new RegulatoryRegion(_chr17, 100,200,CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[1] = new RegulatoryRegion(_chr17, 200, 300, CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[2] = new RegulatoryRegion(_chr17, 300, 400, CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[3] = new RegulatoryRegion(_chr1, 1000, 2000, CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[4] = new RegulatoryRegion(_chr1, 2000, 3000, CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[5] = new RegulatoryRegion(_chr11, 150, 250, CompactId.Empty, RegulatoryRegionType.enhancer);
     regulatoryRegions[6] = new RegulatoryRegion(_chr11, 250, 350, CompactId.Empty, RegulatoryRegionType.enhancer);
     return regulatoryRegions;
 }
Beispiel #4
0
        public TranscriptCacheReaderTests()
        {
            var chr1 = new Chromosome("chr1", "1", 0);
            var chr2 = new Chromosome("chr2", "2", 1);
            var chr3 = new Chromosome("chr3", "3", 2);

            _refIndexToChromosome = new Dictionary <ushort, IChromosome>
            {
                [chr1.Index] = chr1,
                [chr2.Index] = chr2,
                [chr3.Index] = chr3
            };

            const GenomeAssembly genomeAssembly = GenomeAssembly.GRCh38;

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

            _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(chr3, 100, 200, true, "TP53", 300, CompactId.Convert("7157"),
                                CompactId.Convert("ENSG00000141510"));

            var regulatoryRegions = new IRegulatoryRegion[2];

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

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

            _expectedCacheData = new TranscriptCacheData(_expectedHeader, genes, transcriptRegions, mirnas, peptideSeqs,
                                                         transcriptIntervalArrays, regulatoryRegionIntervalArrays);
        }
Beispiel #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);
        }
        private IRegulatoryRegion[] GetRegulatoryRegions()
        {
            var regulatoryRegions = new IRegulatoryRegion[3];

            regulatoryRegions[0] = new RegulatoryRegion(_chr11, 11000, 12000, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            regulatoryRegions[1] = new RegulatoryRegion(_chr1, 120, 180, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            regulatoryRegions[2] = new RegulatoryRegion(_chr1, 300, 320, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            return(regulatoryRegions);
        }
Beispiel #7
0
        private static IRegulatoryRegion[] GetRegulatoryRegions()
        {
            var regulatoryRegions = new IRegulatoryRegion[3];

            regulatoryRegions[0] = new RegulatoryRegion(ChromosomeUtilities.Chr11, 11000, 12000, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            regulatoryRegions[1] = new RegulatoryRegion(ChromosomeUtilities.Chr1, 120, 180, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            regulatoryRegions[2] = new RegulatoryRegion(ChromosomeUtilities.Chr1, 300, 320, CompactId.Empty,
                                                        RegulatoryRegionType.promoter);

            return(regulatoryRegions);
        }
Beispiel #8
0
        public void RegulatoryRegion_EndToEnd()
        {
            IChromosome  expectedChromosome         = new Chromosome("chrBob", "Bob", 1);
            const int    expectedStart              = int.MaxValue;
            const int    expectedEnd                = int.MinValue;
            const string expectedId                 = "ENST00000540021";
            const RegulatoryRegionType expectedType = RegulatoryRegionType.open_chromatin_region;

            var indexToChromosome = new Dictionary <ushort, IChromosome>
            {
                [expectedChromosome.Index] = expectedChromosome
            };

            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            var regulatoryRegion = new RegulatoryRegion(expectedChromosome, expectedStart, expectedEnd,
                                                        CompactId.Convert(expectedId), expectedType);
            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            IRegulatoryRegion observedRegulatoryRegion;

            using (var ms = new MemoryStream())
            {
                using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true))
                {
                    regulatoryRegion.Write(writer);
                }

                ms.Position = 0;

                using (var reader = new ExtendedBinaryReader(ms))
                {
                    observedRegulatoryRegion = RegulatoryRegion.Read(reader, indexToChromosome);
                }
            }

            Assert.NotNull(observedRegulatoryRegion);
            Assert.Equal(expectedStart, observedRegulatoryRegion.Start);
            Assert.Equal(expectedEnd, observedRegulatoryRegion.End);
            Assert.Equal(expectedId, observedRegulatoryRegion.Id.WithoutVersion);
            Assert.Equal(expectedType, observedRegulatoryRegion.Type);
            Assert.Equal(expectedChromosome.Index, observedRegulatoryRegion.Chromosome.Index);
        }