예제 #1
0
        /// <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
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <summary>
        /// Corrrects coordinates of end of coding sequence based on coding sequence length
        /// </summary>
        /// <param name="codingSequenceLength"></param>
        /// <returns></returns>
        public UTR3Prime EndFrameCorrection(long codingSequenceLength)
        {
            long endFrame = codingSequenceLength % 3;

            if (endFrame <= 0)
            {
                return(null);
            }                                   // nothing to do

            // First exon is not zero? => Create a UTR5 prime to compensate
            Exon      parent = (FindParent(typeof(Transcript)) as Transcript).GetLastCodingExon();
            UTR3Prime utr3   = null;

            if (IsStrandPlus())
            {
                long start = OneBasedEnd - (endFrame - 1);
                utr3 = new UTR3Prime(parent, parent.ChromosomeID, parent.Source, parent.Strand, start, OneBasedEnd);
            }
            else
            {
                long end = OneBasedStart + (endFrame - 1);
                utr3 = new UTR3Prime(parent, parent.ChromosomeID, parent.Source, parent.Strand, OneBasedStart, end);
            }

            // correct start or end coordinates
            if (IsStrandPlus())
            {
                OneBasedEnd -= endFrame;
            }
            else
            {
                OneBasedStart += endFrame;
            }

            return(utr3);
        }
예제 #4
0
 public UTR3Prime(UTR3Prime utr)
     : base(utr)
 {
 }