/// <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); }
/// <summary> /// Get new (modified) codons /// </summary> /// <returns></returns> protected override string CodonsAlt() { // Inserts BEFORE base: // - In positive strand that is BEFORE pos // - In negative strand, that is AFTER pos int idx = CodonStartIndex + (Transcript.IsStrandMinus() ? 1 : 0); // Insertion: Concatenate... string prefix = CodonsReference.Length >= idx?CodonsReference.Substring(0, idx) : CodonsReference; // First part of the codon string netChange = Variant.NetChange(Transcript.IsStrandMinus()); // Insertion string suffix = CodonsReference.Length >= idx?CodonsReference.Substring(idx) : ""; // last part of the codon // New codon string codonsNew = prefix + netChange + suffix; return(codonsNew); }
/// <summary> /// We may have to calculate 'netCdsChange', which is the effect on the CDS. /// Note: A deletion or a MNP might affect several exons /// </summary> /// <returns></returns> protected virtual string NetCdsChange() { if (!RequireNetCdsChange) { return(""); } if (Variant.Length() > 1) { StringBuilder sb = new StringBuilder(); foreach (Exon exon in Transcript.ExonsSortedStrand) { sb.Append(Variant.NetChange(exon)); } return(sb.ToString()); } return(Variant.NetChange(Transcript.IsStrandMinus())); }
/// <summary> /// Get new (modified) codons /// </summary> /// <returns></returns> protected override string CodonsAlt() { // Was there a problem getting 'codonsOld'? => We cannot do anything if (CodonsReference == "") { return(""); } char[] codonChars = CodonsReference.ToLower(CultureInfo.InvariantCulture).ToCharArray(); char snpBase = Variant.NetChange(Transcript.IsStrandMinus())[0]; if (CodonStartIndex < codonChars.Length) { codonChars[CodonStartIndex] = char.ToUpper(snpBase); } string codonsNew = new string(codonChars); return(codonsNew); }
/// <summary> /// Get original codons in CDS /// </summary> /// <returns></returns> protected override string CodonsRef() { if (NetCodingSequenceChange == "") { return(""); } long min = Variant.OneBasedStart; long max = Variant.OneBasedEnd; long cdsBaseMin = CdsBaseNumber(min); long cdsBaseMax = CdsBaseNumber(max); // Swap? if (Transcript.IsStrandMinus()) { long swap = cdsBaseMin; cdsBaseMin = cdsBaseMax; cdsBaseMax = swap; } if (cdsBaseMax < cdsBaseMin) { throw new ArgumentOutOfRangeException("This should never happen!\n\tcdsBaseMin: " + cdsBaseMin + "\n\tcdsBaseMax: " + cdsBaseMax + "\n\tmin: " + min + "\n\tmax: " + max + "\n\tSeqChange: " + Variant + "\n\ttranscript: " + Transcript + "\n\tCDS.len: " + Transcript.RetrieveCodingSequence().Count); } long maxCodon = cdsBaseMax / CODON_SIZE; long minCodon = cdsBaseMin / CODON_SIZE; long oldCodonCdsStart = (CODON_SIZE * minCodon); long oldCodonCdsEnd = (CODON_SIZE * (maxCodon + 1)) - 1; string codons = oldCodonCdsEnd >= Transcript.RetrieveCodingSequence().Count ? SequenceExtensions.ConvertToString(Transcript.RetrieveCodingSequence()).Substring((int)oldCodonCdsStart) : SequenceExtensions.ConvertToString(Transcript.RetrieveCodingSequence().GetSubSequence(oldCodonCdsStart, (maxCodon - minCodon + 1) * CODON_SIZE)); return(codons); }