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

Method from_str

src/plot.rs:408–452  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

406 type Err = anyhow::Error;
407
408 fn from_str(s: &str) -> Result<Self> {
409 let mut inner_cigars = Vec::new();
410 for inner in s.split('|') {
411 let inner_cigar = match inner.chars().last() {
412 Some('=') => {
413 let length = inner.chars().take(inner.len() - 1).collect::<String>();
414 InnerPlotCigar {
415 cigar_type: CigarType::Match,
416 bases: None,
417 length: Some(u32::from_str(&length).unwrap()),
418 }
419 }
420 Some('d') => {
421 let length = inner.chars().take(inner.len() - 1).collect::<String>();
422 InnerPlotCigar {
423 cigar_type: CigarType::Del,
424 bases: None,
425 length: Some(u32::from_str(&length).unwrap()),
426 }
427 }
428 _ => {
429 if inner.starts_with('i') {
430 InnerPlotCigar {
431 cigar_type: CigarType::Ins,
432 bases: Some(inner.chars().skip(1).collect()),
433 length: None,
434 }
435 } else {
436 InnerPlotCigar {
437 cigar_type: CigarType::Sub,
438 bases: Some(vec![inner.chars().last().unwrap()]),
439 length: Some(
440 u32::from_str(
441 &inner.chars().take(inner.len() - 1).collect::<String>(),
442 )
443 .unwrap(),
444 ),
445 }
446 }
447 }
448 };
449 inner_cigars.push(inner_cigar);
450 }
451 Ok(PlotCigar(inner_cigars))
452 }
453}
454
455#[derive(Serialize, Debug, Eq, PartialEq)]

Callers

nothing calls this directly

Calls 2

OkFunction · 0.85
PlotCigarClass · 0.85

Tested by

no test coverage detected