Class SimpleAllele

java.lang.Object
htsjdk.variant.variantcontext.SimpleAllele
All Implemented Interfaces:
Allele, Serializable, Comparable<Allele>

public class SimpleAllele extends Object implements Allele
An implementation of Allele which includes a byte[] of the bases in the allele or the symbolic name. This has been made public as a base for classes which need to subclass Allele. Most users should create alleles using Allele.create(byte[]) instead of interacting with this class directly.
See Also:
  • Constructor Details

    • SimpleAllele

      protected SimpleAllele(byte[] bases, boolean isRef)
    • SimpleAllele

      protected SimpleAllele(String bases, boolean isRef)
    • SimpleAllele

      protected SimpleAllele(SimpleAllele allele, boolean ignoreRefState)
      Creates a new allele based on the provided one. Ref state will be copied unless ignoreRefState is true (in which case the returned allele will be non-Ref). This method is efficient because it can skip the validation of the bases (since the original allele was already validated)
      Parameters:
      allele - the allele from which to copy the bases
      ignoreRefState - should we ignore the reference state of the input allele and use the default ref state?
  • Method Details

    • isPrefixOf

      public boolean isPrefixOf(Allele other)
      Specified by:
      isPrefixOf in interface Allele
    • isNoCall

      public boolean isNoCall()
      Specified by:
      isNoCall in interface Allele
      Returns:
      true if this is the NO_CALL allele
    • isCalled

      public boolean isCalled()
      Specified by:
      isCalled in interface Allele
    • isReference

      public boolean isReference()
      Specified by:
      isReference in interface Allele
      Returns:
      true if this Allele is the reference allele
    • isNonReference

      public boolean isNonReference()
      Specified by:
      isNonReference in interface Allele
      Returns:
      true if this Allele is not the reference allele
    • isSymbolic

      public boolean isSymbolic()
      Specified by:
      isSymbolic in interface Allele
      Returns:
      true if this Allele is symbolic (i.e. no well-defined base sequence), this includes breakpoints and breakends
    • isBreakpoint

      public boolean isBreakpoint()
      Specified by:
      isBreakpoint in interface Allele
      Returns:
      true if this Allele is a breakpoint ( ex: G]17:198982] or ]13:123456]T )
    • isSingleBreakend

      public boolean isSingleBreakend()
      Specified by:
      isSingleBreakend in interface Allele
      Returns:
      true if this Allele is a single breakend (ex: .A or A.)
    • toString

      public String toString()
      Specified by:
      toString in interface Allele
      Overrides:
      toString in class Object
    • getBases

      public byte[] getBases()
      Return the DNA bases segregating in this allele. Note this isn't reference polarized, so the Null allele is represented by a vector of length 0
      Specified by:
      getBases in interface Allele
      Returns:
      the segregating bases
    • getBaseString

      public String getBaseString()
      Return the DNA bases segregating in this allele in String format. This is useful, because toString() adds a '*' to reference alleles and getBases() returns garbage when you call toString() on it.
      Specified by:
      getBaseString in interface Allele
      Returns:
      the segregating bases
    • getDisplayString

      public String getDisplayString()
      Return the printed representation of this allele. Same as getBaseString(), except for symbolic alleles. For symbolic alleles, the base string is empty while the display string contains <TAG>.
      Specified by:
      getDisplayString in interface Allele
      Returns:
      the allele string representation
    • getDisplayBases

      public byte[] getDisplayBases()
      Same as #getDisplayString() but returns the result as byte[]. Slightly faster then getDisplayString()
      Specified by:
      getDisplayBases in interface Allele
      Returns:
      the allele string representation
    • equals

      public boolean equals(Object other)
      Specified by:
      equals in interface Allele
      Overrides:
      equals in class Object
      Parameters:
      other - the other allele
      Returns:
      true if these alleles are equal
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Allele
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • equals

      public boolean equals(Allele other, boolean ignoreRefState)
      Returns true if this and other are equal. If ignoreRefState is true, then doesn't require both alleles has the same ref tag
      Specified by:
      equals in interface Allele
      Parameters:
      other - allele to compare to
      ignoreRefState - if true, ignore ref state in comparison
      Returns:
      true if this and other are equal
    • basesMatch

      public boolean basesMatch(byte[] test)
      Specified by:
      basesMatch in interface Allele
      Parameters:
      test - bases to test against
      Returns:
      true if this Allele contains the same bases as test, regardless of its reference status; handles Null and NO_CALL alleles
    • basesMatch

      public boolean basesMatch(String test)
      Specified by:
      basesMatch in interface Allele
      Parameters:
      test - bases to test against
      Returns:
      true if this Allele contains the same bases as test, regardless of its reference status; handles Null and NO_CALL alleles
    • basesMatch

      public boolean basesMatch(Allele test)
      Specified by:
      basesMatch in interface Allele
      Parameters:
      test - allele to test against
      Returns:
      true if this Allele contains the same bases as test, regardless of its reference status; handles Null and NO_CALL alleles
    • length

      public int length()
      Specified by:
      length in interface Allele
      Returns:
      the length of this allele. Null and NO_CALL alleles have 0 length.
    • compareTo

      public int compareTo(Allele other)
      Specified by:
      compareTo in interface Comparable<Allele>
    • isNonRefAllele

      public boolean isNonRefAllele()
      Specified by:
      isNonRefAllele in interface Allele
      Returns:
      true if Allele is either <NON_REF> or <*>