CRAM.Reference.MD5 (cram v0.1.0)

Copy Markdown View Source

SAM reference checksum.

The MD5 is taken over the sequence with ASCII whitespace removed and letters upper-cased. That is the M5 rule used by SAM @SQ lines.

Summary

Functions

Lower-case hex MD5 of normalize/1.

Upper-case sequence and remove whitespace, which is the SAM M5 input.

True when md5 is 32 hexadecimal digits.

Functions

hex(sequence)

@spec hex(binary()) :: String.t()

Lower-case hex MD5 of normalize/1.

sequence is a binary. Returns 32 hex digits. Does not raise.

iex> CRAM.Reference.MD5.hex("tt ca\nccca")
"be19336b7e15968f7ac7dc82493d9cd8"

normalize(sequence)

@spec normalize(binary()) :: binary()

Upper-case sequence and remove whitespace, which is the SAM M5 input.

sequence is a binary. Returns the normalized binary. Does not raise.

iex> CRAM.Reference.MD5.normalize("tt ca\nccca")
"TTCACCCA"

valid_hex?(md5)

@spec valid_hex?(term()) :: boolean()

True when md5 is 32 hexadecimal digits.

Any other term, including a shorter string, is false. Does not raise.

iex> CRAM.Reference.MD5.valid_hex?("be19336b7e15968f7ac7dc82493d9cd8")
true
iex> CRAM.Reference.MD5.valid_hex?("nope")
false