gtars_core/models/
fragments.rs1use std::str::FromStr;
2
3use anyhow::Result;
4
5use crate::models::Region;
6
7#[allow(unused)]
8pub struct Fragment {
9 pub chr: String,
10 pub start: u32,
11 pub end: u32,
12 pub barcode: String,
13 pub read_support: u32,
14}
15
16impl FromStr for Fragment {
17 type Err = anyhow::Error;
18
19 fn from_str(s: &str) -> Result<Self> {
20 let parts: Vec<&str> = s.split_whitespace().collect();
21 let start = parts[1].parse::<u32>()?;
31 let end = parts[2].parse::<u32>()?;
32 let read_support = parts[4].parse::<u32>()?;
33
34 Ok(Fragment {
35 chr: parts[0].to_string(),
36 start,
37 end,
38 barcode: parts[3].to_string(),
39 read_support,
40 })
41 }
42}
43
44impl From<Fragment> for Region {
45 fn from(val: Fragment) -> Self {
46 Region {
47 chr: val.chr,
48 start: val.start,
49 end: val.end,
50 rest: None,
51 }
52 }
53}