java.lang.Object
htsjdk.variant.variantcontext.SimpleAllele
org.broadinstitute.hellbender.utils.haplotype.Haplotype
All Implemented Interfaces:
htsjdk.variant.variantcontext.Allele, Serializable, Comparable<htsjdk.variant.variantcontext.Allele>

public final class Haplotype extends htsjdk.variant.variantcontext.SimpleAllele
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Comparator<Haplotype>
    Compares two haplotypes first by their lengths and then by lexicographic order of their bases.

    Fields inherited from interface htsjdk.variant.variantcontext.Allele

    ALT_A, ALT_C, ALT_G, ALT_N, ALT_T, BREAKEND_EXTENDING_LEFT, BREAKEND_EXTENDING_RIGHT, NO_CALL, NO_CALL_STRING, NON_REF_ALLELE, NON_REF_STRING, REF_A, REF_C, REF_G, REF_N, REF_T, SINGLE_BREAKEND_INDICATOR, SPAN_DEL, SPAN_DEL_STRING, SV_SIMPLE_CNV, SV_SIMPLE_DEL, SV_SIMPLE_DUP, SV_SIMPLE_INS, SV_SIMPLE_INV, SYMBOLIC_ALLELE_END, SYMBOLIC_ALLELE_START, UNSPECIFIED_ALTERNATE_ALLELE, UNSPECIFIED_ALTERNATE_ALLELE_STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
    Haplotype(byte[] bases)
    Create a new non-ref haplotype
    Haplotype(byte[] bases, boolean isRef)
    Main constructor
    Haplotype(byte[] bases, boolean isRef, int alignmentStartHapwrtRef, htsjdk.samtools.Cigar cigar)
    Create a new haplotype with bases Requires bases.length == cigar.getReadLength()
    Haplotype(byte[] bases, htsjdk.samtools.util.Locatable loc)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
    htsjdk.samtools.Cigar
    Get the cigar for this haplotype.
    htsjdk.samtools.Cigar
    Get the haplotype cigar extended by padSize M at the tail, consolidated into a clean cigar
     
    htsjdk.samtools.util.Locatable
    Get the span of this haplotype (may be null)
    int
     
    htsjdk.samtools.util.Locatable
    Get the span of this haplotype (may be null)
    double
    Get the score (an estimate of the support) of this haplotype
    long
     
    long
     
    int
     
    int
     
    insertAllele(htsjdk.variant.variantcontext.Allele refAllele, htsjdk.variant.variantcontext.Allele altAllele, int insertLocation)
     
    boolean
     
    void
    setAlignmentStartHapwrtRef(int alignmentStartHapwrtRef)
     
    void
    setCigar(htsjdk.samtools.Cigar cigar)
    Set the cigar of this haplotype to cigar.
    void
    setCollapsed(boolean collapsed)
     
    void
     
    void
    setGenomeLocation(htsjdk.samtools.util.Locatable genomeLocation)
     
    void
    setKmerSize(int kmerSize)
     
    void
    setScore(double score)
    Set the score (an estimate of the support) of this haplotype.
    void
    setUniquenessValue(int uniquenessValue)
     
     
    trim(htsjdk.samtools.util.Locatable loc)
    Create a new Haplotype derived from this one that exactly spans the provided location Note that this haplotype must have a contain a genome loc for this operation to be successful.
    trim(htsjdk.samtools.util.Locatable loc, boolean ignoreRefState)
    Create a new Haplotype derived from this one that exactly spans the provided location Note that this haplotype must have a contain a genome loc for this operation to be successful.

    Methods inherited from class htsjdk.variant.variantcontext.SimpleAllele

    basesMatch, basesMatch, basesMatch, compareTo, equals, getBases, getBaseString, getDisplayBases, getDisplayString, isBreakpoint, isCalled, isNoCall, isNonRefAllele, isNonReference, isPrefixOf, isReference, isSingleBreakend, isSymbolic, length

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • SIZE_AND_BASE_ORDER

      public static final Comparator<Haplotype> SIZE_AND_BASE_ORDER
      Compares two haplotypes first by their lengths and then by lexicographic order of their bases.
  • Constructor Details

    • Haplotype

      public Haplotype(byte[] bases, boolean isRef)
      Main constructor
      Parameters:
      bases - a non-null array of bases
      isRef - is this the reference haplotype?
    • Haplotype

      public Haplotype(byte[] bases)
      Create a new non-ref haplotype
      Parameters:
      bases - a non-null array of bases
    • Haplotype

      public Haplotype(byte[] bases, boolean isRef, int alignmentStartHapwrtRef, htsjdk.samtools.Cigar cigar)
      Create a new haplotype with bases Requires bases.length == cigar.getReadLength()
      Parameters:
      bases - a non-null array of bases
      isRef - is this the reference haplotype?
      alignmentStartHapwrtRef - offset of this haplotype w.r.t. the reference
      cigar - the cigar that maps this haplotype to the reference sequence
    • Haplotype

      public Haplotype(byte[] bases, htsjdk.samtools.util.Locatable loc)
  • Method Details

    • trim

      public Haplotype trim(htsjdk.samtools.util.Locatable loc)
      Create a new Haplotype derived from this one that exactly spans the provided location Note that this haplotype must have a contain a genome loc for this operation to be successful. If no GenomeLoc is contained than @throws an IllegalStateException Also loc must be fully contained within this Haplotype's genomeLoc. If not an IllegalArgumentException is thrown.
      Parameters:
      loc - a location completely contained within this Haplotype's location
      Returns:
      a new Haplotype within only the bases spanning the provided location, or null for some reason the haplotype would be malformed if
    • trim

      public Haplotype trim(htsjdk.samtools.util.Locatable loc, boolean ignoreRefState)
      Create a new Haplotype derived from this one that exactly spans the provided location Note that this haplotype must have a contain a genome loc for this operation to be successful. If no GenomeLoc is contained than @throws an IllegalStateException Also loc must be fully contained within this Haplotype's genomeLoc. If not an IllegalArgumentException is thrown.
      Parameters:
      loc - a location completely contained within this Haplotype's location
      ignoreRefState - should the reference state of the original Haplotype be ignored
      Returns:
      a new Haplotype within only the bases spanning the provided location, or null for some reason the haplotype would be malformed if
    • equals

      public boolean equals(Object h)
      Specified by:
      equals in interface htsjdk.variant.variantcontext.Allele
      Overrides:
      equals in class htsjdk.variant.variantcontext.SimpleAllele
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface htsjdk.variant.variantcontext.Allele
      Overrides:
      hashCode in class htsjdk.variant.variantcontext.SimpleAllele
    • getEventMap

      public EventMap getEventMap()
    • setEventMap

      public void setEventMap(EventMap eventMap)
    • toString

      public String toString()
      Specified by:
      toString in interface htsjdk.variant.variantcontext.Allele
      Overrides:
      toString in class htsjdk.variant.variantcontext.SimpleAllele
    • getLocation

      public htsjdk.samtools.util.Locatable getLocation()
      Get the span of this haplotype (may be null)
      Returns:
      a potentially null genome loc
    • setGenomeLocation

      public void setGenomeLocation(htsjdk.samtools.util.Locatable genomeLocation)
    • getStartPosition

      public long getStartPosition()
    • getStopPosition

      public long getStopPosition()
    • getAlignmentStartHapwrtRef

      public int getAlignmentStartHapwrtRef()
    • setAlignmentStartHapwrtRef

      public void setAlignmentStartHapwrtRef(int alignmentStartHapwrtRef)
    • getCigar

      public htsjdk.samtools.Cigar getCigar()
      Get the cigar for this haplotype. Note that the cigar is guaranteed to be consolidated in that multiple adjacent equal operates will have been merged
      Returns:
      the cigar of this haplotype
    • getConsolidatedPaddedCigar

      public htsjdk.samtools.Cigar getConsolidatedPaddedCigar(int padSize)
      Get the haplotype cigar extended by padSize M at the tail, consolidated into a clean cigar
      Parameters:
      padSize - how many additional Ms should be appended to the end of this cigar. Must be >= 0
      Returns:
      a newly allocated Cigar that consolidate(getCigar + padSize + M)
    • setCigar

      public void setCigar(htsjdk.samtools.Cigar cigar)
      Set the cigar of this haplotype to cigar. This method consolidates the cigar, so that 1M1M1I1M1M => 2M1I2M. It does not remove leading or trailing deletions because haplotypes, unlike reads, are pegged to a specific reference start and end.
      Parameters:
      cigar - a cigar whose readLength == length()
    • insertAllele

      public Haplotype insertAllele(htsjdk.variant.variantcontext.Allele refAllele, htsjdk.variant.variantcontext.Allele altAllele, int insertLocation)
      Parameters:
      refAllele - allele, contained in this haplotype, to be replaced
      altAllele - new allele, the bases of which replace those of refAllele
      insertLocation - location in the genome at which the new allele starts Example: suppose this haplotype starts at position 100 on its contig and has bases ACCGTTATATCG and we wish to delete the GTT. Then refAllele = CGTT, alt allele = C, and insertLocation = 102.
    • getScore

      public double getScore()
      Get the score (an estimate of the support) of this haplotype
      Returns:
      a double, where higher values are better
    • setScore

      public void setScore(double score)
      Set the score (an estimate of the support) of this haplotype. Note that if this is the reference haplotype it is always given Double.MAX_VALUE score
      Parameters:
      score - a double, where higher values are better
    • getGenomeLocation

      public htsjdk.samtools.util.Locatable getGenomeLocation()
      Get the span of this haplotype (may be null)
      Returns:
      a potentially null genome loc
    • isCollapsed

      public boolean isCollapsed()
    • setCollapsed

      public void setCollapsed(boolean collapsed)
    • getUniquenessValue

      public int getUniquenessValue()
    • getKmerSize

      public int getKmerSize()
    • setUniquenessValue

      public void setUniquenessValue(int uniquenessValue)
    • setKmerSize

      public void setKmerSize(int kmerSize)