Пример #1
0
        public void Assign_WhenIntervalsNull_ReturnNull()
        {
            var sequence = new SimpleSequence("AAA");
            var codons   = Codons.GetCodons("A", "G", -1, -1, -1, -1, sequence);

            Assert.Equal("", codons.Reference);
            Assert.Equal("", codons.Alternate);
        }
Пример #2
0
        public void Assign_SNV()
        {
            var sequence = new Mock <ISequence>();

            sequence.SetupGet(x => x.Length).Returns(100);
            sequence.Setup(x => x.Substring(21, 2)).Returns("CA");

            var codons = Codons.GetCodons("A", "G", 24, 24, 8, 8, sequence.Object);

            Assert.Equal("caA", codons.Reference);
            Assert.Equal("caG", codons.Alternate);
        }
Пример #3
0
        public void Assign_SNV_SuffixLenTooBig()
        {
            var sequence = new Mock <ISequence>();

            sequence.SetupGet(x => x.Length).Returns(89);
            sequence.Setup(x => x.Substring(87, 1)).Returns("t");

            var codons = Codons.GetCodons("C", "T", 89, 89, 30, 30, sequence.Object);

            Assert.Equal("tC", codons.Reference);
            Assert.Equal("tT", codons.Alternate);
        }
Пример #4
0
        public void Assign_MNV()
        {
            var sequence = new Mock <ISequence>();

            sequence.SetupGet(x => x.Length).Returns(100);
            sequence.Setup(x => x.Substring(21, 2)).Returns("CA");
            sequence.Setup(x => x.Substring(28, 2)).Returns("GG");

            var codons = Codons.GetCodons("GTGCT", "ACCGA", 24, 28, 8, 10, sequence.Object);

            Assert.Equal("caGTGCTgg", codons.Reference);
            Assert.Equal("caACCGAgg", codons.Alternate);
        }
Пример #5
0
        public void GetCodons_OutOfRangeIndexes_Adjusted(int cdsStart, int cdsEnd, int proteinBegin, int proteinEnd, string expectedRefCodons)
        {
            var sequence = new Mock <ISequence>();

            sequence.SetupGet(x => x.Length).Returns(99);
            sequence.Setup(x => x.Substring(0, 0)).Returns("");
            sequence.Setup(x => x.Substring(0, 4)).Returns("ACGT");
            sequence.Setup(x => x.Substring(4, 2)).Returns("CA");
            sequence.Setup(x => x.Substring(94, 5)).Returns("GCTGA");
            sequence.Setup(x => x.Substring(93, 1)).Returns("G");

            var codons = Codons.GetCodons("", cdsStart, cdsEnd, proteinBegin, proteinEnd, sequence.Object);

            Assert.Equal(expectedRefCodons, codons.Reference);
        }
Пример #6
0
                        AltAminoAcids, string RefCodons, string AltCodons, string TranscriptAltAllele, string TranscriptRefAllele) AnnotateTranscript(ITranscript transcript, ISimpleVariant variant, AminoAcids aminoAcids, ISequence refSequence)
        {
            bool onReverseStrand = transcript.Gene.OnReverseStrand;
            var  start           = MappedPositionUtilities.FindRegion(transcript.TranscriptRegions, variant.Start);
            var  end             = MappedPositionUtilities.FindRegion(transcript.TranscriptRegions, variant.End);

            var position = GetMappedPosition(transcript.TranscriptRegions, start.Region, start.Index, end.Region,
                                             end.Index, variant, onReverseStrand, transcript.Translation?.CodingRegion, transcript.StartExonPhase,
                                             variant.Type == VariantType.insertion);

            var codingSequence = GetCodingSequence(transcript, refSequence);
            var cdnaSequence   = GetCdnaSequence(transcript, refSequence);

            string transcriptAltAllele = HgvsUtilities.GetTranscriptAllele(variant.AltAllele, onReverseStrand);
            var    codons = Codons.GetCodons(transcriptAltAllele, position.CdsStart, position.CdsEnd, position.ProteinStart, position.ProteinEnd, codingSequence);

            var aa = aminoAcids.Translate(codons.Reference, codons.Alternate);

            (aa, position.ProteinStart, position.ProteinEnd) = TryTrimAminoAcidsAndUpdateProteinPositions(aa, position.ProteinStart, position.ProteinEnd);

            (position.CoveredCdnaStart, position.CoveredCdnaEnd) = transcript.TranscriptRegions.GetCoveredCdnaPositions(position.CdnaStart, start.Index, position.CdnaEnd, end.Index, onReverseStrand);
            (position.CoveredCdsStart, position.CoveredCdsEnd, position.CoveredProteinStart, position.CoveredProteinEnd) = MappedPositionUtilities.GetCoveredCdsAndProteinPositions(position.CoveredCdnaStart, position.CoveredCdnaEnd, transcript.StartExonPhase, transcript.Translation?.CodingRegion);

            var            transcriptRefAllele = GetTranscriptRefAllele(position, cdnaSequence, variant, onReverseStrand);
            SequenceChange coveredAa;

            // only generate the covered version of ref & alt alleles when CDS start/end is -1
            if (position.CdsStart == -1 || position.CdsEnd == -1)
            {
                coveredAa = GetCoveredAa(aminoAcids, transcriptAltAllele, position.CoveredCdsStart, position.CoveredCdsEnd, position.CoveredProteinStart, position.CoveredProteinEnd, codingSequence);
                (coveredAa, position.CoveredProteinStart, position.CoveredProteinEnd) = TryTrimAminoAcidsAndUpdateProteinPositions(coveredAa, position.CoveredProteinStart, position.CoveredProteinEnd);
            }
            else
            {
                coveredAa = aa;
                position.CoveredProteinStart = position.ProteinStart;
                position.CoveredProteinEnd   = position.ProteinEnd;
            }


            var positionalEffect = GetPositionalEffect(transcript, variant, position, aa.Reference, aa.Alternate,
                                                       position.CoveredCdnaStart, position.CoveredCdnaEnd, position.CoveredCdsStart, position.CoveredCdsEnd);

            var variantEffect = new VariantEffect(positionalEffect, variant, transcript, aa.Reference, aa.Alternate,
                                                  codons.Reference, codons.Alternate, position.ProteinStart, coveredAa.Reference, coveredAa.Alternate);

            return(variantEffect, position, aa.Reference, aa.Alternate, codons.Reference, codons.Alternate, transcriptAltAllele, transcriptRefAllele);
        }
Пример #7
0
                         AltAminoAcids, string RefCodons, string AltCodons, string TranscriptAltAllele) AnnotateTranscript(ITranscript transcript, ISimpleVariant variant, AminoAcids aminoAcids,
                                                                                                                           ISequence refSequence)
        {
            var onReverseStrand = transcript.Gene.OnReverseStrand;
            var start           = MappedPositionUtilities.FindRegion(transcript.TranscriptRegions, variant.Start);
            var end             = MappedPositionUtilities.FindRegion(transcript.TranscriptRegions, variant.End);

            var position = GetMappedPosition(transcript.TranscriptRegions, start.Region, start.Index, end.Region,
                                             end.Index, variant, onReverseStrand, transcript.Translation?.CodingRegion, transcript.StartExonPhase,
                                             variant.Type == VariantType.insertion);

            var transcriptRefAllele = HgvsUtilities.GetTranscriptAllele(variant.RefAllele, onReverseStrand);
            var transcriptAltAllele = HgvsUtilities.GetTranscriptAllele(variant.AltAllele, onReverseStrand);

            var codingSequence = transcript.Translation == null
                ? null
                : new CodingSequence(refSequence, transcript.Translation.CodingRegion, transcript.TranscriptRegions,
                                     transcript.Gene.OnReverseStrand, transcript.StartExonPhase);

            var codons = Codons.GetCodons(transcriptRefAllele, transcriptAltAllele, position.CdsStart, position.CdsEnd,
                                          position.ProteinStart, position.ProteinEnd, codingSequence);

            var coveredCdna = transcript.TranscriptRegions.GetCoveredCdnaPositions(position.CdnaStart, start.Index,
                                                                                   position.CdnaEnd, end.Index, onReverseStrand);

            var coveredCds = MappedPositionUtilities.GetCoveredCdsPositions(coveredCdna.Start, coveredCdna.End,
                                                                            transcript.StartExonPhase, transcript.Translation?.CodingRegion);

            var aa = aminoAcids.Translate(codons.Reference, codons.Alternate);

            var positionalEffect = GetPositionalEffect(transcript, variant, position, aa.Reference, aa.Alternate,
                                                       coveredCdna.Start, coveredCdna.End, coveredCds.Start, coveredCds.End);

            var variantEffect = new VariantEffect(positionalEffect, variant, transcript, aa.Reference, aa.Alternate,
                                                  codons.Reference, codons.Alternate, position.ProteinStart);

            return(variantEffect, position, aa.Reference, aa.Alternate, codons.Reference, codons.Alternate,
                   transcriptAltAllele);
        }
        private static SequenceChange GetCoveredAa(AminoAcids aminoAcids, string transcriptAltAllele, int coveredCdsStart, int coveredCdsEnd, int coveredProteinStart, int coveredProteinEnd, ISequence codingSequence)
        {
            var codonsChange = Codons.GetCodons(transcriptAltAllele, coveredCdsStart, coveredCdsEnd, coveredProteinStart, coveredProteinEnd, codingSequence);

            return(aminoAcids.Translate(codonsChange.Reference, codonsChange.Alternate));
        }