/// <summary> /// Create a specific codon change for a variant /// </summary> /// <param name="variant"></param> /// <param name="transcript"></param> /// <param name="variantEffects"></param> /// <returns></returns> public static CodonChange Factory(Variant variant, Transcript transcript, VariantEffects variantEffects) { switch (variant.VarType) { case Variant.VariantType.SNV: return(new CodonChangeSnv(variant, transcript, variantEffects)); case Variant.VariantType.INS: return(new CodonChangeIns(variant, transcript, variantEffects)); case Variant.VariantType.DEL: return(new CodonChangeDel(variant, transcript, variantEffects)); case Variant.VariantType.MNV: return(new CodonChangeMnv(variant, transcript, variantEffects)); //case Variant.VariantType.MIXED: // return new CodonChangeMixed(variant, transcript, variantEffects); case Variant.VariantType.DUP: return(new CodonChangeDup(variant, transcript, variantEffects)); case Variant.VariantType.INV: return(new CodonChangeInv(variant, transcript, variantEffects)); case Variant.VariantType.INTERVAL: return(new CodonChangeInterval(variant, transcript, variantEffects)); default: throw new ArgumentException("Unimplemented factory for variant type '" + variant.VarType + "', variant: " + variant); } }
/// <summary> /// Add an effect /// </summary> /// <param name="marker"></param> /// <param name="effectType"></param> /// <param name="effectImpact"></param> /// <param name="codonsOld"></param> /// <param name="codonsNew"></param> /// <param name="codonNum"></param> /// <param name="codonIndex"></param> /// <param name="allowReplace"></param> /// <returns></returns> private VariantEffect Effect(Interval marker, EffectType effectType, EffectImpact effectImpact, string codonsOld, string codonsNew, int codonNum, int codonIndex, bool allowReplace) { // Create and add variant affect long cDnaPos = Transcript.BaseNumber2MRnaPos(Variant.OneBasedStart); VariantEffect varEff = new VariantEffect(Variant, marker, effectType, effectImpact, codonsOld, codonsNew, codonNum, codonIndex, cDnaPos); VariantEffects.AddEffect(varEff); // Are there any additional effects? Sometimes a new effect arises from setting codons (e.g. FRAME_SHIFT disrupts a STOP codon) EffectType addEffType = AdditionalEffect(codonsOld, codonsNew, codonNum, codonIndex); if (addEffType != EffectType.NONE && addEffType != effectType) { if (allowReplace && addEffType.CompareTo(effectType) < 0) { // Replace main effect (using default impact) varEff.SetEffect(addEffType); } else { // Add effect to list (using default impact) varEff.AddEffect(addEffType); } } return(varEff); }
public override bool CreateVariantEffect(Variant variant, VariantEffects variantEffects) { if (!Intersects(variant)) { return(false); } Transcript tr = (Transcript)Parent; bool coding = tr.IsProteinCoding(); // Different analysis for coding or non-coding bool exonAnnotated = false; if (!coding || variant.isInterval() || !variant.isVariant()) { // Non-coding or non-variant? Just annotate as 'exon' variantEffects.AddEffect(variant, this, EffectType.EXON, ""); exonAnnotated = true; } else if (tr.IsCds(variant)) { // Is it a coding transcript and the variant is within the CDS? // => We need codon analysis CodonChange codonChange = CodonChange.Factory(variant, tr, variantEffects); codonChange.ChangeCodon(); exonAnnotated = true; } // Any splice site effect to add? //for (SpliceSite ss : spliceSites) // if (ss.intersects(variant)) ss.variantEffect(variant, variantEffects); return(exonAnnotated); }
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> /// Calculate the effect of this variant /// </summary> /// <param name="variant"></param> /// <param name="variantEffects"></param> /// <returns></returns> public virtual bool CreateVariantEffect(Variant variant, VariantEffects variantEffects) { if (!Intersects(variant)) { return(false); } variantEffects.AddEffect(variant, this, IntervalType, ""); return(true); }
public override bool CreateVariantEffect(Variant variant, VariantEffects variantEffects) { if (!Intersects(variant)) { return(false); } //for (SpliceSite ss : spliceSites) // if (ss.intersects(variant)) ss.variantEffect(variant, variantEffects); // Add intron part variantEffects.AddEffectType(variant, this, EffectType.INTRON); return(true); }
/// <summary> /// Analyze SNPs in this transcript. Add changeEffect to 'changeEffect' /// </summary> /// <param name="exon"></param> /// <returns></returns> protected override bool ChangeCodon(Exon exon) { // Get old and new codons CodonsReference = CodonsRef(); CodonsAlternate = CodonsAlt(); // Use a generic low priority variant, this allows 'AdditionalEffects' to override it Effect(exon, EffectType.CODON_CHANGE, true); if (CodonsReference == "") { VariantEffects.AddErrorWarning(Variant, ErrorWarningType.ERROR_MISSING_CDS_SEQUENCE); } return(true); }
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); }
public CodonChangeSnv(Variant variant, Transcript transcript, VariantEffects variantEffects) : base(variant, transcript, variantEffects) { ReturnNow = true; // A SNP can only affect one exon }
protected CodonChangeStructural(Variant variant, Transcript transcript, VariantEffects variantEffects) : base(variant, transcript, variantEffects) { coding = transcript.IsProteinCoding(); // || Config.get().isTreatAllAsProteinCoding(); CountAffectedExons(); }
public abstract override bool CreateVariantEffect(Variant variant, VariantEffects variantEffects);
public CodonChangeMnv(Variant variant, Transcript transcript, VariantEffects variantEffects) : base(variant, transcript, variantEffects) { ReturnNow = false; RequireNetCdsChange = true; }
public CodonChangeIns(Variant seqChange, Transcript transcript, VariantEffects changeEffects) : base(seqChange, transcript, changeEffects) { ReturnNow = true; // An insertion can only affect one exon }
protected CodonChange(Variant variant, Transcript transcript, VariantEffects variantEffects) { Transcript = transcript; VariantEffects = variantEffects; Variant = variant; }
/// <summary> /// Calculate a list of codon changes /// </summary> public virtual void ChangeCodon() { if (!Transcript.Intersects(Variant)) { return; } // Get coding start (after 5 prime UTR) long cdsStart = Transcript.CdsOneBasedStart; // We may have to calculate 'netCdsChange', which is the effect on the CDS NetCodingSequenceChange = NetCdsChange(); if (RequireNetCdsChange && NetCodingSequenceChange == "") { // This can happen on mixed changes where the 'InDel' part lies outside the transcript's exons CodonsReference = ""; CodonsAlternate = ""; return; } //--- // Concatenate all exons //--- int firstCdsBaseInExon = 0; // Where the exon maps to the CDS (i.e. which CDS base number does the first base in this exon maps to). List <Exon> exons = Transcript.ExonsSortedStrand; foreach (Exon exon in exons) { Exon = exon; if (exon.Intersects(Variant)) { long cdsBaseInExon; // cdsBaseInExon: base number relative to the beginning of the coding part of this exon (i.e. excluding 5'UTRs) if (Transcript.IsStrandPlus()) { long firstvariantBaseInExon = Math.Max(Variant.OneBasedStart, Math.Max(exon.OneBasedStart, cdsStart)); cdsBaseInExon = firstvariantBaseInExon - Math.Max(exon.OneBasedStart, cdsStart); } else { long lastvariantBaseInExon = Math.Min(Variant.OneBasedEnd, Math.Min(exon.OneBasedEnd, cdsStart)); cdsBaseInExon = Math.Min(exon.OneBasedEnd, cdsStart) - lastvariantBaseInExon; } if (cdsBaseInExon < 0) { cdsBaseInExon = 0; } // Get codon number and index within codon (where seqChage is pointing) if (CodonStartNumber < 0) { CodonStartNumber = (int)(firstCdsBaseInExon + cdsBaseInExon) / CODON_SIZE; CodonStartIndex = (int)(firstCdsBaseInExon + cdsBaseInExon) % CODON_SIZE; } // Use appropriate method to calculate codon change bool hasChanged = false; // Was there any change? hasChanged = ChangeCodon(exon); // This is overriden for the specific type of codon change // Any change? => Add change to list if (hasChanged && !VariantEffects.HasMarker()) { VariantEffects.SetMarker(exon); // It is affecting this exon, so we set the marker } // Can we finish after effect of first exon is added? if (ReturnNow) { return; } } firstCdsBaseInExon += Transcript.IsStrandPlus() ? (int)Math.Max(0, exon.OneBasedEnd - Math.Max(exon.OneBasedStart, cdsStart) + 1) : (int)Math.Max(0, Math.Min(cdsStart, exon.OneBasedEnd) - exon.OneBasedStart + 1); } }