Skip to main content

complement_base

Function complement_base 

Source
pub const fn complement_base(base: u8) -> u8
Expand description

Complements a single DNA base, normalizing to uppercase except for N/n.

Returns the Watson-Crick complement: A<->T, C<->G. Both uppercase and lowercase A/T/C/G input are normalized to uppercase output.

§Case preservation for N/n

Uppercase ‘N’ and lowercase ‘n’ are returned unchanged (case preserved). This is required for fgbio compatibility in CODEC consensus calling:

  • CODEC uses lowercase ‘n’ for padding when R1/R2 have different lengths (see codec_caller::pad_consensus). These padded bases are then reverse complemented for ac/bc tags (see codec_caller::reverse_complement_ss). fgbio preserves lowercase ‘n’ through this operation.

  • Simplex/Duplex use only uppercase ‘N’ for no-call bases in production (see vanilla_caller lines 640, 1024, 1078 and duplex_caller NO_CALL const). The padded_default function with lowercase ‘n’ exists but is only used in tests.

  • Zipper/tag_reversal do not create ‘n’ bases, only reverse complement existing tag values which come from upstream processing.