mecfs_bio.build_system.task.genome_reference_harmonization.allele_classes
Per-row allele classes relative to the genome reference.
Equal-length variants (SNVs, MNPs) are compared on the plus strand. The reverse complement is consulted only when neither plus-strand allele matches, as gwaslab does. Different-length variants (indels) are compared on the plus strand only: a reverse-complemented left-anchored indel loses its anchor base, so a minus-strand match would be spurious.
AlleleClass is what the type checker sees; the CLASS_* constants are what code uses. An import-time assertion keeps the two in step (see outcomes.py for why this is not a StrEnum).
Functions:
-
classify_alleles–Add ALLELE_CLASS_COL and the palindrome flags to rows with valid, uppercase alleles.
-
prepare_alleles–Alleles as uppercase strings and positions as Int64.
-
reverse_complement_expr– -
valid_alleles_expr–
Attributes:
-
ALLELE_CLASS_COL– -
AlleleClass– -
CLASS_EA_REF(Final[AlleleClass]) – -
CLASS_EA_REF_RC(Final[AlleleClass]) – -
CLASS_INDEL_BOTH(Final[AlleleClass]) – -
CLASS_INDEL_EA_ONLY(Final[AlleleClass]) – -
CLASS_INDEL_NEA_ONLY(Final[AlleleClass]) – -
CLASS_INDEL_NOT_ON_REFERENCE(Final[AlleleClass]) – -
CLASS_NEA_REF(Final[AlleleClass]) – -
CLASS_NEA_REF_RC(Final[AlleleClass]) – -
CLASS_NOT_ON_REFERENCE(Final[AlleleClass]) – -
IS_PALINDROMIC_MNP_COL– -
IS_PALINDROMIC_SNV_COL–
AlleleClass
module-attribute
AlleleClass = Literal[
"nea_ref",
"ea_ref",
"nea_ref_rc",
"ea_ref_rc",
"not_on_reference",
"indel_both",
"indel_nea_only",
"indel_ea_only",
"indel_not_on_reference",
]
CLASS_INDEL_NOT_ON_REFERENCE
module-attribute
CLASS_NOT_ON_REFERENCE
module-attribute
classify_alleles
classify_alleles(
frame: DataFrame,
fasta: IndexedFasta,
chrom: int,
max_gather_bytes: int,
) -> pl.DataFrame
Add ALLELE_CLASS_COL and the palindrome flags to rows with valid, uppercase alleles.
Source code in mecfs_bio/build_system/task/genome_reference_harmonization/allele_classes.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
prepare_alleles
Alleles as uppercase strings and positions as Int64.