Boughter
boughter
¶
Boughter Dataset Loader
Loads preprocessed Boughter mouse antibody dataset.
IMPORTANT: This module is for LOADING preprocessed data, not for running the preprocessing pipeline. The preprocessing scripts that CREATE the data are in: preprocessing/boughter/stage2_stage3_annotation_qc.py
Dataset characteristics: - Full antibodies (VH + VL) - Mouse antibodies from 6 subsets (flu, hiv, gut, mouse IgA) - DNA sequences requiring translation to protein - Novo flagging strategy (0/1-¾+ flags) - 3-stage quality control pipeline - 16 fragment types (full antibody)
Processing Pipeline
Stage 1: DNA translation (FASTA → protein sequences) Stage 2: ANARCI annotation (riot_na) Stage 3: Post-annotation QC (filter X in CDRs, empty CDRs)
Source: - data/train/boughter/raw/ (multiple subsets) - Sequences in DNA format requiring translation
Reference: - Boughter et al., "Biochemical patterns of antibody polyreactivity revealed through a bioinformatics-based analysis of CDR loops"
Classes¶
BoughterDataset
¶
Bases: AntibodyDataset
Loader for Boughter mouse antibody dataset.
This class provides an interface to LOAD preprocessed Boughter dataset files. It does NOT run the preprocessing pipeline - use preprocessing/boughter/stage2_stage3_annotation_qc.py for that.
The Boughter dataset originally requires DNA translation before standard preprocessing. Sequences are provided as DNA in FASTA format and must be translated to protein sequences using a hybrid translation strategy (done by preprocessing scripts).
Source code in src/antibody_training_esm/datasets/boughter.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
Functions¶
get_fragment_types()
¶
Return full antibody fragment types.
Boughter contains VH + VL sequences, so we generate all 16 fragment types.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of 16 full antibody fragment types |
Source code in src/antibody_training_esm/datasets/boughter.py
load_data(processed_csv=None, subset=None, include_mild=False, **_)
¶
Load Boughter dataset from processed CSV.
Note: This assumes DNA translation has already been performed. For DNA translation from FASTA files, use the preprocessing scripts in preprocessing/boughter/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_csv
|
str | Path | None
|
Path to processed CSV with protein sequences |
None
|
subset
|
str | None
|
Specific subset to load (flu, hiv_nat, etc.) or None for all |
None
|
include_mild
|
bool
|
If True, include mild (1-3 flags). Default False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: id, VH_sequence, VL_sequence, label, flags, include_in_training |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If processed CSV not found |
Source code in src/antibody_training_esm/datasets/boughter.py
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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
translate_dna_to_protein(dna_sequence)
¶
This method is NOT IMPLEMENTED and will always raise an error.
DNA translation logic belongs in the preprocessing scripts, not in dataset loader classes. Loaders are for LOADING preprocessed data, not for creating it.
For DNA translation, use: preprocessing/boughter/stage1_dna_translation.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dna_sequence
|
str
|
DNA sequence string (unused - always raises) |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always - this method intentionally does nothing |
Source code in src/antibody_training_esm/datasets/boughter.py
filter_quality_issues(df)
¶
Stage 3 QC: Filter sequences with quality issues.
Removes: - Sequences with X in CDRs (ambiguous amino acids) - Sequences with empty CDRs - Invalid annotations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Annotated DataFrame |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered DataFrame |
Source code in src/antibody_training_esm/datasets/boughter.py
Functions¶
load_boughter_data(processed_csv=None, subset=None, include_mild=False)
¶
Convenience function to load preprocessed Boughter dataset.
IMPORTANT: This loads PREPROCESSED data. To preprocess raw data, use: preprocessing/boughter/stage2_stage3_annotation_qc.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_csv
|
str | None
|
Path to processed CSV with protein sequences |
None
|
subset
|
str | None
|
Specific subset to load or None for all |
None
|
include_mild
|
bool
|
If True, include mild (1-3 flags) |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with preprocessed data |
Example
from antibody_training_esm.datasets.boughter import load_boughter_data df = load_boughter_data(include_mild=False) # Novo flagging print(f"Loaded {len(df)} sequences")