Skip to content

Commit

Permalink
fix: error on sequence complement when lowercase
Browse files Browse the repository at this point in the history
nt in fasta file
  • Loading branch information
sharkLoc authored and zaeleus committed May 26, 2024
1 parent 052db76 commit b782045
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions noodles-fasta/src/record/sequence/complement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ fn complement(b: u8) -> Result<u8, ComplementError> {
b'H' => Ok(b'D'),
b'V' => Ok(b'B'),
b'N' => Ok(b'N'),
b'a' => Ok(b't'),
b'c' => Ok(b'g'),
b'g' => Ok(b'c'),
b't' => Ok(b'a'),
b'u' => Ok(b'a'),
b'w' => Ok(b'w'),
b's' => Ok(b's'),
b'm' => Ok(b'k'),
b'k' => Ok(b'm'),
b'r' => Ok(b'y'),
b'y' => Ok(b'r'),
b'b' => Ok(b'v'),
b'd' => Ok(b'h'),
b'h' => Ok(b'd'),
b'v' => Ok(b'b'),
b'n' => Ok(b'n'),

_ => Err(ComplementError(b)),
}
}
Expand Down Expand Up @@ -96,6 +113,22 @@ mod tests {
assert_eq!(complement(b'H'), Ok(b'D'));
assert_eq!(complement(b'V'), Ok(b'B'));
assert_eq!(complement(b'N'), Ok(b'N'));
assert_eq!(complement(b'a'), Ok(b't'));
assert_eq!(complement(b'c'), Ok(b'g'));
assert_eq!(complement(b'g'), Ok(b'c'));
assert_eq!(complement(b't'), Ok(b'a'));
assert_eq!(complement(b'u'), Ok(b'a'));
assert_eq!(complement(b'w'), Ok(b'w'));
assert_eq!(complement(b's'), Ok(b's'));
assert_eq!(complement(b'm'), Ok(b'k'));
assert_eq!(complement(b'k'), Ok(b'm'));
assert_eq!(complement(b'r'), Ok(b'y'));
assert_eq!(complement(b'y'), Ok(b'r'));
assert_eq!(complement(b'b'), Ok(b'v'));
assert_eq!(complement(b'd'), Ok(b'h'));
assert_eq!(complement(b'h'), Ok(b'd'));
assert_eq!(complement(b'v'), Ok(b'b'));
assert_eq!(complement(b'n'), Ok(b'n'));
assert_eq!(complement(b'X'), Err(ComplementError(b'X')));
}
}

0 comments on commit b782045

Please sign in to comment.