
Strip redundant alleles from typing string if higher resolution is available
Source:R/clean_hla.R
strip_redundant.RdSometimes a typing will contain multiple "versions" of an allele at different
levels of resolution. Most commonly this is both the split and the broad,
e.g. A24(9) or A10 A25. The latter can cause a typing to contain more
than 2 alleles for a given locus, which cannot be handled with
extract_alleles_str(); the former is not accepted by validate_allele().
Besides, the broads are redundant in this case, and can always be added back
with get_broad(). Sometimes even three "versions" are included: the split,
the broad, and the two-field allele, e.g. DR5 DR11 DRB1*11:03.
Examples
strip_redundant("A24(9)")
#> [1] "A24"
strip_redundant("A9(24)") # also works when the split is in parentheses
#> [1] "A24"
strip_redundant("A24(9) A10 A25") # removes both A9 and A10
#> [1] "A24 A25"
strip_redundant("DR5 DR11 DRB1*11:03") # removes both the split and the broad
#> [1] "DRB1*11:03"
# also works on character vectors
strip_redundant(c("A24(9)", "A25(10)"))
#> [1] "A24" "A25"