/// <summary> /// Fix coding domain sequences that have end frames /// </summary> /// <returns></returns> public void FrameCorrection() { // No coding domains? Nothing to do if (CdsSortedStrand == null || CdsSortedStrand.Count == 0) { return; } CDS cdsFirst = CdsSortedStrand.First(); if (cdsFirst != null) { UTR5Prime utr = cdsFirst.StartFrameCorrection(); if (utr != null) { UTRs.Add(utr); } } CDS cdsLast = CdsSortedStrand.Last(); if (cdsLast != null) { UTR3Prime utr = cdsLast.EndFrameCorrection(RetrieveCodingSequence().Count); if (utr != null) { UTRs.Add(utr); } } _CodingSequence = null; // update this later after this frame update }
/// <summary> /// Create UTR regions for this transcript /// </summary> public List <UTR> CreateUTRs() { if (CodingDomainSequences.Count == 0) { return(UTRs); } List <Interval> missing = Exons.OfType <Interval>().ToList(); foreach (Interval interval in UTRs.Concat(CodingDomainSequences.OfType <Interval>().ToList())) { missing = missing.SelectMany(i => i.Minus(interval)).ToList(); } long codingMin = CodingDomainSequences.Select(c => c.OneBasedStart).Min(); long codingMax = CodingDomainSequences.Select(c => c.OneBasedEnd).Max(); foreach (Interval interval in missing) { Exon x = FindExon(interval); if (x == null) { throw new ArgumentException("Cannot find exon for UTR: " + interval.ToString()); } UTR toAdd = null; if (IsStrandPlus()) { if (interval.OneBasedEnd <= codingMin) { toAdd = new UTR5Prime(x, x.ChromosomeID, x.Source, x.Strand, interval.OneBasedStart, interval.OneBasedEnd); } else if (interval.OneBasedStart >= codingMax) { toAdd = new UTR3Prime(x, x.ChromosomeID, x.Source, x.Strand, interval.OneBasedStart, interval.OneBasedEnd); } } else { if (interval.OneBasedStart >= codingMax) { toAdd = new UTR5Prime(x, x.ChromosomeID, x.Source, x.Strand, interval.OneBasedStart, interval.OneBasedEnd); } else if (interval.OneBasedEnd <= codingMin) { toAdd = new UTR3Prime(x, x.ChromosomeID, x.Source, x.Strand, interval.OneBasedStart, interval.OneBasedEnd); } } // OK? if (toAdd != null) { UTRs.Add(toAdd); } } return(UTRs); }