crispr_analysis_utils.guide_alignment.iupac¶
crispr_analysis_utils.guide_alignment.iupac ¶
IUPAC nucleotide codes: complements and PAM patterns.
A PAM pattern such as NGG is a string of IUPAC codes. A genomic base
matches a code when it is one of the bases the code stands for; N matches
anything, a genomic N included, and a genomic N matches nothing else.
IUPAC_BASES
module-attribute
¶
IUPAC_BASES: dict[str, frozenset[str]] = {'A': frozenset('A'), 'C': frozenset('C'), 'G': frozenset('G'), 'T': frozenset('T'), 'R': frozenset('AG'), 'Y': frozenset('CT'), 'S': frozenset('CG'), 'W': frozenset('AT'), 'K': frozenset('GT'), 'M': frozenset('AC'), 'B': frozenset('CGT'), 'D': frozenset('AGT'), 'H': frozenset('ACT'), 'V': frozenset('ACG'), 'N': frozenset('ACGT')}
The bases each IUPAC nucleotide code stands for.
complement ¶
complement(sequence: str) -> str
Complement an IUPAC sequence, keeping its case.
Parameters:
-
sequence(str) –IUPAC nucleotide codes, in either case.
Returns:
-
str–Each code replaced by its complement (A-T, C-G, R-Y, K-M, B-V, D-H; S, W and N are their own complements). Characters outside the IUPAC alphabet are left unchanged.
Source code in src/crispr_analysis_utils/guide_alignment/iupac.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
reverse_complement ¶
reverse_complement(sequence: str) -> str
Reverse-complement an IUPAC sequence, keeping its case.
Parameters:
-
sequence(str) –IUPAC nucleotide codes, in either case.
Returns:
-
str–The complement (see
complement) read in reverse.
Source code in src/crispr_analysis_utils/guide_alignment/iupac.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
validate_pattern ¶
validate_pattern(pattern: str) -> str
Uppercase an IUPAC pattern and check its alphabet.
Parameters:
-
pattern(str) –IUPAC codes, such as
ngg.
Returns:
-
str–The pattern, uppercased.
Raises:
-
ValueError–If the pattern is empty or holds a character that is not an IUPAC nucleotide code.
Source code in src/crispr_analysis_utils/guide_alignment/iupac.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |