Exemple #1
0
        /// <summary>
        /// Analyze insertions in this transcript. Add changeEffect to 'changeEffect'
        /// </summary>
        /// <param name="exon"></param>
        /// <returns></returns>
        protected override bool ChangeCodon(Exon exon)
        {
            string netChange = Variant.NetChange(Transcript.IsStrandMinus());

            CodonsReference = CodonsRef();
            CodonsAlternate = CodonsAlt();

            EffectType effType;

            if (netChange.Length % CODON_SIZE != 0)
            {
                /**
                 * Length not multiple of CODON_SIZE => FRAME_SHIFT
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Insert 'TT' pos 0:	TTA AAC CCG GGA AAC CCG GGA AAC CCG GG
                 *      Insert 'TT' pos 1:	ATT AAC CCG GGA AAC CCG GGA AAC CCG GG
                 *      Insert 'TT' pos 2:	AAT TAC CCG GGA AAC CCG GGA AAC CCG GG
                 */
                effType = EffectType.FRAME_SHIFT;
            }
            else if (CodonStartIndex == 0)
            {
                /**
                 * Length multiple of CODON_SIZE and insertion happens at codon boundary => CODON_INSERTION
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Insert 'TTT' pos 0:	TTT AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 */
                effType = EffectType.CODON_INSERTION;
            }
            else
            {
                /**
                 * Length multiple of CODON_SIZE and insertion does not happen at codon boundary => CODON_CHANGE_PLUS_CODON_INSERTION
                 *  E.g. :
                 *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Insert 'TTT' pos 1:	ATT TAA CCC GGG AAA CCC GGG AAA CCC GGG
                 *      Insert 'TTT' pos 2:	AAT TTA CCC GGG AAA CCC GGG AAA CCC GGG
                 */
                if (CodonsAlternate.ToUpper(CultureInfo.InvariantCulture).StartsWith(CodonsReference.ToUpper(CultureInfo.InvariantCulture)))
                {
                    /**
                     *  May be the inserted base are equal to the old ones.
                     *  E.g.
                     *      Original:			AAA CCC GGG AAA CCC GGG AAA CCC GGG
                     *      Insert 'AAA' pos 1:	AAA AAA CCC GGG AAA CCC GGG AAA CCC GGG
                     */
                    effType = EffectType.CODON_INSERTION;
                }
                else
                {
                    effType = EffectType.CODON_CHANGE_PLUS_CODON_INSERTION;
                }
            }

            Effect(exon, effType, false);

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Calculate codons old / codons new
        /// </summary>
        protected void codonOldNew()
        {
            if (!Transcript.Intersects(Variant))
            {
                return;
            }

            // CDS coordinates
            cdsStart = Transcript.IsStrandPlus() ? Transcript.CdsOneBasedStart : Transcript.CdsOneBasedEnd;
            cdsEnd   = Transcript.IsStrandPlus() ? Transcript.CdsOneBasedEnd : Transcript.CdsOneBasedStart;

            // Does it intersect CDS?
            if (cdsStart > Variant.OneBasedEnd)
            {
                return;
            }
            if (cdsEnd < Variant.OneBasedStart)
            {
                return;
            }

            // Base number relative to CDS start
            long scStart, scEnd;

            if (Transcript.IsStrandPlus())
            {
                scStart = cdsBaseNumber(Variant.OneBasedStart, false);
                scEnd   = cdsBaseNumber(Variant.OneBasedEnd, true);
            }
            else
            {
                scEnd   = cdsBaseNumber(Variant.OneBasedStart, true);
                scStart = cdsBaseNumber(Variant.OneBasedEnd, false);
            }

            // Update coordinates
            CodonStartNumber = (int)(scStart / CODON_SIZE);
            CodonStartIndex  = (int)(scStart % CODON_SIZE);

            // MNP overlap in coding part
            long scLen = scEnd - scStart;

            if (scLen < 0)
            {
                return;
            }

            // Round to codon position
            long scStart3 = round3(scStart, false);
            long scEnd3   = round3(scEnd, true);
            long scLen3   = scEnd3 - scStart3;

            if (scEnd3 == scStart3)
            {
                scEnd3 += 3;
            }                                       // At least one codon

            // Append 'N'
            string padN = "";
            long   diff = scEnd3 - (Transcript.RetrieveCodingSequence().Count - 1);

            if (diff > 0)
            {
                scEnd3 = Transcript.RetrieveCodingSequence().Count - 1;
                // Pad with 'N'
                switch (diff)
                {
                case 1:
                    padN = "N";
                    break;

                case 2:
                    padN = "NN";
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Sanity check failed. Number of 'N' pading is :" + diff + ". This should not happen!");
                }
            }

            // Get old codon (reference)
            CodonsReference = SequenceExtensions.ConvertToString(Transcript.RetrieveCodingSequence().GetSubSequence(scStart3, scLen3));

            // Get new codon (change)
            string prepend = CodonsReference.Substring(0, (int)(scStart - scStart3));
            string append  = scEnd3 > scEnd?CodonsReference.Substring(CodonsReference.Length - (int)(scEnd3 - scEnd)) : "";

            CodonsAlternate = prepend + NetCdsChange() + append;

            // Pad codons with 'N' if required
            CodonsReference += padN;
            CodonsAlternate += padN;

            //---
            // Can we simplify codons?
            //---
            if ((CodonsReference != null) && (CodonsAlternate != null))
            {
                while ((CodonsReference.Length >= 3) && (CodonsAlternate.Length >= 3))
                {
                    // First codon
                    string cold = CodonsReference.Substring(0, 3);
                    string cnew = CodonsAlternate.Substring(0, 3);

                    // Are codons equal? => Simplify
                    if (cold.Equals(cnew, StringComparison.InvariantCultureIgnoreCase))
                    {
                        CodonsReference = CodonsReference.Substring(3);
                        CodonsAlternate = CodonsAlternate.Substring(3);
                        CodonStartNumber++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }