Пример #1
0
        /// <summary>
        /// returns true if at least one base of the first codon was changed in the transcript [VariantEffect.pm:722 affects_start_codon]
        /// </summary>
        public bool IsStartLost()
        {
            const ConsequenceTag ct = ConsequenceTag.start_lost;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // check the predicates
            if (!_preCache.IsCoding)
            {
                _cache.Add(ct, false);
                return(false);
            }

            if (_proteinBegin != 1 || _referenceAminoAcidsLen == 0)
            {
                _cache.Add(ct, false);
                return(false);
            }

            // insertion in start codon and do not change start codon
            if (_isInsertion && _proteinBegin == 1 && _alternateAminoAcids.EndsWith(_referenceAminoAcids))
            {
                _cache.Add(ct, false);
                return(false);
            }

            bool result = _alternateAminoAcidsLen == 0 || _alternateAminoAcids[0] != _referenceAminoAcids[0];

            _cache.Add(ct, result);
            return(result);
        }
Пример #2
0
        /// <summary>
        /// returns true if the variant is a missense variant [VariantEffect.pm:682 missense_variant]
        /// </summary>
        public bool IsMissenseVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.missense_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // check the predicates
            if (!_preCache.IsCoding)
            {
                _cache.Add(ct, false);
                return(false);
            }

            if (IsStartLost() ||
                IsStopLost() ||
                IsStopGained() ||
                IsIncompleteTerminalCodonVariant() ||
                IsFrameshiftVariant() ||
                IsInframeDeletion() ||
                IsInframeInsertion())
            {
                _cache.Add(ct, false);
                return(false);
            }

            bool result = _referenceAminoAcids != _alternateAminoAcids &&
                          _referenceAminoAcidsLen == _alternateAminoAcidsLen;

            _cache.Add(ct, result);
            return(result);
        }
Пример #3
0
        /// <summary>
        /// returns true if the variant is a frameshift variant [VariantEffect.pm:940 frameshift]
        /// </summary>
        public bool IsFrameshiftVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.frameshift_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // check the predicates
            if (!_preCache.IsCoding)
            {
                _cache.Add(ct, false);
                return(false);
            }

            if (IsIncompleteTerminalCodonVariant())
            {
                _cache.Add(ct, false);
                return(false);
            }

            bool result = _preCache.HasFrameShift && !IsStopRetained() && !IsTruncatedByStop();

            _cache.Add(ct, result);
            return(result);
        }
Пример #4
0
        /// <summary>
        /// returns true if the variant is an inframe insertion [VariantEffect.pm:780 inframe_insertion]
        /// </summary>
        public bool IsInframeInsertion()
        {
            const ConsequenceTag ct = ConsequenceTag.inframe_insertion;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // check the predicates
            if (!_preCache.IsCoding || !_isInsertion)
            {
                _cache.Add(ct, false);
                return(false);
            }

            if (IsStopRetained() ||
                IsFrameshiftVariant() ||
                IsStartLost() ||
                _alternateCodonsLen <= _referenceCodonsLen ||
                IsIncompleteTerminalCodonVariant())
            {
                _cache.Add(ct, false);
                return(false);
            }

            bool result = !IsTruncatedByStop();

            _cache.Add(ct, result);
            return(result);
        }
Пример #5
0
        /// <summary>
        /// returns true if the variant is a protein altering variant [VariationEffect.pm:300 protein_altering_variant]
        /// </summary>
        public bool IsProteinAlteringVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.protein_altering_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            var result = true;

            var sameLen       = _referenceAminoAcidsLen == _alternateAminoAcidsLen;
            var startsWithTer = _referenceAminoAcids.OptimizedStartsWith('X') || _alternateAminoAcids.OptimizedStartsWith('X');

            var isInframeDeletion = IsInframeDeletion();
            // Note: sequence ontology says that stop retained should not be here (http://www.sequenceontology.org/browser/current_svn/term/SO:0001567)
            var isStopCodonVarinat = IsStopLost() || IsStopGained();

            if (sameLen || startsWithTer || isInframeDeletion || isStopCodonVarinat ||
                IsStartLost() || IsFrameshiftVariant() || IsInframeInsertion() || IsStopRetained() || !_preCache.IsCoding)
            {
                result = false;
            }

            _cache.Add(ct, result);
            return(result);
        }
Пример #6
0
        public void DetermineFlankingVariantEffects(bool isDownStreamVariant, ConsequenceTag expectedConsequence)
        {
            List <ConsequenceTag> observedConsequences = Consequences.DetermineFlankingVariantEffects(isDownStreamVariant);

            Assert.Single(observedConsequences);
            Assert.Equal(expectedConsequence, observedConsequences[0]);
        }
Пример #7
0
 public static string GetConsequence(ConsequenceTag consequence)
 {
     if (consequence == ConsequenceTag.five_prime_UTR_variant)
     {
         return("5_prime_UTR_variant");
     }
     return(consequence == ConsequenceTag.three_prime_UTR_variant ? "3_prime_UTR_variant" : consequence.ToString());
 }
Пример #8
0
        [InlineData(ConsequenceTag.short_tandem_repeat_contraction, true)] // parallel
        public void NeedsTranscriptVariant_STR(ConsequenceTag consequence, bool expectedResult)
        {
            var consequences = new List <ConsequenceTag> {
                consequence
            };
            bool observedResult = Consequences.NeedsTranscriptVariant(VariantType.unknown, consequences);

            Assert.Equal(expectedResult, observedResult);
        }
Пример #9
0
        public void DetermineFlankingVariantEffects(bool isDownStreamVariant, ConsequenceTag expectedConsequence)
        {
            var consequence = new Consequences();

            consequence.DetermineFlankingVariantEffects(isDownStreamVariant);
            var observedConsequences = consequence.GetConsequences();

            Assert.Single(observedConsequences);
            Assert.Equal(expectedConsequence, observedConsequences[0]);
        }
        public void Annotate_Promoter()
        {
            var variant          = GetVariant();
            var regulatoryRegion = GetRegulatoryRegion();

            const ConsequenceTag expectedConsequence = ConsequenceTag.regulatory_region_variant;
            var annotatedRegulatoryRegion            = RegulatoryRegionAnnotator.Annotate(variant, regulatoryRegion);
            var consequences = annotatedRegulatoryRegion.Consequences.ToList();

            Assert.NotNull(annotatedRegulatoryRegion);
            Assert.Single(consequences);
            Assert.Equal(expectedConsequence, consequences[0]);
        }
Пример #11
0
        /// <summary>
        /// returns true if the variant is a nonsense-mediated decay transcript variant [VariationEffect.pm:391 within_nmd_transcript]
        /// </summary>
        public bool IsNonsenseMediatedDecayTranscriptVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.NMD_transcript_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }
            var result = _transcript.BioType == BioType.nonsense_mediated_decay;

            _cache.Add(ct, result);
            return(result);
        }
Пример #12
0
        /// <summary>
        /// returns true if the variant is a splice donor variant [VariationEffect.pm:459 donor_splice_site]
        /// </summary>
        public bool IsSpliceDonorVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.splice_donor_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = _transcript.Gene.OnReverseStrand ? _preCache.IsEndSpliceSite : _preCache.IsStartSpliceSite;

            _cache.Add(ct, result);
            return(result);
        }
Пример #13
0
        /// <summary>
        /// returns true if the variant is a non-coding transcript exon variant [VariationEffect.pm:405 non_coding_exon_variant]
        /// </summary>
        public bool IsNonCodingTranscriptExonVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.non_coding_transcript_exon_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = _preCache.HasExonOverlap && _transcript.Translation == null && !_preCache.OverlapWithMicroRna;

            _cache.Add(ct, result);
            return(result);
        }
Пример #14
0
        /// <summary>
        /// returns true if the variant overlaps a mature MiRNA. [VariationEffect.pm:432 within_mature_miRNA]
        /// </summary>
        public bool IsMatureMirnaVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.mature_miRNA_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = _preCache.OverlapWithMicroRna;

            _cache.Add(ct, result);
            return(result);
        }
Пример #15
0
        /// <summary>
        /// returns true if the variant's amino acid changes to a stop codon [VariationEffect.pm:884 stop_gained]
        /// </summary>
        public bool IsStopGained()
        {
            const ConsequenceTag ct = ConsequenceTag.stop_gained;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = !IsStopRetained() &&
                          (string.IsNullOrEmpty(_referenceAminoAcids) || !_referenceAminoAcids.Contains(AminoAcids.StopCodon)) &&
                          !string.IsNullOrEmpty(_alternateAminoAcids) && _alternateAminoAcids.Contains(AminoAcids.StopCodon);

            _cache.Add(ct, result);
            return(result);
        }
Пример #16
0
        /// <summary>
        /// returns true if the variant is within a non-coding gene [VariationEffect.pm:398 within_non_coding_gene]
        /// </summary>
        public bool IsNonCodingTranscriptVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.non_coding_transcript_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // NOTE: Isn't IsWithinTranscript always true? and not within mature miRNA is always true
            // For Ensembl transcript, miRNA may be a valid attribute. We have their location and we would like to check if the variant overlaps with the miRNA
            var result = !_preCache.HasExonOverlap && _transcript.Translation == null && !_preCache.OverlapWithMicroRna;

            _cache.Add(ct, result);
            return(result);
        }
Пример #17
0
        /// <summary>
        /// returns true if the variant is a synonymous variant [VariationEffect.pm:755 synonymous_variant]
        /// </summary>
        public bool IsSynonymousVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.synonymous_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = !string.IsNullOrEmpty(_referenceAminoAcids) &&
                          (_variant.Type == VariantType.SNV ||
                           _variant.Type == VariantType.MNV) &&
                          _referenceAminoAcids == _alternateAminoAcids && !_referenceAminoAcids.Contains("X") &&
                          !_alternateAminoAcids.Contains("X") && !IsStopRetained();

            _cache.Add(ct, result);
            return(result);
        }
Пример #18
0
        /// <summary>
        /// returns true if it's a coding sequnce variant [VariationEffect.pm:998 coding_unknown]
        /// </summary>
        public bool IsCodingSequenceVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.coding_sequence_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = _preCache.WithinCds &&
                          (string.IsNullOrEmpty(_transcript.Translation.PeptideSeq) ||
                           string.IsNullOrEmpty(_alternateAminoAcids) || _alternateAminoAcids.Contains("X")) &&
                          !(IsFrameshiftVariant() || IsInframeDeletion() || IsIncompleteTerminalCodonVariant() ||
                            IsProteinAlteringVariant() || IsStopGained() || IsStopRetained() || IsStopLost());

            _cache.Add(ct, result);
            return(result);
        }
Пример #19
0
        /// <summary>
        /// returns true if the variant is an inframe deletion [VariantEffect.pm:825 inframe_deletion]
        /// </summary>
        public bool IsInframeDeletion()
        {
            const ConsequenceTag ct = ConsequenceTag.inframe_deletion;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            // check the predicates
            if (!_preCache.IsCoding || !_isDeletion)
            {
                _cache.Add(ct, false);
                return(false);
            }

            if (_referenceCodonsLen == 0 || //|| (PreCache.ReferenceCodonLen < PreCache.AlternateCodonLen)
                IsFrameshiftVariant() ||
                IsIncompleteTerminalCodonVariant() ||
                IsStopGained())
            {
                _cache.Add(ct, false);
                return(false);
            }

            // simple string match
            var referenceCodon = _referenceCodons.ToLower();
            var alternateCodon = _alternateCodons.ToLower();

            if (referenceCodon.StartsWith(alternateCodon) || referenceCodon.EndsWith(alternateCodon))
            {
                _cache.Add(ct, true);
                return(true);
            }

            // try a more complex string match
            var commonPrefixLength = _referenceCodons.CommonPrefixLength(_alternateCodons);
            var commonSuffixLength = _referenceCodons.CommonSuffixLength(_alternateCodons);

            bool result = _alternateCodonsLen - commonPrefixLength - commonSuffixLength == 0;

            _cache.Add(ct, result);
            return(result);
        }
Пример #20
0
        /// <summary>
        /// returns true if the variant is a stop lost variant [VariationEffect.pm:898 stop_lost]
        /// </summary>
        public bool IsStopLost()
        {
            const ConsequenceTag ct = ConsequenceTag.stop_lost;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = false;

            if (!string.IsNullOrEmpty(_coveredReferenceAminoAcids) && _coveredAlternateAminoAcids != null)
            {
                result = _coveredReferenceAminoAcids.Contains(AminoAcids.StopCodon) &&
                         !_coveredAlternateAminoAcids.Contains(AminoAcids.StopCodon);
            }

            _cache.Add(ct, result);
            return(result);
        }
Пример #21
0
        /// <summary>
        /// returns true if the variant is a stop retained variant [VariationEffect.pm:701 stop_lost]
        /// </summary>
        public bool IsStopRetained()
        {
            const ConsequenceTag ct = ConsequenceTag.stop_retained_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            var alternateAminoAcids = TrimPeptides(_alternateAminoAcids);

            bool result = !string.IsNullOrEmpty(_referenceAminoAcids) && alternateAminoAcids != null &&
                          _referenceAminoAcids == alternateAminoAcids &&
                          _referenceAminoAcids.Contains(AminoAcids.StopCodon) ||
                          string.IsNullOrEmpty(_referenceAminoAcids) && alternateAminoAcids != null &&
                          _proteinBegin == _transcript.Translation?.PeptideSeq.Length + 1 &&
                          alternateAminoAcids == AminoAcids.StopCodon;

            _cache.Add(ct, result);
            return(result);
        }
Пример #22
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());
        }
Пример #23
0
        public void DetermineStructuralVariantEffect(bool isAblation, bool isAmplification, bool isElongation,
                                                     bool isTruncation, ConsequenceTag expectedConsequence)
        {
            ConsequenceTag[] expectedConsequences = { expectedConsequence, ConsequenceTag.transcript_variant };

            var featureEffectsMock = new Mock <IFeatureVariantEffects>();

            featureEffectsMock.Setup(x => x.Ablation()).Returns(isAblation);
            featureEffectsMock.Setup(x => x.Amplification()).Returns(isAmplification);
            featureEffectsMock.Setup(x => x.Elongation()).Returns(isElongation);
            featureEffectsMock.Setup(x => x.Truncation()).Returns(isTruncation);

            var variant = new Variant(null, 0, 0, null, null, VariantType.unknown, null, false, false, false, null,
                                      AnnotationBehavior.StructuralVariants, true);

            var consequence = new Consequences(null, featureEffectsMock.Object);

            consequence.DetermineStructuralVariantEffect(variant);
            ConsequenceTag[] observedConsequences = consequence.GetConsequences().ToArray();

            Assert.Equal(expectedConsequences, observedConsequences);
        }
Пример #24
0
        /// <summary>
        /// returns true if the variant is a splice region variant [VariationEffect.pm:483 splice_region]
        /// </summary>
        public bool IsSpliceRegionVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.splice_region_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = false;

            if (IsSpliceDonorVariant() || IsSpliceAcceptorVariant())
            {
                // false
            }
            else
            {
                result = _preCache.IsWithinSpliceSiteRegion;
            }

            _cache.Add(ct, result);
            return(result);
        }
Пример #25
0
        /// <summary>
        /// returns true if the variant is a 3' UTR variant [VariationEffect.pm:609 within_3_prime_utr]
        /// </summary>
        public bool IsThreePrimeUtrVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.three_prime_UTR_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            bool result = false;

            if (_transcript.Translation != null)
            {
                var isThreePrimeOfCoding = _transcript.Gene.OnReverseStrand
                    ? _preCache.BeforeCoding
                    : _preCache.AfterCoding;

                result = isThreePrimeOfCoding && _preCache.WithinCdna;
            }

            _cache.Add(ct, result);
            return(result);
        }
Пример #26
0
        /// <summary>
        /// returns true if we have an incomplete terminal codon variant. [VariantEffect.pm:983 partial_codon]
        /// </summary>
        public bool IsIncompleteTerminalCodonVariant()
        {
            const ConsequenceTag ct = ConsequenceTag.incomplete_terminal_codon_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            if (_transcript.Translation == null)
            {
                _cache.Add(ct, false);
                return(false);
            }

            int cdsLength       = _transcript.Translation.CodingRegion.Length;
            int codonCdsStart   = _proteinBegin * 3 - 2;
            int lastCodonLength = cdsLength - (codonCdsStart - 1);

            bool result = lastCodonLength < 3 && lastCodonLength > 0;

            _cache.Add(ct, result);
            return(result);
        }
Пример #27
0
        public bool IsStartRetained()
        {
            const ConsequenceTag ct = ConsequenceTag.start_retained_variant;

            if (_cache.Contains(ct))
            {
                return(_cache.Get(ct));
            }

            if (_proteinBegin != 1 || string.IsNullOrEmpty(_referenceAminoAcids))
            {
                _cache.Add(ct, false);
                return(false);
            }

            var startProtein        = _referenceAminoAcids[0].ToString();
            var alternateAminoAcids = TrimPeptides(_alternateAminoAcids);

            var result = alternateAminoAcids != null &&
                         alternateAminoAcids.Contains(startProtein);

            _cache.Add(ct, result);
            return(result);
        }
Пример #28
0
 /// <summary>
 /// returns true if the corresponding value has been cached
 /// </summary>
 public bool Contains(ConsequenceTag consequence)
 {
     return(_isCached[(int)consequence]);
 }
Пример #29
0
        public void DetermineSmallVariantEffects_Tier1(VariantType variantType, bool isAblation, bool isAmplification, ConsequenceTag expectedResult)
        {
            var featureEffect = new Mock <IFeatureVariantEffects>();

            featureEffect.Setup(x => x.Ablation()).Returns(isAblation);
            featureEffect.Setup(x => x.Amplification()).Returns(isAmplification);

            var variantEffect = new Mock <IVariantEffect>();

            // make sure these tier 2 effects don't show up
            featureEffect.Setup(x => x.Elongation()).Returns(true);
            variantEffect.Setup(x => x.IsMatureMirnaVariant()).Returns(true);

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

            consequence.DetermineSmallVariantEffects();

            List <ConsequenceTag> observedConsequences = consequence.GetConsequences();

            Assert.Contains(expectedResult, observedConsequences);
        }
Пример #30
0
 /// <summary>
 /// returns the cached value for the corresponding result
 /// </summary>
 public bool Get(ConsequenceTag consequence)
 {
     return(_cachedResults[(int)consequence]);
 }