1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
pub use crate::chrom::Chrom;
use crate::dict::Dictionary;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Header {
pub(crate) chrom_list: Vec<Chrom>,
pub(crate) dictionary: Dictionary,
}
impl Header {
pub fn new() -> Self {
Header {
chrom_list: vec![],
dictionary: Dictionary::SimpleRange { low: 0, high: 64 },
}
}
pub fn dictionary(&self) -> &Dictionary {
&self.dictionary
}
pub fn chrom_list(&self) -> &[Chrom] {
self.chrom_list.as_ref()
}
pub fn set_chrom_list(&mut self, new_value: Vec<Chrom>) {
self.chrom_list = new_value
}
pub(crate) fn primary_table_size(&self) -> usize {
let bit_width = self.dictionary.bit_width();
self.chrom_list
.iter()
.map(|chr| (chr.size as usize * bit_width + 7) / 8)
.sum()
}
}