Beispiel #1
0
        public override bool CreateVariantEffect(Variant variant, VariantEffects variantEffects)
        {
            // Has the whole UTR been deleted?
            if (variant.Includes(this) && variant.VarType == Variant.VariantType.DEL)
            {
                variantEffects.AddEffect(variant, this, EffectType.UTR_5_DELETED, ""); // A UTR was removed entirely
                return(true);
            }

            // Add distance
            Transcript    tr            = (Transcript)FindParent(typeof(Transcript));
            long          distance      = utrDistance(variant, tr);
            VariantEffect variantEffect = new VariantEffect(variant);

            variantEffect.Set(this, IntervalType, EffectTypeMethods.EffectDictionary[IntervalType], distance >= 0 ? distance + " bases from TSS" : "");
            variantEffect.Distance = distance;
            variantEffects.AddEffect(variantEffect);

            // Start gained?
            string gained = startGained(variant);

            if (gained != "")
            {
                variantEffects.AddEffect(variant, this, EffectType.START_GAINED, gained);
            }

            return(true);
        }
        /// <summary>
        /// Apply a Variant to a marker. Variant is a duplication
        /// </summary>
        /// <param name="variant"></param>
        /// <returns></returns>
        protected Interval ApplyDup(Variant variant)
        {
            Interval m = new Interval(this);

            if (variant.OneBasedEnd < m.OneBasedStart)
            {
                // Duplication before marker start? => Adjust both coordinates
                long lenChange = variant.LengthChange();
                m.OneBasedStart += lenChange;
                m.OneBasedEnd   += lenChange;
            }
            else if (variant.Includes(m))
            {
                // Duplication includes whole marker? => Adjust both coordinates
                long lenChange = variant.LengthChange();
                m.OneBasedStart += lenChange;
                m.OneBasedEnd   += lenChange;
            }
            else if (m.Includes(variant))
            {
                // Duplication included in marker? => Adjust end coordinate
                m.OneBasedEnd += variant.LengthChange();
            }
            else if (variant.Intersects(m))
            {
                // Duplication includes part of marker? => Adjust end
                m.OneBasedEnd += variant.IntersectSize(m);
            }
            else
            {
                // Duplication after end, no effect on marker coordinates
            }

            return(m);
        }
        /// <summary>
        /// Apply a Variant to a marker. Variant is a deletion
        /// </summary>
        /// <param name="variant"></param>
        /// <returns></returns>
        protected Interval ApplyDel(Variant variant)
        {
            Interval m = new Interval(this);

            if (variant.OneBasedEnd < m.OneBasedStart)
            {
                // Deletion before start: Adjust coordinates
                long lenChange = variant.LengthChange();
                m.OneBasedStart += lenChange;
                m.OneBasedEnd   += lenChange;
            }
            else if (variant.Includes(m))
            {
                // Deletion completely includes this marker => The whole marker deleted
                return(null);
            }
            else if (m.Includes(variant))
            {
                // This marker completely includes the deletion, but deletion does not include
                // marker. Marker is shortened (i.e. only 'end' coordinate needs to be updated)
                m.OneBasedEnd += variant.LengthChange();
            }
            else
            {
                // Variant is partially included in this marker.
                // This is treated as three different type of deletions:
                //		1- One after the marker
                //		2- One inside the marker
                //		3- One before the marker
                // Note that type 1 and 3 cannot exists at the same time, otherwise the
                // deletion would fully include the marker (previous case)

                // Part 1: Deletion after the marker
                if (m.OneBasedEnd < variant.OneBasedEnd)
                {
                    // Actually this does not affect the coordinates, so we don't care about this part
                }

                // Part 2: Deletion matching the marker (intersection)
                long istart = Math.Max(variant.OneBasedStart, m.OneBasedStart);
                long iend   = Math.Min(variant.OneBasedEnd, m.OneBasedEnd);
                if (iend < istart)
                {
                    throw new ArgumentOutOfRangeException("This should never happen!");
                }                                     // Sanity check
                m.OneBasedEnd -= (iend - istart + 1); // Update end coordinate

                // Part 3: Deletion before the marker
                if (variant.OneBasedStart < m.OneBasedEnd)
                {
                    // Update coordinates shifting the marker to the left
                    long delta = m.OneBasedStart - variant.OneBasedStart;
                    m.OneBasedStart -= delta;
                    m.OneBasedEnd   -= delta;
                }
            }

            return(m);
        }
Beispiel #4
0
 /// <summary>
 /// Whole exon/s deleted?
 /// </summary>
 private void ExonLoss()
 {
     foreach (Exon ex in Transcript.Exons)
     {
         if (Variant.Includes(ex))
         {
             EffectNoCodon(ex, EffectType.EXON_DELETED);
         }
     }
 }
        /// <summary>
        /// How many full / partial exons does the variant affect?
        /// </summary>
        protected void CountAffectedExons()
        {
            exonFull    = 0;
            exonPartial = 0;

            foreach (Exon ex in Transcript.Exons)
            {
                if (Variant.Includes(ex))
                {
                    exonFull++;
                }
                else if (Variant.Intersects(ex))
                {
                    exonPartial++;
                }
            }
        }
 public override void ChangeCodon()
 {
     if (Variant.Includes(Transcript))
     {
         // Whole transcript affected?
         EffectTranscript();
     }
     else
     {
         // Does the variant affect any exons?
         if (exonFull > 0 || exonPartial > 0)
         {
             Exons();
         }
         else
         {
             Intron();
         }
     }
 }
Beispiel #7
0
        public override bool CreateVariantEffect(Variant variant, VariantEffects variantEffects)
        {
            if (!Intersects(variant))
            {
                return(false);
            }

            if (variant.Includes(this) && variant.VarType == Variant.VariantType.DEL)
            {
                variantEffects.AddEffectType(variant, this, EffectType.UTR_3_DELETED); // A UTR was removed entirely
                return(true);
            }

            Transcript tr       = (Transcript)FindParent(typeof(Transcript));
            long       distance = utrDistance(variant, tr);

            VariantEffect variantEffect = new VariantEffect(variant);

            variantEffect.Set(this, EffectType.UTR_3_PRIME, EffectTypeMethods.EffectDictionary[EffectType.UTR_3_PRIME], distance >= 0 ? distance + " bases from CDS" : "");
            variantEffect.Distance = distance;
            variantEffects.AddEffect(variantEffect);

            return(true);
        }
Beispiel #8
0
        /// <summary>
        /// Analyze deletions in this transcript.
        /// </summary>
        /// <param name="exon"></param>
        /// <returns></returns>
        protected override bool ChangeCodon(Exon exon)
        {
            // Is there any net effect?
            if (NetCodingSequenceChange == "")
            {
                return(false);
            }

            EffectType effType;

            if (Variant.Includes(exon))
            {
                /**
                 * An exon has been entirely removed
                 */
                CodonsReference  = "";
                CodonsAlternate  = "";
                CodonStartNumber = -1;
                CodonStartIndex  = -1;
                effType          = EffectType.EXON_DELETED;
            }
            else if (NetCodingSequenceChange.Length % CODON_SIZE != 0)
            {
                /**
                 * Length not multiple of CODON_SIZE => FRAME_SHIFT
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Delete 'AA' pos 0:	ACC CGG GAA ACC CGG GAA ACC CGG G
                 *      Delete 'AA' pos 1:	ACC CGG GAA ACC CGG GAA ACC CGG G
                 *      Delete 'AC' pos 2:	AAC CGG GAA ACC CGG GAA ACC CGG G
                 */
                CodonsReference = CodonsRef();
                CodonsAlternate = "";
                effType         = EffectType.FRAME_SHIFT;
            }
            else if (CodonStartIndex == 0)
            {
                /**
                 * Length multiple of CODON_SIZE and insertion happens at codon boundary => CODON_DELETION
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Delete 'AAA' pos 0:	CCC GGG AAA CCC GGG AAA CCC GGG
                 */
                CodonsReference = CodonsRef();
                CodonsAlternate = "";
                effType         = EffectType.CODON_DELETION;
            }
            else
            {
                /**
                 * Length multiple of CODON_SIZE and insertion does not happen at codon boundary => CODON_CHANGE_PLUS_CODON_DELETION
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Delete 'AAC' pos 1:	ACC GGG AAA CCC GGG AAA CCC GGG
                 *      Delete 'ACC' pos 2:	AAC GGG AAA CCC GGG AAA CCC GGG
                 */
                CodonsReference = CodonsRef();
                CodonsAlternate = CodonsAlt();

                if (CodonsAlternate == "" || CodonsReference.StartsWith(CodonsAlternate))
                {
                    /**
                     * Note: It might happen that the last codon of the exon was deleted.
                     *       In this case there is no 'CODON_CHANGE'
                     * E.g.
                     *      Original:				AAA CCC GGG AAA CCC GGG AAA CCC GGG
                     *      Delete 'GGG' pos 24:	ACC CCC GGG AAA CCC GGG AAA CCC
                     *
                     * Note2: It may also be the case that the deleted bases are equal to the following ones.
                     *  E.g.
                     *      Original:			ACG TCG TCC GGG AAA CCC GGG AAA CCC GGG
                     *      Delete 'CGT' pos 1:	ACG TCC GGG AAA CCC GGG AAA CCC GGG
                     */
                    effType = EffectType.CODON_DELETION;
                }
                else
                {
                    effType = EffectType.CODON_CHANGE_PLUS_CODON_DELETION;
                }
            }

            Effect(exon, effType, false);

            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// Deletion analysis using full transcript information. This is done only when the variant affects more than one exons.
        /// </summary>
        protected override void Exons()
        {
            if (exonFull == 0 && exonPartial == 1)
            {
                // Variant partially affects only one exon?
                // => Use the standard (by exon) method
                codonChangeSuper();
                return;
            }
            else if (exonFull > 0)
            {
                // Full exons deleted
                ExonLoss();

                // Only whole exons deleted? We are done
                if (exonPartial == 0)
                {
                    return;
                }
            }

            //---
            // A combination of partial and full exons affected
            //---
            CodonsRefAlt();
            EffectType effType;
            int        lenDiff = cdsAlt.Length - cdsRef.Length;

            if (lenDiff % CODON_SIZE != 0)
            {
                effType = EffectType.FRAME_SHIFT;
            }
            else if (CodonStartIndex == 0)
            {
                effType = EffectType.CODON_DELETION;
            }
            else
            {
                if (CodonsAlternate == "" || CodonsReference.StartsWith(CodonsAlternate))
                {
                    effType = EffectType.CODON_DELETION;
                }
                else
                {
                    effType = EffectType.CODON_CHANGE_PLUS_CODON_DELETION;
                }
            }

            // Assign to first exon
            foreach (Exon ex in Transcript.Exons)
            {
                if (Variant.Includes(ex) || Variant.Intersects(ex))
                {
                    Exon = ex;
                    break;
                }
            }

            // Add variant effect
            Effect(Exon, effType, false);
        }