/// <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> /// Did we gain a start codon in this 5'UTR interval? /// </summary> /// <param name="seqChange"></param> /// <returns>A new start codon (if gained)</returns> private string startGained(Variant seqChange) { if (!seqChange.isSnv()) { return(""); } // Only SNPs supported. // Calculate SNP position relative to UTRs long pos = seqChange.DistanceBases(get5primeUtrs().OfType <Interval>().ToList(), IsStrandMinus()); // Change base at SNP position string sequence = getSequence(); char[] chars = sequence.ToCharArray(); char snpBase = seqChange.NetChange(this)[0]; if (IsStrandMinus() && Alphabets.DNA.TryGetComplementSymbol((byte)snpBase, out byte complement)) { snpBase = (char)complement; } chars[pos] = snpBase; // Do we gain a new start codon? return(startGained(chars, pos)); }
/// <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 override string NetCdsChange() { if (Variant.Length() > 1) { StringBuilder sb = new StringBuilder(); foreach (Exon exon in Transcript.ExonsSortedStrand) { string seq = Variant.NetChange(exon); sb.Append(exon.IsStrandPlus() ? seq : SequenceExtensions.ConvertToString(new Sequence(Alphabets.AmbiguousDNA, seq).GetReverseComplementedSequence())); } return(sb.ToString()); } return(Variant.NetChange(Transcript.IsStrandPlus())); }
/// <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); }
protected void ApplyIns(Variant variant, IntervalSequence markerSeq) { // Get sequence in positive strand direction ISequence seq = IsStrandPlus() ? Sequence : Sequence.GetReverseComplementedSequence(); // Apply change to sequence String netChange = variant.NetChange(this); long idx = variant.OneBasedStart - OneBasedStart - 1; if (idx >= 0) { seq = new Sequence(seq.Alphabet, SequenceExtensions.ConvertToString(seq, 0, idx + 1) + netChange + SequenceExtensions.ConvertToString(seq, idx + 1)); } else { seq = new Sequence(seq.Alphabet, netChange + SequenceExtensions.ConvertToString(seq)); } // Update sequence markerSeq.Sequence = IsStrandPlus() ? seq : seq.GetReverseComplementedSequence(); }