/** * @param bases bases representing a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final byte[] bases) { return acceptableAlleleBases(bases, true); }
/** * @param bases bases representing an allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(byte[] bases) { return acceptableAlleleBases(bases, true); // default: N bases are acceptable }
/** * @param bases bases representing a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final byte[] bases) { return acceptableAlleleBases(bases, true); }
/** * @param bases bases representing an allele * @param isReferenceAllele is a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final String bases, boolean isReferenceAllele) { return acceptableAlleleBases(bases.getBytes(), isReferenceAllele); }
/** * @param bases bases representing a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final String bases) { return acceptableAlleleBases(bases.getBytes(), true); }
/** * @param bases bases representing an allele * @param isReferenceAllele is a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final String bases, boolean isReferenceAllele) { return acceptableAlleleBases(bases.getBytes(), isReferenceAllele); }
/** * @param bases bases representing an allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(String bases) { return acceptableAlleleBases(bases.getBytes(), true); }
/** * @param bases bases representing a reference allele * @return true if the bases represent the well formatted allele */ public static boolean acceptableAlleleBases(final String bases) { return acceptableAlleleBases(bases.getBytes(), true); }
public static boolean acceptableAlleleBases(String bases, boolean allowNsAsAcceptable) { return acceptableAlleleBases(bases.getBytes(), allowNsAsAcceptable); }
protected Allele(final byte[] bases, final boolean isRef) { // null alleles are no longer allowed if ( wouldBeNullAllele(bases) ) { throw new IllegalArgumentException("Null alleles are not supported"); } // no-calls are represented as no bases if ( wouldBeNoCallAllele(bases) ) { this.bases = EMPTY_ALLELE_BASES; isNoCall = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a NoCall allele as the reference allele"); return; } if ( wouldBeSymbolicAllele(bases) ) { isSymbolic = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a symbolic allele as the reference allele"); } else { StringUtil.toUpperCase(bases); } this.isRef = isRef; this.bases = bases; if ( ! acceptableAlleleBases(bases, isRef) ) throw new IllegalArgumentException("Unexpected base in allele bases \'" + new String(bases)+"\'"); }
protected Allele(final byte[] bases, final boolean isRef) { // null alleles are no longer allowed if ( wouldBeNullAllele(bases) ) { throw new IllegalArgumentException("Null alleles are not supported"); } // no-calls are represented as no bases if ( wouldBeNoCallAllele(bases) ) { this.bases = EMPTY_ALLELE_BASES; isNoCall = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a NoCall allele as the reference allele"); return; } if ( wouldBeSymbolicAllele(bases) ) { isSymbolic = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a symbolic allele as the reference allele"); } else { StringUtil.toUpperCase(bases); } this.isRef = isRef; this.bases = bases; if ( ! acceptableAlleleBases(bases, isRef) ) throw new IllegalArgumentException("Unexpected base in allele bases \'" + new String(bases)+"\'"); }
/** A generic static NO_CALL allele for use */ // no public way to create an allele protected Allele(byte[] bases, boolean isRef) { // null alleles are no longer allowed if ( wouldBeNullAllele(bases) ) { throw new IllegalArgumentException("Null alleles are not supported"); } // no-calls are represented as no bases if ( wouldBeNoCallAllele(bases) ) { this.bases = EMPTY_ALLELE_BASES; isNoCall = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a NoCall allele as the reference allele"); return; } if ( wouldBeSymbolicAllele(bases) ) { isSymbolic = true; if ( isRef ) throw new IllegalArgumentException("Cannot tag a symbolic allele as the reference allele"); } else { StringUtil.toUpperCase(bases); } this.isRef = isRef; this.bases = bases; if ( ! acceptableAlleleBases(bases) ) throw new IllegalArgumentException("Unexpected base in allele bases \'" + new String(bases)+"\'"); }
/** * check to make sure the allele is an acceptable allele * @param allele the allele to check * @param isRef are we the reference allele? * @param lineNo the line number for this record */ private static void checkAllele(String allele, boolean isRef, int lineNo) { if ( allele == null || allele.length() == 0 ) generateException(generateExceptionTextForBadAlleleBases(""), lineNo); if ( GeneralUtils.DEBUG_MODE_ENABLED && MAX_ALLELE_SIZE_BEFORE_WARNING != -1 && allele.length() > MAX_ALLELE_SIZE_BEFORE_WARNING ) { System.err.println(String.format("Allele detected with length %d exceeding max size %d at approximately line %d, likely resulting in degraded VCF processing performance", allele.length(), MAX_ALLELE_SIZE_BEFORE_WARNING, lineNo)); } if ( isSymbolicAllele(allele) ) { if ( isRef ) { generateException("Symbolic alleles not allowed as reference allele: " + allele, lineNo); } } else { // check for VCF3 insertions or deletions if ( (allele.charAt(0) == VCFConstants.DELETION_ALLELE_v3) || (allele.charAt(0) == VCFConstants.INSERTION_ALLELE_v3) ) generateException("Insertions/Deletions are not supported when reading 3.x VCF's. Please" + " convert your file to VCF4 using VCFTools, available at http://vcftools.sourceforge.net/index.html", lineNo); if (!Allele.acceptableAlleleBases(allele)) generateException(generateExceptionTextForBadAlleleBases(allele), lineNo); if ( isRef && allele.equals(VCFConstants.EMPTY_ALLELE) ) generateException("The reference allele cannot be missing", lineNo); } }
/** * check to make sure the allele is an acceptable allele * @param allele the allele to check * @param isRef are we the reference allele? * @param lineNo the line number for this record */ private static void checkAllele(String allele, boolean isRef, int lineNo) { if ( allele == null || allele.isEmpty() ) generateException(generateExceptionTextForBadAlleleBases(""), lineNo); if ( GeneralUtils.DEBUG_MODE_ENABLED && MAX_ALLELE_SIZE_BEFORE_WARNING != -1 && allele.length() > MAX_ALLELE_SIZE_BEFORE_WARNING ) { System.err.println(String.format("Allele detected with length %d exceeding max size %d at approximately line %d, likely resulting in degraded VCF processing performance", allele.length(), MAX_ALLELE_SIZE_BEFORE_WARNING, lineNo)); } if ( isSymbolicAllele(allele) ) { if ( isRef ) { generateException("Symbolic alleles not allowed as reference allele: " + allele, lineNo); } } else { // check for VCF3 insertions or deletions if ( (allele.charAt(0) == VCFConstants.DELETION_ALLELE_v3) || (allele.charAt(0) == VCFConstants.INSERTION_ALLELE_v3) ) generateException("Insertions/Deletions are not supported when reading 3.x VCF's. Please" + " convert your file to VCF4 using VCFTools, available at http://vcftools.sourceforge.net/index.html", lineNo); if (!Allele.acceptableAlleleBases(allele, isRef)) generateException(generateExceptionTextForBadAlleleBases(allele), lineNo); if ( isRef && allele.equals(VCFConstants.EMPTY_ALLELE) ) generateException("The reference allele cannot be missing", lineNo); } }
/** * check to make sure the allele is an acceptable allele * @param allele the allele to check * @param isRef are we the reference allele? * @param lineNo the line number for this record */ private static void checkAllele(String allele, boolean isRef, int lineNo) { if ( allele == null || allele.isEmpty() ) generateException(generateExceptionTextForBadAlleleBases(""), lineNo); if ( GeneralUtils.DEBUG_MODE_ENABLED && MAX_ALLELE_SIZE_BEFORE_WARNING != -1 && allele.length() > MAX_ALLELE_SIZE_BEFORE_WARNING ) { System.err.println(String.format("Allele detected with length %d exceeding max size %d at approximately line %d, likely resulting in degraded VCF processing performance", allele.length(), MAX_ALLELE_SIZE_BEFORE_WARNING, lineNo)); } if ( isSymbolicAllele(allele) ) { if ( isRef ) { generateException("Symbolic alleles not allowed as reference allele: " + allele, lineNo); } } else { // check for VCF3 insertions or deletions if ( (allele.charAt(0) == VCFConstants.DELETION_ALLELE_v3) || (allele.charAt(0) == VCFConstants.INSERTION_ALLELE_v3) ) generateException("Insertions/Deletions are not supported when reading 3.x VCF's. Please" + " convert your file to VCF4 using VCFTools, available at http://vcftools.sourceforge.net/index.html", lineNo); if (!Allele.acceptableAlleleBases(allele, isRef)) generateException(generateExceptionTextForBadAlleleBases(allele), lineNo); if ( isRef && allele.equals(VCFConstants.EMPTY_ALLELE) ) generateException("The reference allele cannot be missing", lineNo); } }
final byte[] refBases = Arrays.copyOfRange(ref.getBases(), startIdxInReference - 1, startIdxInReference + dLen); // add reference padding if (Allele.acceptableAlleleBases(refBases, false)) { refAllele = Allele.create(refBases, true); altAllele = Allele.create(ref.getBase(), false); if (Allele.acceptableAlleleBases(insertionBases, false)) { // don't allow N's in insertions refAllele = Allele.create(ref.getBase(), true); altAllele = Allele.create(insertionBases, false);
} else { if ( !Allele.acceptableAlleleBases(new byte[]{ref.getBase()}) ) return null; final Set<Allele> alleles = new HashSet<>(Collections.singleton(Allele.create(ref.getBase(),true)));