Files
obitools4/autodoc/docmd/pkg/obiseq/iupac_nog.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

28 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Semantic Description of `obiseq` Package
The `obiseq` package provides utilities for handling **IUPAC nucleotide ambiguity codes** in biological sequences.
## Core Components
- `_iupac`: A lookup table mapping lowercase ASCII letters (`a``z`) to numeric IUPAC nucleotide codes:
- `A=1`, `C=2`, `G=4`, `T/U=8` (standard bases)
- Ambiguous codes are bitwise OR combinations:
e.g., `R = A|G = 1+4=5`, `Y = C|T = 2+8=10`, etc.
- Invalid or non-nucleotide characters map to `0`.
## Key Functionality
### `SameIUPACNuc(a, b byte) bool`
Performs **case-insensitive comparison** of two nucleotide symbols using IUPAC ambiguity rules.
- Converts uppercase letters to lowercase via bitwise OR (`|= 32`).
- For valid nucleotides, checks if their IUPAC codes have **non-zero bitwise AND**:
- Returns `true` only if the symbols share at least one possible base.
*Example*: `'R' & 'A' → (5 & 1) = 1 > 0 ⇒ true`
`'Y' & 'G' → (10 & 4) = 0 ⇒ false`
- For non-IUPAC or invalid characters, falls back to exact equality (`a == b`).
## Use Case
Enables robust comparison of DNA/RNA sequences where ambiguity codes (e.g., `N`, `R`, `W`) are used—critical for alignment, variant calling, or primer design tools.