@@ -128,8 +128,12 @@ public Allele getRenamedAllele(VariantContext vc, Allele toCheck)
128128 throw new IllegalArgumentException ("Ref not found at pos " + _start + ": " + vc .toStringWithoutGenotypes () + ", existing: " + StringUtils .join (_encounteredAlleles .keySet (), ";" ));
129129 }
130130
131- Allele ret = map .get (toCheck );
132- return ret == null ? toCheck : ret ;
131+ if (!map .containsKey (toCheck ))
132+ {
133+ throw new IllegalArgumentException ("Allele not found at pos " + _start + ": " + vc .toStringWithoutGenotypes () + " for allele: " + toCheck .getBaseString () + ", existing: " + map .keySet ().stream ().map (x -> x .getBaseString () + "-" + map .get (x ).getBaseString ()).collect (Collectors .joining (";" )));
134+ }
135+
136+ return map .get (toCheck );
133137 }
134138
135139 private String getEncounteredKey (int start , Allele ref )
@@ -142,8 +146,12 @@ public void addSite(VariantContext vc, Logger log)
142146 Map <Allele , Allele > alleles = _encounteredAlleles .getOrDefault (getEncounteredKey (vc .getStart (), vc .getReference ()), new HashMap <>());
143147 vc .getAlternateAlleles ().forEach (a -> {
144148 Allele translated = extractAlleleForPosition (vc , a , log );
145- if (!alleles .containsKey (a ))
146- alleles .put (a , translated );
149+ if (alleles .containsKey (a ) && alleles .get (a ) != null && !alleles .get (a ).equals (translated ))
150+ {
151+ throw new IllegalArgumentException ("Translated allele does not match at pos " + _start + ": " + vc .toStringWithoutGenotypes () + " for allele: " + a .getBaseString () + ", existing: " + alleles .keySet ().stream ().map (x -> x .getBaseString () + "-" + alleles .get (x ).getBaseString ()).collect (Collectors .joining (";" )));
152+ }
153+
154+ alleles .put (a , translated );
147155
148156 if (translated != null && !_alternates .contains (translated ))
149157 _alternates .add (translated );
0 commit comments