Helper for sparse encoding of a base track (A, T, G, C)
(&self, f: F)
| 252 | |
| 253 | /// Helper for sparse encoding of a base track (A, T, G, C) |
| 254 | fn encode_sparse<F>(&self, f: F) -> String |
| 255 | where |
| 256 | F: Fn(&BaseCoverage) -> usize, |
| 257 | { |
| 258 | self.0 |
| 259 | .iter() |
| 260 | .enumerate() |
| 261 | .filter_map(|(i, bc)| { |
| 262 | let cov = f(bc); |
| 263 | if cov > 0 { |
| 264 | Some(format!("{}|{}", i + 1, cov)) |
| 265 | } else { |
| 266 | None |
| 267 | } |
| 268 | }) |
| 269 | .collect::<Vec<_>>() |
| 270 | .join("$") |
| 271 | } |
| 272 | |
| 273 | pub fn a(&self) -> String { |
| 274 | self.encode_sparse(|bc| bc.a) |