Class Haplotype
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
FieldsModifier and TypeFieldDescriptionstatic 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
ConstructorsConstructorDescriptionHaplotype
(byte[] bases) Create a new non-ref haplotypeHaplotype
(byte[] bases, boolean isRef) Main constructorHaplotype
(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 TypeMethodDescriptionboolean
int
htsjdk.samtools.Cigar
getCigar()
Get the cigar for this haplotype.htsjdk.samtools.Cigar
getConsolidatedPaddedCigar
(int padSize) Get the haplotype cigar extended by padSize M at the tail, consolidated into a clean cigarhtsjdk.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
getScore()
Get the score (an estimate of the support) of this haplotypelong
long
int
int
hashCode()
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
setEventMap
(EventMap eventMap) 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) toString()
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
-
Field Details
-
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 basesisRef
- 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 basesisRef
- is this the reference haplotype?alignmentStartHapwrtRef
- offset of this haplotype w.r.t. the referencecigar
- the cigar that maps this haplotype to the reference sequence
-
Haplotype
public Haplotype(byte[] bases, htsjdk.samtools.util.Locatable loc)
-
-
Method Details
-
trim
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
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 locationignoreRefState
- 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
- Specified by:
equals
in interfacehtsjdk.variant.variantcontext.Allele
- Overrides:
equals
in classhtsjdk.variant.variantcontext.SimpleAllele
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfacehtsjdk.variant.variantcontext.Allele
- Overrides:
hashCode
in classhtsjdk.variant.variantcontext.SimpleAllele
-
getEventMap
-
setEventMap
-
toString
- Specified by:
toString
in interfacehtsjdk.variant.variantcontext.Allele
- Overrides:
toString
in classhtsjdk.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 replacedaltAllele
- new allele, the bases of which replace those of refAlleleinsertLocation
- 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)
-