/// Parses nucleotide substitution from string. Expects IUPAC notation commonly used in bioinformatics.
Parses nucleotide substitution from string. Expects IUPAC notation commonly used in bioinformatics.
Parses nucleotide substitution from string . Expects IUPAC notation commonly used in bioinformatics .
fn from_str(s: &str) -> Result<Self, Self::Err> {
    lazy_static! {
      static ref RE: Regex = Regex::new(NUC_MUT_REGEX)
        .wrap_err_with(|| format!("When compiling regular expression '{NUC_MUT_REGEX}'"))
        .unwrap();
    }
    if let Some(captures) = RE.captures(s) {
      return match (captures.name("ref"), captures.name("pos"), captures.name("qry")) {
        (Some(reff), Some(pos), Some(qry)) => {
          let reff = Nuc::from_string(reff.as_str())?;
          let pos = parse_pos(pos.as_str())?;
          let qry = Nuc::from_string(qry.as_str())?;
          Ok(Self { reff, pos, qry })
        }
        _ => make_error!("Unable to parse nucleotide mutation: '{s}'"),
      };
    }
    make_error!("Unable to parse nucleotide mutation: '{s}'")
  }
fn from_str ( s : & str ) -> Result < Self , Self :: Err > { lazy_static ! { static ref RE Regex Regex new ( NUC_MUT_REGEX ) wrap_err_with ( format ( " " ) ) unwrap ( ) } if let Some ( captures ) = RE . captures ( s ) { return match ( captures . name ( " " ) , captures . name ( " " ) , captures . name ( " " ) ) { ( Some ( reff ) , Some ( pos ) , Some ( qry ) ) => { let reff = Nuc :: from_string ( reff . as_str ( ) ) ? ; let pos = parse_pos ( pos . as_str ( ) ) ? ; let qry = Nuc :: from_string ( qry . as_str ( ) ) ? ; Ok ( Self { reff , pos , qry } ) } _ => make_error ! ( " " ) , } ; } make_error ! ( " " ) }
Parses nucleotide substitution from string.
Parses nucleotide substitution from string .
s
&str