Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

Commit a0f8fbe

Browse files
committed
Added IUPAC ambuguity codes fix in REF for complex/deletions .
1 parent db38bfe commit a0f8fbe

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/main/java/com/astrazeneca/vardict/modules/ToVarsBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,19 @@ else if (deletionLength < instance().conf.SVMINLEN) {
993993
}
994994
}
995995

996+
/**
997+
* Validate reference allele according to VCF 4.3 specification in case if IUPAC ambiguity codes are present
998+
* in reference.
999+
* @param refallele sequence of reference bases that covers variant
1000+
* @return reference allele sequence where IUPAC ambuguity bases are changed to the one that is
1001+
* first alphabetically.
1002+
*/
9961003
String validateRefallele(String refallele) {
997-
if (IUPAC_AMBIGUITY_CODES.containsKey(refallele)){
998-
refallele = IUPAC_AMBIGUITY_CODES.get(refallele);
1004+
for (int i = 0; i < refallele.length(); i++) {
1005+
String refBase = substr(refallele, i, 1);
1006+
if (IUPAC_AMBIGUITY_CODES.containsKey(refBase)) {
1007+
refallele = refallele.replaceFirst(refBase, IUPAC_AMBIGUITY_CODES.get(refBase));
1008+
}
9991009
}
10001010
return refallele;
10011011
}

src/test/java/com/astrazeneca/vardict/modules/ToVarsBuilderTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,14 @@ public void testValidateRefAllele(){
139139
validatedAlleles.add(toVarsBuilder.validateRefallele(allele));
140140
}
141141
assertEquals(validatedAlleles, expected);
142+
143+
List<String> alleles_complex = Arrays.asList("ANYCGT", "MRACT", "CCGKBG");
144+
List<String> expected_complex = Arrays.asList("ANCCGT", "AAACT", "CCGGCG");
145+
146+
validatedAlleles = new ArrayList<>();
147+
for (String allele: alleles_complex) {
148+
validatedAlleles.add(toVarsBuilder.validateRefallele(allele));
149+
}
150+
assertEquals(validatedAlleles, expected_complex);
142151
}
143152
}

0 commit comments

Comments
 (0)