Shared local-alignment engine used by abivalidate and abiscreen.
Extracted from abivalidate.nim so both tools share one Smith-Waterman implementation, one reverse-complement/orientation-retry strategy, and one IUPAC ambiguity-code decoder instead of duplicating them.
Types
AlignConfig = object minIdentity*: float minCoverage*: float scoreMatch*: int scoreMismatch*: int scoreGap*: int
- Source Edit
AlignmentResult = object refName*: string refStart*: int refEnd*: int abiStart*: int abiEnd*: int score*: int identity*: float coverage*: float alignment*: string refAligned*: string abiAligned*: string isReverseComplement*: bool
- Source Edit
RefSequence = object name*: string sequence*: string
- Source Edit
Procs
proc defaultAlignConfig(): AlignConfig {....raises: [], tags: [], forbids: [].}
- Source Edit
proc findBestAlignment(abiSeq: string; abiQual: seq[int]; references: seq[RefSequence]; config: AlignConfig): ( RefSequence, AlignmentResult, seq[int]) {....raises: [ValueError], tags: [], forbids: [].}
-
Finds the best alignment of an ABI sequence against reference sequences.
Tries forward orientation first, then reverse complement if no good alignment is found. Returns the best reference, alignment result, and the quality scores in the same orientation as the aligned sequence (reversed if reverse complement was used).
Source Edit proc isAmbiguousBaseCompatible(ambiguousBase: char; refBase: char): bool {. ...raises: [], tags: [], forbids: [].}
- Check if an ambiguous base from ABI is compatible with reference base Source Edit
proc isValidNucleotide(base: char): bool {....raises: [], tags: [], forbids: [].}
- Check if base is a valid nucleotide (A, T, G, C) Source Edit
proc iupacAlleles(base: char): set[char] {....raises: [], tags: [], forbids: [].}
- Decodes an IUPAC nucleotide code into the set of alleles it represents. Unknown/invalid codes decode to the empty set. Source Edit
proc loadReference(filename: string): seq[RefSequence] {....raises: [], tags: [], forbids: [].}
- Loads named sequences from a (multi-)FASTA file. Source Edit
proc reverseComplement(sequence: string): string {....raises: [], tags: [], forbids: [].}
- Simple reverse complement function Source Edit
proc smithWaterman(seq1, seq2: string; matchScore, mismatchScore, gapScore: int): AlignmentResult {. ...raises: [], tags: [], forbids: [].}
- Local alignment of seq2 against seq1 (typically reference, abi read). Source Edit