public void GetAnnotatedTranscripts_ReturnEmptyList()
        {
            var variant     = new Mock <IVariant>();
            var transcript1 = new Mock <ITranscript>();
            var transcript2 = new Mock <ITranscript>();

            var transcripts = new[] { transcript1.Object, transcript2.Object };

            variant.SetupGet(x => x.Behavior).Returns(new AnnotationBehavior(true, false, false, true, false));
            variant.SetupGet(x => x.Start).Returns(123456);
            variant.SetupGet(x => x.End).Returns(123456);

            transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_046018.2"));
            transcript1.SetupGet(x => x.Start).Returns(108455);
            transcript1.SetupGet(x => x.End).Returns(118455);
            transcript1.SetupGet(x => x.Gene.Start).Returns(108455);
            transcript1.SetupGet(x => x.Gene.End).Returns(118455);

            transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_106918.1"));
            transcript2.SetupGet(x => x.Start).Returns(128460);
            transcript2.SetupGet(x => x.End).Returns(129489);
            transcript2.SetupGet(x => x.Gene.Start).Returns(128460);
            transcript2.SetupGet(x => x.Gene.End).Returns(129489);

            var compressedSequence = new Mock <ISequence>();

            var observedAnnotatedTranscripts =
                TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts,
                                                                    compressedSequence.Object, null, null);

            Assert.Empty(observedAnnotatedTranscripts);
        }
Esempio n. 2
0
        public void Translation_EndToEnd()
        {
            ICodingRegion expectedCodingRegion = new CodingRegion(100, 200, 300, 400, 101);
            const string  expectedProteinId    = "ENSP00000446475.7";
            const string  expectedPeptideSeq   = "VEIDSD";

            string[] peptideSeqs = { expectedPeptideSeq };

            ITranslation expectedTranslation =
                new Translation(expectedCodingRegion, CompactId.Convert(expectedProteinId, 7),
                                expectedPeptideSeq);

            ITranslation observedTranslation;

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

                ms.Position = 0;

                using (var reader = new BufferedBinaryReader(ms))
                {
                    observedTranslation = Translation.Read(reader, peptideSeqs);
                }
            }

            Assert.NotNull(observedTranslation);
            Assert.Equal(expectedCodingRegion.CdnaStart, observedTranslation.CodingRegion.CdnaStart);
            Assert.Equal(expectedProteinId, observedTranslation.ProteinId.WithVersion);
            Assert.Equal(expectedPeptideSeq, observedTranslation.PeptideSeq);
        }
        public void GetAnnotatedTranscripts_RohAnnotation_ReturnsCanonicalOnly()
        {
            var variant     = new Mock <IVariant>();
            var transcript1 = new Mock <ITranscript>();
            var transcript2 = new Mock <ITranscript>();

            var transcripts = new[] { transcript1.Object, transcript2.Object };

            variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.RohBehavior);
            variant.SetupGet(x => x.Start).Returns(10000);
            variant.SetupGet(x => x.End).Returns(20000);

            transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_123.1"));
            transcript1.SetupGet(x => x.Start).Returns(11000);
            transcript1.SetupGet(x => x.End).Returns(15000);
            transcript1.SetupGet(x => x.IsCanonical).Returns(true);

            transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_456.2"));
            transcript2.SetupGet(x => x.Start).Returns(11000);
            transcript2.SetupGet(x => x.End).Returns(15000);
            transcript2.SetupGet(x => x.IsCanonical).Returns(false);

            var observedAnnotatedTranscripts =
                TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, null, null, null);

            Assert.Single(observedAnnotatedTranscripts);
            Assert.Equal("NM_123", observedAnnotatedTranscripts[0].Transcript.Id.WithVersion);
        }
        public void refSeq_gene_return_entrezId()
        {
            var mockedTranscript = new Mock <ITranscript>();

            mockedTranscript.Setup(x => x.Source).Returns(Source.RefSeq);
            mockedTranscript.Setup(x => x.Gene.EntrezGeneId.ToString()).Returns("12345");
            mockedTranscript.Setup(x => x.Gene.Symbol).Returns("TestGene");
            mockedTranscript.Setup(x => x.Id).Returns(CompactId.Convert("NM_124"));
            mockedTranscript.Setup(x => x.Version).Returns(1);
            mockedTranscript.Setup(x => x.Translation.ProteinId).Returns(CompactId.Convert("NP_342"));
            mockedTranscript.Setup(x => x.Translation.ProteinVersion).Returns(2);



            var mappedPosition = new Mock <IMappedPositions>();

            mappedPosition.Setup(x => x.ProteinInterval).Returns(new NullableInterval(100, 101));
            var transcript = new PianoAnnotatedTranscript(mockedTranscript.Object, "AT", "GR", mappedPosition.Object, "KILGF", "ATYRGD",
                                                          new List <ConsequenceTag> {
                ConsequenceTag.missense_variant, ConsequenceTag.splice_region_variant
            });
            var expectedOut = "TestGene	12345	NM_124.1	NP_342.2	100-101	KILGF	AT/GR	ATYRGD	missense_variant,splice_region_variant";

            Assert.Equal(expectedOut, transcript.ToString());
        }
        public void Empty_upstreamAminoAcids_return_dot()
        {
            var mockedTranscript = new Mock <ITranscript>();

            mockedTranscript.Setup(x => x.Source).Returns(Source.Ensembl);
            mockedTranscript.Setup(x => x.Gene.EnsemblId.ToString()).Returns("ENSG12345");
            mockedTranscript.Setup(x => x.Gene.Symbol).Returns("TestGene");
            mockedTranscript.Setup(x => x.Id).Returns(CompactId.Convert("ENST124"));
            mockedTranscript.Setup(x => x.Version).Returns(1);
            mockedTranscript.Setup(x => x.Translation.ProteinId).Returns(CompactId.Convert("ENSP123456"));
            mockedTranscript.Setup(x => x.Translation.ProteinVersion).Returns(2);



            var mappedPosition = new Mock <IMappedPositions>();

            mappedPosition.Setup(x => x.ProteinInterval).Returns(new NullableInterval(100, 100));
            var transcript = new PianoAnnotatedTranscript(mockedTranscript.Object, "A", "R", mappedPosition.Object, "", "ATYRGD",
                                                          new List <ConsequenceTag> {
                ConsequenceTag.missense_variant
            });
            var expectedOut = "TestGene	ENSG12345	ENST124.1	ENSP123456.2	100	.	A/R	ATYRGD	missense_variant";

            Assert.Equal(expectedOut, transcript.ToString());
        }
Esempio n. 6
0
        public void regulatory_region_is_added()
        {
            var mockedRegulatory = new Mock <IAnnotatedRegulatoryRegion>();

            mockedRegulatory.SetupGet(x => x.Consequences).Returns(new List <ConsequenceTag> {
                ConsequenceTag.regulatory_region_variant
            });
            mockedRegulatory.SetupGet(x => x.RegulatoryRegion.Id).Returns(CompactId.Convert("ENSR12345"));

            var vcfFields = "chr1	101	sa123	A	.	.	.	.	.".Split("\t");
            var chrom     = new Chromosome("chr1", "1", 0);
            var inforData = new InfoData(null, null, VariantType.SNV, null, null, null, null, null, false, null, null,
                                         false, false, "Test=abc", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "." }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", ".", VariantType.reference, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.RegulatoryRegions.Add(mockedRegulatory.Object);

            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("Test=abc;CSQR=1|ENSR12345|regulatory_region_variant", observedVcf);
        }
Esempio n. 7
0
        public void CombineIdAndVersion(string id, byte version, string expectedVersion)
        {
            var compactId       = CompactId.Convert(id);
            var observedVersion = FormatUtilities.CombineIdAndVersion(compactId, version);

            Assert.Equal(expectedVersion, observedVersion);
        }
Esempio n. 8
0
        internal static ITranscript GetForwardTranscript()
        {
            // get info from ENST00000343938.4
            var regions = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 1260147, 1260482, 1, 336),
                new TranscriptRegion(TranscriptRegionType.Intron, 1, 1260483, 1262215, 336, 337),
                new TranscriptRegion(TranscriptRegionType.Exon, 2, 1262216, 1262412, 337, 533),
                new TranscriptRegion(TranscriptRegionType.Intron, 2, 1262413, 1262620, 533, 534),
                new TranscriptRegion(TranscriptRegionType.Exon, 3, 1262621, 1264277, 534, 2190)
            };

            var translation = new Mock <ITranslation>();

            translation.SetupGet(x => x.CodingRegion).Returns(new CodingRegion(1262291, 1263143, 412, 1056, 645));

            var transcript = new Mock <ITranscript>();

            transcript.SetupGet(x => x.Id).Returns(CompactId.Convert("ENST00000343938", 4));
            transcript.SetupGet(x => x.Chromosome).Returns(Chromosome);
            transcript.SetupGet(x => x.Start).Returns(1260147);
            transcript.SetupGet(x => x.End).Returns(1264277);
            transcript.SetupGet(x => x.Gene.OnReverseStrand).Returns(false);
            transcript.SetupGet(x => x.TranscriptRegions).Returns(regions);
            transcript.SetupGet(x => x.Translation).Returns(translation.Object);
            transcript.SetupGet(x => x.TotalExonLength).Returns(2190);
            return(transcript.Object);
        }
Esempio n. 9
0
        private static List <MutableGene> GetSh3RefSeqGenes()
        {
            ushort refIndex         = 1;
            var    geneId           = CompactId.Convert("344558");
            var    symbol           = "SH3RF3";
            var    hgncId           = -1;
            var    transcriptSource = TranscriptDataSource.RefSeq;

            return(new List <MutableGene>
            {
                new MutableGene
                {
                    ReferenceIndex = refIndex,
                    Start = 109745997,
                    End = 110107395,
                    OnReverseStrand = false,
                    Symbol = symbol,
                    HgncId = hgncId,
                    EntrezGeneId = geneId,
                    TranscriptDataSource = transcriptSource
                },
                new MutableGene
                {
                    ReferenceIndex = refIndex,
                    Start = 110259067,
                    End = 110262207,
                    OnReverseStrand = false,
                    Symbol = symbol,
                    HgncId = hgncId,
                    EntrezGeneId = geneId,
                    TranscriptDataSource = transcriptSource
                }
            });
        }
        public void GetAnnotatedTranscripts_ReturnEmptyList()
        {
            var variant     = new Mock <IVariant>();
            var transcript1 = new Mock <ITranscript>();
            var transcript2 = new Mock <ITranscript>();

            ITranscript[] transcripts = { transcript1.Object, transcript2.Object };

            variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.SmallVariants);
            variant.SetupGet(x => x.Chromosome.FlankingLength).Returns(Chromosome.ShortFlankingLength);
            variant.SetupGet(x => x.Start).Returns(123456);
            variant.SetupGet(x => x.End).Returns(123456);

            transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_046018.2"));
            transcript1.SetupGet(x => x.Start).Returns(108455);
            transcript1.SetupGet(x => x.End).Returns(118455);
            transcript1.SetupGet(x => x.Gene.Start).Returns(108455);
            transcript1.SetupGet(x => x.Gene.End).Returns(118455);

            transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_106918.1"));
            transcript2.SetupGet(x => x.Start).Returns(128460);
            transcript2.SetupGet(x => x.End).Returns(129489);
            transcript2.SetupGet(x => x.Gene.Start).Returns(128460);
            transcript2.SetupGet(x => x.Gene.End).Returns(129489);

            var compressedSequence = new Mock <ISequence>();

            IList <IAnnotatedTranscript> observedAnnotatedTranscripts =
                TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts,
                                                                    compressedSequence.Object, null, null);

            Assert.Empty(observedAnnotatedTranscripts);
        }
Esempio n. 11
0
 public void CombineIdAndVersion()
 {
     const string expectedResult = "ENSG00000141510.7";
     var id = CompactId.Convert("ENSG00000141510");
     var observedResult = FormatUtilities.CombineIdAndVersion(id, 7);
     Assert.Equal(expectedResult, observedResult);
 }
        public void GetAnnotatedTranscripts_RohAnnotation_ReturnsCanonicalOnly()
        {
            var variant     = new Mock <IVariant>();
            var transcript1 = new Mock <ITranscript>();
            var transcript2 = new Mock <ITranscript>();

            ITranscript[] transcripts = { transcript1.Object, transcript2.Object };

            variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.RunsOfHomozygosity);
            variant.SetupGet(x => x.Chromosome.FlankingLength).Returns(Chromosome.ShortFlankingLength);
            variant.SetupGet(x => x.Start).Returns(10000);
            variant.SetupGet(x => x.End).Returns(20000);

            transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_123.1"));
            transcript1.SetupGet(x => x.Start).Returns(11000);
            transcript1.SetupGet(x => x.End).Returns(15000);
            transcript1.SetupGet(x => x.IsCanonical).Returns(true);

            transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_456.2"));
            transcript2.SetupGet(x => x.Start).Returns(11000);
            transcript2.SetupGet(x => x.End).Returns(15000);
            transcript2.SetupGet(x => x.IsCanonical).Returns(false);

            IList <IAnnotatedTranscript> observedAnnotatedTranscripts =
                TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, null, null, null);

            Assert.Single(observedAnnotatedTranscripts);
            Assert.Equal("NM_123", observedAnnotatedTranscripts[0].Transcript.Id.WithVersion);
        }
Esempio n. 13
0
        public void CompactId_IO_EndToEnd()
        {
            const string expectedResults = "ENSP00000334393.3";
            var          id = CompactId.Convert("ENSP00000334393", 3);

            ICompactId observedId;

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

                ms.Position = 0;

                using (var reader = new BufferedBinaryReader(ms))
                {
                    observedId = CompactId.Read(reader);
                }
            }

            Assert.NotNull(observedId);
            Assert.Equal(expectedResults, observedId.WithVersion);
        }
Esempio n. 14
0
        private List <MutableGene> GetSrgap2CRefSeqGenes()
        {
            ushort refIndex         = 0;
            var    geneId           = CompactId.Convert("653464");
            var    symbol           = "SRGAP2C";
            var    hgncId           = -1;
            var    transcriptSource = TranscriptDataSource.RefSeq;

            return(new List <MutableGene>
            {
                new MutableGene
                {
                    ReferenceIndex = refIndex,
                    Start = 120835810,
                    End = 120838261,
                    OnReverseStrand = true,
                    Symbol = symbol,
                    HgncId = hgncId,
                    EntrezGeneId = geneId,
                    TranscriptDataSource = transcriptSource
                },
                new MutableGene
                {
                    ReferenceIndex = refIndex,
                    Start = 121107154,
                    End = 121131061,
                    OnReverseStrand = false,
                    Symbol = symbol,
                    HgncId = hgncId,
                    EntrezGeneId = geneId,
                    TranscriptDataSource = transcriptSource
                }
            });
        }
Esempio n. 15
0
        public void Convert_Unknown()
        {
            var id = CompactId.Convert("ABC123");

            Assert.True(id.IsEmpty());
            Assert.Null(id.WithVersion);
        }
Esempio n. 16
0
        internal static ITranscript GetReverseTranscript()
        {
            // get info from "ENST00000423372.3
            var regions = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 2, 134901, 135802, 1760, 2661),
                new TranscriptRegion(TranscriptRegionType.Intron, 1, 135803, 137620, 1759, 1760),
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 137621, 139379, 1, 1759)
            };

            var translation = new Mock <ITranslation>();

            translation.SetupGet(x => x.CodingRegion).Returns(new CodingRegion(138530, 139309, 71, 850, 780));

            var transcript = new Mock <ITranscript>();

            transcript.SetupGet(x => x.Id).Returns(CompactId.Convert("ENST00000423372", 3));
            transcript.SetupGet(x => x.Chromosome).Returns(Chromosome);
            transcript.SetupGet(x => x.Start).Returns(134901);
            transcript.SetupGet(x => x.End).Returns(139379);
            transcript.SetupGet(x => x.Gene.OnReverseStrand).Returns(true);
            transcript.SetupGet(x => x.TranscriptRegions).Returns(regions);
            transcript.SetupGet(x => x.Translation).Returns(translation.Object);
            transcript.SetupGet(x => x.TotalExonLength).Returns(2661);
            return(transcript.Object);
        }
Esempio n. 17
0
 public void Convert_OnlyNumbers_ThrowException_NumberTooLarge()
 {
     Assert.Throws <ArgumentOutOfRangeException>(delegate
     {
         // ReSharper disable once UnusedVariable
         var id = CompactId.Convert("268435456");
     });
 }
Esempio n. 18
0
        public void IsPredictedTranscript_ReturnsTrue()
        {
            var id  = CompactId.Convert("XM_005244780", 1);
            var id2 = CompactId.Convert("XR_005244780", 1);

            Assert.True(id.IsPredictedTranscript());
            Assert.True(id2.IsPredictedTranscript());
        }
Esempio n. 19
0
        /// <summary>
        /// parses the relevant data from each regulatory element
        /// </summary>
        public static IRegulatoryRegion Parse(ObjectValueNode objectValue, IChromosome chromosome)
        {
            int    start    = -1;
            int    end      = -1;
            string stableId = null;
            string type     = null;

            foreach (var node in objectValue.Values)
            {
                // sanity check: make sure we know about the keys are used for
                if (!KnownKeys.Contains(node.Key))
                {
                    throw new InvalidDataException($"Encountered an unknown key in the dumper regulatory element object: {node.Key}");
                }

                switch (node.Key)
                {
                case ImportKeys.AnalysisId:
                case ImportKeys.BoundLengths:
                case ImportKeys.CellTypeCount:
                case ImportKeys.CellTypes:
                case ImportKeys.DbId:
                case ImportKeys.DisplayLabel:
                case ImportKeys.EpigenomeCount:
                case ImportKeys.HasEvidence:
                case ImportKeys.Projected:
                case ImportKeys.RegulatoryBuildId:
                case ImportKeys.Set:
                case ImportKeys.Strand:
                case ImportKeys.Slice:
                case ImportKeys.VepFeatureType:
                    // not used
                    break;

                case ImportKeys.FeatureType:
                    type = node.GetString();
                    break;

                case ImportKeys.End:
                    end = node.GetInt32();
                    break;

                case ImportKeys.StableId:
                    stableId = node.GetString();
                    break;

                case ImportKeys.Start:
                    start = node.GetInt32();
                    break;

                default:
                    throw new InvalidDataException($"Unknown key found: {node.Key}");
                }
            }

            return(new RegulatoryRegion(chromosome, start, end, CompactId.Convert(stableId),
                                        RegulatoryRegionTypeHelper.GetRegulatoryRegionType(type)));
        }
Esempio n. 20
0
        public GeneComparerTests()
        {
            var chromosome = new Chromosome("chr1", "1", 0);

            _geneA        = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123"));
            _geneB        = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123"));
            _geneC        = new Gene(chromosome, 101, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123"));
            _geneComparer = new GeneComparer();
        }
Esempio n. 21
0
        public void RegulatoryFeatureEqualityTests()
        {
            var regulatoryFeature1 = new RegulatoryElement(2, 100, 200, CompactId.Convert("1"), RegulatoryElementType.promoter);
            var regulatoryFeature2 = new RegulatoryElement(2, 100, 200, CompactId.Convert("1"), RegulatoryElementType.promoter);
            var regulatoryFeature3 = new RegulatoryElement(4, 105, 201, CompactId.Convert("3"), RegulatoryElementType.CTCF_binding_site);

            Assert.Equal(regulatoryFeature1, regulatoryFeature2);
            Assert.False(regulatoryFeature1 == regulatoryFeature3);
        }
Esempio n. 22
0
 private static ITranscript[] GetTranscripts(IChromosome chromosome, IGene[] genes, ITranscriptRegion[] regions,
                                             IInterval[] mirnas)
 {
     return(new ITranscript[]
     {
         new Transcript(chromosome, 120, 180, CompactId.Convert("789"), null, BioType.IG_D_gene, genes[0], 0, 0,
                        false, regions, 0, mirnas, -1, -1, Source.None, false, false, null, null)
     });
 }
Esempio n. 23
0
        /// <summary>
        /// retrieves the next gene. Returns false if there are no more genes available
        /// </summary>
        public MutableGene Next()
        {
            // get the next line
            string line = _reader.ReadLine();

            if (line == null)
            {
                return(null);
            }

            var cols = line.Split('\t');

            if (cols.Length != 10)
            {
                throw new GeneralException($"Expected 10 columns but found {cols.Length} when parsing the gene entry.");
            }

            try
            {
                var referenceIndex  = ushort.Parse(cols[1]);
                var start           = int.Parse(cols[2]);
                var end             = int.Parse(cols[3]);
                var onReverseStrand = cols[4] == "R";
                var symbol          = cols[5];
                var hgnc            = cols[6];
                var entrezId        = CompactId.Convert(cols[7]);
                var ensemblId       = CompactId.Convert(cols[8]);
                var omimId          = int.Parse(cols[9]);

                var hgncId = hgnc == "" ? -1 : int.Parse(hgnc);

                var gene = new MutableGene
                {
                    ReferenceIndex       = referenceIndex,
                    Start                = start,
                    End                  = end,
                    OnReverseStrand      = onReverseStrand,
                    Symbol               = symbol,
                    HgncId               = hgncId,
                    EntrezGeneId         = entrezId,
                    EnsemblId            = ensemblId,
                    MimNumber            = omimId,
                    TranscriptDataSource = Header.TranscriptSource
                };

                return(gene);
            }
            catch (Exception)
            {
                Console.WriteLine("Offending line: {0}", line);
                for (int i = 0; i < cols.Length; i++)
                {
                    Console.WriteLine("- col {0}: [{1}]", i, cols[i]);
                }
                throw;
            }
        }
Esempio n. 24
0
        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));
        }
Esempio n. 25
0
        private static void AddTranscript(IAnnotatedVariant annotatedVariant)
        {
            var annotatedTranscript = new Mock <IAnnotatedTranscript>();

            annotatedTranscript.SetupGet(x => x.Transcript.Id).Returns(CompactId.Convert("ENST00000540021"));
            annotatedTranscript.SetupGet(x => x.Transcript.Start).Returns(966300);
            annotatedTranscript.SetupGet(x => x.Transcript.End).Returns(966405);
            annotatedTranscript.SetupGet(x => x.AlternateCodons).Returns("cAt/cGt");

            annotatedVariant.EnsemblTranscripts.Add(annotatedTranscript.Object);
        }
Esempio n. 26
0
        public void Convert_NullInput_ReturnsEmptyId()
        {
            var id = CompactId.Convert(null);

            Assert.True(id.IsEmpty());
            Assert.Null(id.WithVersion);

            id = CompactId.Convert(string.Empty);
            Assert.True(id.IsEmpty());
            Assert.Null(id.WithVersion);
        }
Esempio n. 27
0
        public void Only_canonical_transcripts_are_reported_in_vcf()
        {
            var mockedTranscript1 = new Mock <IAnnotatedTranscript>();

            mockedTranscript1.Setup(x => x.Transcript.IsCanonical).Returns(true);
            mockedTranscript1.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("ENST12345", 1));
            mockedTranscript1.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene1");
            mockedTranscript1.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.five_prime_UTR_variant
            });

            var mockedTranscript2 = new Mock <IAnnotatedTranscript>();

            mockedTranscript2.Setup(x => x.Transcript.IsCanonical).Returns(false);
            mockedTranscript2.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("ENST23456", 2));
            mockedTranscript2.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene2");
            mockedTranscript2.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.missense_variant
            });

            var mockedTranscript3 = new Mock <IAnnotatedTranscript>();

            mockedTranscript3.Setup(x => x.Transcript.IsCanonical).Returns(true);
            mockedTranscript3.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("NM_1234", 3));
            mockedTranscript3.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene3");
            mockedTranscript3.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.missense_variant, ConsequenceTag.splice_region_variant
            });


            var vcfFields = "chr1	101	sa123	A	T	.	.	.".Split("\t");
            var chrom     = new Chromosome("chr1", "1", 0);
            var inforData = new InfoData(null, null, VariantType.SNV, null, null, null, null, null, false, null, null,
                                         false, false, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.EnsemblTranscripts.Add(mockedTranscript1.Object);
            annotatedVariant.EnsemblTranscripts.Add(mockedTranscript2.Object);
            annotatedVariant.RefSeqTranscripts.Add(mockedTranscript3.Object);

            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("CSQT=1|testGene1|ENST12345.1|5_prime_UTR_variant,1|testGene3|NM_1234.3|missense_variant&splice_region_variant", observedVcf);
        }
Esempio n. 28
0
        public void IsPredictedTranscript_ReturnsFalse()
        {
            var id  = CompactId.Convert("XP_005244780", 1);
            var id2 = CompactId.Convert("NM_005244780", 1);
            var id3 = CompactId.Convert("NR_074509", 1);
            var id4 = CompactId.Convert("NP_001025056", 1);

            Assert.False(id.IsPredictedTranscript());
            Assert.False(id2.IsPredictedTranscript());
            Assert.False(id3.IsPredictedTranscript());
            Assert.False(id4.IsPredictedTranscript());
        }
Esempio n. 29
0
        public void ComputeGeneFusions_ReturnNull_NoFusions()
        {
            var chromosome    = new Chromosome("chr1", "1", 0);
            var chromosome2   = new Chromosome("chr6", "6", 5);
            var transcriptId  = CompactId.Convert("ENST00000491426", 2);
            var transcriptId2 = CompactId.Convert("ENST00000313382", 9);

            var breakEnds = new IBreakEnd[]
            {
                new BreakEnd(chromosome, chromosome2, 31410878, 42248252, true, false)
            };

            var transcriptRegions = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 144890592, 144904679, 1, 670)
            };

            var transcriptRegions2 = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 144851424, 145040002, 1, 8150)
            };

            var transcript = new Mock <ITranscript>();

            transcript.SetupGet(x => x.Chromosome).Returns(chromosome);
            transcript.SetupGet(x => x.Gene.OnReverseStrand).Returns(true);
            transcript.SetupGet(x => x.Gene.Symbol).Returns("PDE4DIP");
            transcript.SetupGet(x => x.Translation.CodingRegion).Returns(new CodingRegion(144890975, 144904679, 1, 287, 287));
            transcript.SetupGet(x => x.Start).Returns(144890592);
            transcript.SetupGet(x => x.End).Returns(144904679);
            transcript.SetupGet(x => x.Source).Returns(Source.Ensembl);
            transcript.SetupGet(x => x.Id).Returns(transcriptId);
            transcript.SetupGet(x => x.TranscriptRegions).Returns(transcriptRegions);

            var transcript2 = new Mock <ITranscript>();

            transcript2.SetupGet(x => x.Chromosome).Returns(chromosome2);
            transcript2.SetupGet(x => x.Gene.OnReverseStrand).Returns(true);
            transcript2.SetupGet(x => x.Gene.Symbol).Returns("PDE4DIP");
            transcript2.SetupGet(x => x.Translation.CodingRegion).Returns(new CodingRegion(144852458, 145039609, 394, 7116, 6723));
            transcript2.SetupGet(x => x.Start).Returns(144852458);
            transcript2.SetupGet(x => x.End).Returns(145039609);
            transcript2.SetupGet(x => x.Source).Returns(Source.Ensembl);
            transcript2.SetupGet(x => x.Id).Returns(transcriptId2);
            transcript2.SetupGet(x => x.TranscriptRegions).Returns(transcriptRegions2);

            var fusedTranscriptCandidates = new[] { transcript2.Object };

            var observedResult = GeneFusionUtilities.GetGeneFusionAnnotation(breakEnds, transcript.Object, fusedTranscriptCandidates);

            Assert.Null(observedResult);
        }
Esempio n. 30
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);
        }