pub struct Region {
pub chr: String,
pub start: u32,
pub end: u32,
pub rest: Option<String>,
}Expand description
Region struct, representation of one Region in RegionSet files
Fields§
§chr: String§start: u32§end: u32§rest: Option<String>Implementations§
Source§impl Region
impl Region
Sourcepub fn mid_point(&self) -> u32
pub fn mid_point(&self) -> u32
Calculate the midpoint of this region: start + width / 2.
NOTE: R’s GenomicDistributions computes midpoints using banker’s
rounding in 1-based coordinates: start + round((end - start) / 2).
For regions with width ≡ 2 (mod 4), this picks the left-of-center
base while our formula picks right-of-center, causing a ±1 bp
difference in ~2.6% of feature distance calculations. This is a
known discrepancy; to match GD exactly, change the formula to:
if w % 4 == 2 { start + w/2 - 1 } else { start + w/2 }.
Sourcepub fn mid_point_with_mode(&self, mode: CoordinateMode) -> u32
pub fn mid_point_with_mode(&self, mode: CoordinateMode) -> u32
Calculate midpoint using the specified coordinate convention.
Bed(default): floor division →start + width / 2GRanges: banker’s rounding in 1-based coords →if w % 4 == 2 { start + w/2 - 1 } else { start + w/2 }
Sourcepub fn distance_to(&self, other: &Region) -> i64
pub fn distance_to(&self, other: &Region) -> i64
Gap distance between two regions.
Returns 0 if the regions overlap, otherwise returns the positive gap (in bases) between the closer edges of the two regions.