/// Finds PCR primer oligonucleotide fragment in reference sequence. Returns position of the begin of the fragment
/// in the reference sequence and the corresponding fragment of reference sequence.
Finds PCR primer oligonucleotide fragment in reference sequence. Returns position of the begin of the fragment
in the reference sequence and the corresponding fragment of reference sequence.
Finds PCR primer oligonucleotide fragment in reference sequence . Returns position of the begin of the fragment in the reference sequence and the corresponding fragment of reference sequence .
pub fn find_primer_in_ref_seq(primer_oligonuc: &[Nuc], ref_seq_str: &str) -> Option<(usize, Vec<Nuc>)> {
  // Remove all non-ACGTN from the primer
  let primer_oligonuc_sanitized = from_nuc_seq(primer_oligonuc)
    .chars()
    .map(|nuc| if is_acgt_char(nuc) { nuc } else { '.' })
    .collect::<String>();
  match Regex::new(&primer_oligonuc_sanitized) {
    Err(report) => {
      warn!(
        "When compiling regular expression for PCR primer search: '{}': {}",
        primer_oligonuc_sanitized,
        report.to_string()
      );
      None
    }
    Ok(primer_regex) => {
      if let Some(captures) = primer_regex.captures(ref_seq_str) {
        captures
          .get(0)
          .map(|capture| (capture.start(), to_nuc_seq(capture.as_str()).unwrap()))
      } else {
        None
      }
    }
  }
}
pub fn find_primer_in_ref_seq ( primer_oligonuc : & [ Nuc ] , ref_seq_str : & str ) -> Option < ( usize , Vec < Nuc > ) > { // Remove all non-ACGTN from the primer let primer_oligonuc_sanitized = from_nuc_seq ( primer_oligonuc ) . chars ( ) . map ( | nuc | if is_acgt_char ( nuc ) { nuc } else { '.' } ) . collect :: < String > ( ) ; match Regex :: new ( & primer_oligonuc_sanitized ) { Err ( report ) => { warn ! ( " " primer_oligonuc_sanitized report to_string ( ) ) ; None } Ok ( primer_regex ) => { if let Some ( captures ) = primer_regex . captures ( ref_seq_str ) { captures . get ( 0 ) . map ( | capture | ( capture . start ( ) , to_nuc_seq ( capture . as_str ( ) ) . unwrap ( ) ) ) } else { None } } } }
Finds PCR primer oligonucleotide fragment in reference sequence.
Finds PCR primer oligonucleotide fragment in reference sequence .
primer_oligonuc
&[Nuc]
ref_seq_str
&str