Exemplo n.º 1
0
        public void IsFivePrimeUtrVariant(bool onReverseStrand, bool withinCdna, bool beforeCoding, bool afterCoding,
                                          bool expectedResult)
        {
            var positionalEffect = new TranscriptPositionalEffect
            {
                BeforeCoding = beforeCoding,
                AfterCoding  = afterCoding,
                WithinCdna   = withinCdna
            };

            var variant    = new Mock <ISimpleVariant>();
            var transcript = new Mock <ITranscript>();

            variant.SetupGet(x => x.AltAllele).Returns("G");
            variant.SetupGet(x => x.RefAllele).Returns("C");

            var variantEffect = new VariantEffect(positionalEffect, variant.Object, transcript.Object, "", "", "", "",
                                                  null, "", "");

            var gene = new Mock <IGene>();

            transcript.SetupGet(x => x.Gene).Returns(gene.Object);
            gene.SetupGet(x => x.OnReverseStrand).Returns(onReverseStrand);

            var translation = new Mock <ITranslation>();

            transcript.SetupGet(x => x.Translation).Returns(translation.Object);

            Assert.Equal(expectedResult, variantEffect.IsFivePrimeUtrVariant());
        }
Exemplo n.º 2
0
        private static List <ConsequenceTag> GetConsequences(ITranscript transcript, IVariant variant,
                                                             VariantEffect variantEffect)
        {
            var featureEffect = new FeatureVariantEffects(transcript, variant.Type, variant,
                                                          variant.Behavior.StructuralVariantConsequence);

            var consequence = new Consequences(variantEffect, featureEffect);

            consequence.DetermineSmallVariantEffects();
            return(consequence.GetConsequences());
        }
Exemplo n.º 3
0
        private static VariantEffect GetVariantEffect(ITranscript transcript, ISimpleVariant variant, IMappedPositions mappedPositions, string refAminoAcids, string altAminoAcids, string refCodons, string altCodons, bool insertionInStartAndNoImpact)
        {
            var positionalEffect = new TranscriptPositionalEffect();

            positionalEffect.DetermineIntronicEffect(transcript.Introns, variant, variant.Type);
            positionalEffect.DetermineExonicEffect(transcript, variant, mappedPositions, variant.AltAllele, insertionInStartAndNoImpact);

            var variantEffect = new VariantEffect(positionalEffect, variant, transcript, refAminoAcids,
                                                  altAminoAcids,
                                                  refCodons, altCodons, mappedPositions.ProteinInterval.Start);

            return(variantEffect);
        }
Exemplo n.º 4
0
        /// <summary>
        /// constructor
        /// </summary>
        public HgvsProteinNomenclature(VariantEffect variantEffect, TranscriptAnnotation ta, Transcript transcript,
                                       VariantFeature variant, ICompressedSequence compressedSequence, AminoAcids aminoAcids)
        {
            _variantEffect      = variantEffect;
            _ta                 = ta;
            _transcript         = transcript;
            _variant            = variant;
            _compressedSequence = compressedSequence;
            _aminoAcids         = aminoAcids;

            _hgvsNotation = new HgvsNotation(_ta.ReferenceAminoAcids, _ta.AlternateAminoAcids,
                                             FormatUtilities.CombineIdAndVersion(_transcript.Translation.ProteinId, _transcript.Translation.ProteinVersion),
                                             _ta.ProteinBegin, _ta.ProteinEnd);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void IsStopLost_DeletionOverStopCodon_ReturnTrue()
        {
            var positionalEffect = new TranscriptPositionalEffect
            {
                BeforeCoding = false,
                AfterCoding  = true,
                WithinCdna   = true
            };

            var variant = new Mock <ISimpleVariant>();

            variant.SetupGet(x => x.AltAllele).Returns("ATAGCCC");
            variant.SetupGet(x => x.RefAllele).Returns("A");

            var variantEffect = new VariantEffect(positionalEffect, variant.Object, null, "", "", "", "",
                                                  null, "*", "X");

            Assert.True(variantEffect.IsStopLost());
        }
Exemplo n.º 7
0
        public void IsStartRetainedVariant(int proteinBegin, string refAminoAcids, string altAminoAcids, string refAllele, string altAllele, bool isStartRetained)
        {
            var variant    = new Mock <ISimpleVariant>();
            var transcript = new Mock <ITranscript>();

            variant.SetupGet(x => x.AltAllele).Returns(refAllele);
            variant.SetupGet(x => x.RefAllele).Returns(altAllele);

            var variantEffect = new VariantEffect(null, variant.Object, transcript.Object, refAminoAcids, altAminoAcids, "", "",
                                                  proteinBegin, refAminoAcids, altAminoAcids);

            if (isStartRetained)
            {
                Assert.True(variantEffect.IsStartRetained());
            }
            else
            {
                Assert.False(variantEffect.IsStartRetained());
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void IsCodingSequenceVariant_WithMoreSpecificConsequence_ReturnFalse(ConsequenceTag ct)
        {
            var positionalEffect = new TranscriptPositionalEffect
            {
                BeforeCoding = false,
                AfterCoding  = true,
                WithinCdna   = true
            };

            var cache = new VariantEffectCache();

            cache.Add(ct, true);
            var variant = new Mock <ISimpleVariant>();

            variant.SetupGet(x => x.AltAllele).Returns("ATAGCCC");
            variant.SetupGet(x => x.RefAllele).Returns("A");

            var variantEffect = new VariantEffect(positionalEffect, variant.Object, null, "", "", "", "",
                                                  null, null, null, cache);

            Assert.False(variantEffect.IsCodingSequenceVariant());
        }
Exemplo n.º 10
0
        public void IsSpliceDonorVariant(bool onReverseStrand, bool isStartSpliceSite, bool isEndSpliceSite, bool expectedResult)
        {
            var positionalEffect = new TranscriptPositionalEffect
            {
                IsStartSpliceSite = isStartSpliceSite,
                IsEndSpliceSite   = isEndSpliceSite
            };

            var variant    = new Mock <ISimpleVariant>();
            var transcript = new Mock <ITranscript>();

            variant.SetupGet(x => x.AltAllele).Returns("G");
            variant.SetupGet(x => x.RefAllele).Returns("C");

            var variantEffect = new VariantEffect(positionalEffect, variant.Object, transcript.Object, "", "", "", "",
                                                  null, "", "");

            var gene = new Mock <IGene>();

            transcript.SetupGet(x => x.Gene).Returns(gene.Object);
            gene.SetupGet(x => x.OnReverseStrand).Returns(onReverseStrand);

            Assert.Equal(expectedResult, variantEffect.IsSpliceDonorVariant());
        }
Exemplo n.º 11
0
        public static string GetHgvsProteinAnnotation(
            ITranscript transcript,
            string refAminoAcids,
            string altAminoAcids,
            string transcriptAltAllele,
            IMappedPosition position,
            VariantEffect variantEffect,
            ISimpleVariant variant,
            ISequence refSequence,
            string hgvscNotation,
            bool isMitochondrial)
        {
            if (IsHgvspNull(transcriptAltAllele, position.CdsStart, position.CdsEnd, variant, hgvscNotation))
            {
                return(null);
            }

            var peptideSeq = transcript.Translation.PeptideSeq;

            // Amino acid seq should never go past the stop codon
            refAminoAcids = !refAminoAcids.EndsWith(AminoAcids.StopCodon) && refAminoAcids.Contains(AminoAcids.StopCodon)
                ? refAminoAcids.OptimizedSplit(AminoAcids.StopCodon[0])[0] + AminoAcids.StopCodon
                : refAminoAcids;

            int proteinStart = position.ProteinStart;

            HgvsUtilities.ShiftAndRotateAlleles(ref proteinStart, ref refAminoAcids, ref altAminoAcids, peptideSeq);

            var end             = proteinStart + refAminoAcids.Length - 1;
            var refAbbreviation = AminoAcids.GetAbbreviations(refAminoAcids);
            var altAbbreviation = AminoAcids.GetAbbreviations(altAminoAcids);

            var proteinId     = transcript.Translation.ProteinId.WithVersion;
            var proteinChange = GetProteinChange(proteinStart, refAminoAcids, altAminoAcids, peptideSeq, variantEffect);

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (proteinChange)
            {
            case ProteinChange.Substitution:
                return(HgvspNotation.GetSubstitutionNotation(proteinId, proteinStart, refAbbreviation, altAbbreviation));

            case ProteinChange.Unknown:
                return(HgvspNotation.GetUnknownNotation(proteinId, proteinStart, end, refAbbreviation, altAbbreviation));

            case ProteinChange.Deletion:
                return(HgvspNotation.GetDeletionNotation(proteinId, proteinStart, end, refAbbreviation, variantEffect.IsStopGained()));

            case ProteinChange.Duplication:
                proteinStart -= altAminoAcids.Length;
                return(HgvspNotation.GetDuplicationNotation(proteinId, proteinStart, end, altAbbreviation));

            case ProteinChange.Frameshift:
                return(GetHgvsFrameshiftNotation(refSequence, position.CdsStart, position.CdsEnd, transcriptAltAllele,
                                                 transcript, isMitochondrial, proteinId, proteinStart, end));

            case ProteinChange.None:
                return(HgvspNotation.GetSilentNotation(hgvscNotation, proteinStart, refAbbreviation, variantEffect.IsStopRetained()));

            case ProteinChange.DelIns:
                return(HgvspNotation.GetDelInsNotation(proteinId, proteinStart, end, refAbbreviation, altAbbreviation));

            case ProteinChange.Insertion:
                Swap.Int(ref proteinStart, ref end);
                return(HgvspNotation.GetInsertionNotation(proteinId, proteinStart, end, altAbbreviation, peptideSeq));

            case ProteinChange.Extension:
                var altPeptideSequence = HgvsUtilities.GetAltPeptideSequence(refSequence, position.CdsStart, position.CdsEnd,
                                                                             transcriptAltAllele, transcript, isMitochondrial);
                altAbbreviation = proteinStart <= altPeptideSequence.Length ? AminoAcids.ConvertAminoAcidToAbbreviation(altPeptideSequence[proteinStart - 1]): "Ter";
                var countToStop = HgvsUtilities.GetNumAminoAcidsUntilStopCodon(altPeptideSequence, peptideSeq, proteinStart - 1, false);

                return(HgvspNotation.GetExtensionNotation(proteinId, proteinStart, refAbbreviation, altAbbreviation, countToStop));

            case ProteinChange.StartLost:
                return(HgvspNotation.GetStartLostNotation(proteinId, proteinStart, end, refAbbreviation));
            }

            return(null);
        }
Exemplo n.º 12
0
        public void DetermineSmallVariantEffects_tier3()
        {
            var cache = new VariantEffectCache();

            cache.Add(ConsequenceTag.mature_miRNA_variant, false);

            cache.Add(ConsequenceTag.splice_donor_variant, true);
            cache.Add(ConsequenceTag.splice_acceptor_variant, true);
            cache.Add(ConsequenceTag.stop_gained, true);
            cache.Add(ConsequenceTag.frameshift_variant, true);
            cache.Add(ConsequenceTag.stop_lost, true);
            cache.Add(ConsequenceTag.start_lost, true);
            cache.Add(ConsequenceTag.inframe_insertion, true);
            cache.Add(ConsequenceTag.inframe_deletion, true);
            cache.Add(ConsequenceTag.missense_variant, true);
            cache.Add(ConsequenceTag.protein_altering_variant, true);
            cache.Add(ConsequenceTag.splice_region_variant, true);
            cache.Add(ConsequenceTag.incomplete_terminal_codon_variant, true);
            cache.Add(ConsequenceTag.stop_retained_variant, true);
            cache.Add(ConsequenceTag.synonymous_variant, true);
            cache.Add(ConsequenceTag.coding_sequence_variant, true);
            cache.Add(ConsequenceTag.five_prime_UTR_variant, true);
            cache.Add(ConsequenceTag.three_prime_UTR_variant, true);
            cache.Add(ConsequenceTag.non_coding_transcript_exon_variant, true);
            cache.Add(ConsequenceTag.intron_variant, true);
            cache.Add(ConsequenceTag.NMD_transcript_variant, true);
            cache.Add(ConsequenceTag.non_coding_transcript_variant, true);


            var simpleVariant = new Mock <ISimpleVariant>();

            simpleVariant.SetupGet(x => x.RefAllele).Returns("G");
            simpleVariant.SetupGet(x => x.AltAllele).Returns("C");

            var positionalEffect = new TranscriptPositionalEffect
            {
                IsWithinIntron = true
            };
            var variantEffect = new VariantEffect(positionalEffect, simpleVariant.Object, null, null, null, null, null, null, cache);

            var featureEffect = new Mock <IFeatureVariantEffects>();

            featureEffect.Setup(x => x.Ablation()).Returns(false);
            featureEffect.Setup(x => x.Amplification()).Returns(false);
            featureEffect.Setup(x => x.Truncation()).Returns(true);
            featureEffect.Setup(x => x.Elongation()).Returns(true);

            var consequence = new Consequences(variantEffect, featureEffect.Object);

            consequence.DetermineSmallVariantEffects();
            var observedConsequence = consequence.GetConsequences();

            Assert.Equal(ConsequenceTag.splice_donor_variant, observedConsequence[0]);
            Assert.Equal(ConsequenceTag.splice_acceptor_variant, observedConsequence[1]);
            Assert.Equal(ConsequenceTag.stop_gained, observedConsequence[2]);
            Assert.Equal(ConsequenceTag.frameshift_variant, observedConsequence[3]);
            Assert.Equal(ConsequenceTag.stop_lost, observedConsequence[4]);
            Assert.Equal(ConsequenceTag.start_lost, observedConsequence[5]);
            Assert.Equal(ConsequenceTag.inframe_insertion, observedConsequence[6]);
            Assert.Equal(ConsequenceTag.inframe_deletion, observedConsequence[7]);
            Assert.Equal(ConsequenceTag.missense_variant, observedConsequence[8]);
            Assert.Equal(ConsequenceTag.protein_altering_variant, observedConsequence[9]);
            Assert.Equal(ConsequenceTag.splice_region_variant, observedConsequence[10]);
            Assert.Equal(ConsequenceTag.incomplete_terminal_codon_variant, observedConsequence[11]);

            Assert.Equal(ConsequenceTag.stop_retained_variant, observedConsequence[12]);
            Assert.Equal(ConsequenceTag.synonymous_variant, observedConsequence[13]);
            Assert.Equal(ConsequenceTag.coding_sequence_variant, observedConsequence[14]);
            Assert.Equal(ConsequenceTag.five_prime_UTR_variant, observedConsequence[15]);
            Assert.Equal(ConsequenceTag.three_prime_UTR_variant, observedConsequence[16]);
            Assert.Equal(ConsequenceTag.non_coding_transcript_exon_variant, observedConsequence[17]);
            Assert.Equal(ConsequenceTag.intron_variant, observedConsequence[18]);
            Assert.Equal(ConsequenceTag.NMD_transcript_variant, observedConsequence[19]);
            Assert.Equal(ConsequenceTag.non_coding_transcript_variant, observedConsequence[20]);
        }