コード例 #1
0
            public int CompareTo(object other)
            {
                CovPoint oth = (CovPoint)other;

                int res = Point.CompareTo(oth.Point);

                if (res == 0)
                {
                    if (this.IsStart == oth.IsStart)
                    {
                        return(0);
                    }
                    else if (IsStart)
                    {
                        return(-1);
                    }
                    else
                    {
                        return(1);
                    }
                }
                return(res);
            }
コード例 #2
0
        public virtual double GetCoverageSection(int st, int ed)
        {
            if (Reads != null)
            {
                int             len       = ed - st + 1;
                List <CovPoint> points    = new List <CovPoint> ();
                List <CovPoint> remPoints = new List <CovPoint> ();
                CovPoint        OldEnd;
                bool            previousWasStart = false;


                foreach (SeqRead sq in Reads)
                {
                    if (HasOverLap(sq, st, ed))
                    {
                        foreach (CovPoint co in points)
                        {
                            if (sq.Contains(co.Point))
                            {
                                remPoints.Add(co);
                            }
                        }
                        foreach (CovPoint co in remPoints)
                        {
                            points.Remove(co);
                        }
                        remPoints.Clear();

                        if (sq.Start < st)
                        {
                            points.Add(new CovPoint(st, true));
                        }
                        else
                        {
                            points.Add(new CovPoint(sq.Start, true));
                        }

                        if (sq.End > ed)
                        {
                            points.Add(new CovPoint(ed, false));
                        }
                        else
                        {
                            points.Add(new CovPoint(sq.End, false));
                        }

                        points.Sort();

                        previousWasStart = false;
                        OldEnd           = null;
                        foreach (CovPoint co in points)
                        {
                            if (co.IsStart)
                            {
                                if (previousWasStart)
                                {
                                    remPoints.Add(co);
                                }
                            }
                            else
                            {
                                if (!previousWasStart)
                                {
                                    remPoints.Add(OldEnd);
                                }
                            }
                            OldEnd           = co;
                            previousWasStart = co.IsStart;
                        }

                        foreach (CovPoint c in remPoints)
                        {
                            points.Remove(c);
                        }
                        remPoints.Clear();
                    }
                }

                int totalGap = 0;
                int lInd     = points.Count - 1;

                if (lInd > 0)
                {
                    if (points [0].IsStart)
                    {
                        totalGap += points [0].Point - st;
                    }
                    if (!points [lInd].IsStart)
                    {
                        totalGap += ed - points [lInd].Point;
                    }
                }
                else
                {
                    totalGap = len;
                }
                if (lInd > 1)
                {
                    CovPoint previous = null;
                    previousWasStart = true;
                    foreach (CovPoint co in points)
                    {
                        if (previous != null)
                        {
                            if (co.IsStart && !previousWasStart)
                            {
                                totalGap += co.Point - previous.Point;
                            }
                        }
                        previous         = co;
                        previousWasStart = co.IsStart;
                    }
                }

                return(1 - totalGap / (double)len);
            }
            else
            {
                return(0);
            }
        }