private static void ParseLocation(XElement locEle, ISequenceRegion loc) { loc.Seqname = locEle.Attribute("seqname").Value; loc.Start = long.Parse(locEle.Attribute("start").Value); loc.End = long.Parse(locEle.Attribute("end").Value); loc.Strand = locEle.Attribute("strand").Value[0]; }
public SequenceRegion(ISequenceRegion source) { this.Seqname = source.Seqname; this.Start = source.Start; this.End = source.End; this.Name = source.Name; this.Strand = source.Strand; this.Sequence = source.Sequence; }
public bool HasOverlap(ISequenceRegion loc) { if (loc == null) { return(false); } return(this.Contains(loc.Start) || loc.Contains(this.Start)); }
public GtfItem(ISequenceRegion source) : this() { this.Name = source.Name; this.Seqname = source.Seqname; this.Start = source.Start; this.End = source.End; this.Strand = source.Strand; this.Sequence = source.Sequence; }
public static long Offset(this ISequenceRegion actual, ISequenceRegion reference) { if (reference.Strand == '-') { return(reference.End - actual.End); } else { return(actual.Start - reference.Start); } }
public static string GetDisplayName(this ISequenceRegion sr) { if (!string.IsNullOrEmpty(sr.Sequence)) { return(sr.Name + ":" + sr.Sequence); } else { return(sr.Name); } }
/// <summary> /// Check if two regions are container-containee. If one contains two, return 1. If two contains one, return -1. Otherwise return 0. /// </summary> /// <param name="one">first region</param> /// <param name="two">second region</param> /// <returns>result</returns> public static int Contains(this ISequenceRegion one, ISequenceRegion two) { if (one.Length >= two.Length) { if (one.Start <= two.Start && one.End >= two.End) { return(1); } return(0); } if (two.Start <= one.Start && two.End >= one.End) { return(-1); } return(0); }
public static double OverlapPercentage(this ISequenceRegion one, ISequenceRegion two) { if (!one.Seqname.Equals(two.Seqname)) { return(0.0); } ISequenceRegion first, second; if (one.Start < two.Start || (one.Start == two.Start && one.End > two.End)) { first = one; second = two; } else { first = two; second = one; } //no-overlap if (first.End < second.Start) { return(0.0); } //contain if (first.End >= second.End) { return(1.0); } //overlap var overlap = first.End - second.Start + 1.0; return(overlap / Math.Min(first.Length, second.Length)); }
public FeatureLocation(ISequenceRegion source) : base(source) { this.SamLocations = new List<FeatureSamLocation>(); }
public FeatureLocation(ISequenceRegion source) : base(source) { this.SamLocations = new List <FeatureSamLocation>(); }
public GtfItem(ISequenceRegion source) : this() { this.Name = source.Name; this.Seqname = source.Seqname; this.Start = source.Start; this.End = source.End; this.Strand = source.Strand; this.Sequence = source.Sequence; }
public void Union(ISequenceRegion loc) { this.Start = Math.Min(this.Start, loc.Start); this.End = Math.Max(this.End, loc.End); }
/// <summary> /// Get location using chrom:start-end:strand format /// </summary> /// <param name="sr"></param> /// <returns></returns> public static string GetLocation(this ISequenceRegion sr) { return(string.Format("{0}:{1}-{2}:{3}", sr.Seqname, sr.Start, sr.End, sr.Strand)); }
public static bool Overlap(this ISequenceRegion one, ISequenceRegion two, double minPercentage) { var perc = OverlapPercentage(one, two); return(perc > 0 && perc >= minPercentage); }
public static void UnionWith(this ISequenceRegion loc, ISequenceRegion item) { loc.Start = Math.Min(loc.Start, item.Start); loc.End = Math.Max(loc.End, item.End); }
/// <summary> /// Get name and location using (name)chrom:start-end:strand format /// </summary> /// <param name="sr"></param> /// <returns></returns> public static string GetNameLocation(this ISequenceRegion sr) { return(string.Format("({0}){1}", sr.Name, sr.GetLocation())); }