internal static Status DecideAnnotationStatus(IInterval variant, IInterval transcript, AnnotationBehavior behavior, IInterval gene) { if (variant.Contains(gene) && behavior.ReducedTranscriptAnnotation) { return(Status.SvCompleteOverlapAnnotation); } if (variant.Contains(gene) && !behavior.ReducedTranscriptAnnotation) { return(Status.FullAnnotation); } if (!variant.Contains(gene) && variant.Overlaps(transcript) && behavior.ReducedTranscriptAnnotation) { return(Status.ReducedAnnotation); } if (!variant.Contains(gene) && variant.Overlaps(transcript) && !behavior.ReducedTranscriptAnnotation) { return(Status.FullAnnotation); } if (!variant.Overlaps(transcript) && variant.Overlaps(transcript, OverlapBehavior.FlankingLength) && behavior.NeedFlankingTranscript) { return(Status.FlankingAnnotation); } return(Status.NoAnnotation); }
internal static Status DecideAnnotationStatus(IInterval variant, IInterval transcript, AnnotationBehavior behavior) { var overlapsTranscript = variant.Overlaps(transcript); if (!behavior.ReducedTranscriptAnnotation) { // handle small variants if (overlapsTranscript) { return(Status.FullAnnotation); } if (behavior.NeedFlankingTranscript && variant.Overlaps(transcript, OverlapBehavior.FlankingLength)) { return(Status.FlankingAnnotation); } } else if (overlapsTranscript) { // handle large variants if (behavior.CanonicalTranscriptOnly) { return(Status.RohAnnotation); } return(variant.Contains(transcript) ? Status.CompleteOverlapAnnotation : Status.ReducedAnnotation); } return(Status.NoAnnotation); }
public virtual IInterval <T>[] Substract(IInterval <T> other) { if (Contains(other)) { if (other.Start.CompareTo(other.End) == 0) // I assumed, that "no interval" still might be a valid input case { return(new IInterval <T>[] { this }); } if (Start.CompareTo(other.Start) == 0 && End.CompareTo(other.End) == 0) { return(new IInterval <T> [0]); // if 2 intervals are same, then after substracting we got nothing } if (Start.CompareTo(other.Start) == 0) { return(new IInterval <T>[] { Construct(other.End, End) }); } if (End.CompareTo(other.End) == 0) { return(new IInterval <T>[] { Construct(Start, other.Start) }); } else { return(new IInterval <T>[] { Construct(Start, other.Start), Construct(other.End, End) }); } } else if (other.Contains(this)) { return(new IInterval <T> [0]); // fully substracted by the "container" } else { if (this.Intersects(other)) { if (Start.CompareTo(other.Start) <= 0) { return(new IInterval <T>[] { Construct(Start, other.Start) }); } else { return(new IInterval <T>[] { Construct(other.End, End) }); } } else { return(new IInterval <T>[] { this }); } } }
/// <summary> /// Splits the interval at the provided value /// </summary> /// <typeparam name="T">Type of the interval values</typeparam> /// <param name="owningInterval">Owning interval</param> /// <param name="value">Value to split on</param> /// <returns>The splitted interval as an IEnumerable</returns> /// <exception cref="ArgumentNullException">Throws if any provided value is null</exception> /// <exception cref="ArgumentOutOfRangeException">Throws if the provided value is not within range of the owning interval</exception> public static IEnumerable <Interval <T> > Split <T>(this IInterval <T> owningInterval, T value) where T : IComparable <T> { if (owningInterval.Contains(value, true)) { yield return(new Interval <T>(owningInterval.Start, value)); yield return(new Interval <T>(value, owningInterval.Stop)); } else { throw new ArgumentOutOfRangeException(nameof(value), "Value to split on was not contained within the provided interval"); } }
private static void AddOverlappingTranscript(Status annotationStatus, ITranscript transcript, IInterval variant, IList <IOverlappingTranscript> overlappingTranscripts) { if (annotationStatus == Status.SvCompleteOverlapAnnotation) { overlappingTranscripts.Add(new OverlappingTranscript(transcript.Id, transcript.Gene.Symbol, transcript.IsCanonical, false)); } if (annotationStatus == Status.ReducedAnnotation) { var partialOverlap = !variant.Contains(transcript); overlappingTranscripts.Add(new OverlappingTranscript(transcript.Id, transcript.Gene.Symbol, transcript.IsCanonical, partialOverlap)); } }
private static IEnumerable <Interval <T> > RemoveCoveredEnumerator <T>(this SortedIntervals <T> intervals, ContainsMode mode = ContainsMode.NON_STRICT) { IInterval <T> current = null; foreach (var interval in intervals) { if (current == null) { current = interval; } else if (!current.Contains(interval, mode)) { yield return(interval); current = interval; } } }
/// <summary> /// Checks if two symbols overlap. /// </summary> /// <param name="other">Other.</param> public bool Overlaps(IInterval <SymbolAddress> other) { return(Contains(other.Start) || other.Contains(Start)); }
public bool IsSubsetOf(IInterval <TBound> other) { return(other.Contains(LowerBound) && other.Contains(UpperBound)); }
/// <summary> /// Determines whether the interval intersects with an other interval. /// </summary> /// <param name="other"> /// The interval to check for intersection with the current interval. /// </param> /// <returns> /// true if the interval intersects with an other interval; otherwise, false. /// </returns> public bool Intersects(IInterval <TBound> other) { return(Contains(other.LowerBound) || other.Contains(LowerBound)); }
public static bool IntersectsWith(this double value, IInterval <double> interval) => interval.Contains(value);