MCPcopy Create free account
hub / github.com/alignoth/alignoth / intervals

Method intervals

src/highlight.rs:24–44  ·  view source on GitHub ↗
(&self, region: &Region)

Source from the content-addressed store, hash-verified

22
23impl Highlight for VcfHighlight {
24 fn intervals(&self, region: &Region) -> Result<Vec<Interval>> {
25 let mut reader = IndexedReader::from_path(&self.path)?;
26 let header = reader.header().clone();
27 let rid = header.name2rid(region.target.as_bytes())?;
28 reader.fetch(rid, region.start as u64, Some(region.end as u64))?;
29 let mut intervals = Vec::new();
30 for record in reader.records() {
31 let record = record?;
32 let position = record.pos() + 1; // Adjust for 1-based indexing
33 let alleles = record.alleles();
34 let end = position + alleles[0].len() as i64 - 1;
35 let ref_allele = std::str::from_utf8(alleles[0]).unwrap_or("?");
36 let alt_allele = std::str::from_utf8(alleles[1]).unwrap_or("?");
37 let mut id = format!("{}:{}>{}", position, ref_allele, alt_allele);
38 if record.id() != b"." {
39 id += &format!(":{}", std::str::from_utf8(&record.id())?);
40 }
41 intervals.push(Interval::new(id, position as f64, end as f64));
42 }
43 Ok(intervals)
44 }
45}
46
47pub(crate) struct BedHighlight {

Callers 4

mainFunction · 0.80
test_vcf_intervalsFunction · 0.80
test_bed_intervalsFunction · 0.80

Calls 3

OkFunction · 0.85
overlapsMethod · 0.80
cloneMethod · 0.45

Tested by 3

test_vcf_intervalsFunction · 0.64
test_bed_intervalsFunction · 0.64