Package htsjdk.samtools
Class Cigar
java.lang.Object
htsjdk.samtools.Cigar
- All Implemented Interfaces:
Serializable
,Iterable<CigarElement>
A list of CigarElements, which describes how a read aligns with the reference.
E.g. the Cigar string 10M1D25M means
* match or mismatch for 10 bases
* deletion of 1 base
* match or mismatch for 25 bases
c.f. https://samtools.github.io/hts-specs/SAMv1.pdf for complete CIGAR specification.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(CigarElement cigarElement) boolean
containsOperator
(CigarOperator operator) returns true if the cigar string contains the given operatorboolean
static Cigar
fromCigarOperators
(List<CigarOperator> cigarOperators) build a new Cigar object from a list of cigar operators.static Cigar
fromCigarString
(String cigarString) Decode a Cigar from a SAM formatted CIGAR String, usesTextCigarCodec.decode(String)
Only performs minimal validation.getCigarElement
(int i) returns the first cigar elementreturns the last cigar elementint
int
static int
getReadLength
(List<CigarElement> cigarElements) int
int
hashCode()
boolean
returns true if the cigar is clippedboolean
isEmpty()
boolean
returns true if the cigar string starts With a clipping operatorboolean
returns true if the cigar string ends With a clipping operatorExhaustive validation of CIGAR.iterator()
shortcut togetCigarElements().iterator()
int
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
-
Constructor Details
-
Cigar
public Cigar() -
Cigar
-
-
Method Details
-
getCigarElements
-
getCigarElement
-
add
-
numCigarElements
public int numCigarElements() -
isEmpty
public boolean isEmpty() -
getReferenceLength
public int getReferenceLength()- Returns:
- The number of reference bases that the read covers, excluding padding.
-
getPaddedReferenceLength
public int getPaddedReferenceLength()- Returns:
- The number of reference bases that the read covers, including padding.
-
getReadLength
public int getReadLength()- Returns:
- The number of read bases that the read covers.
-
getReadLength
- Returns:
- The number of read bases that the read covers.
-
isValid
Exhaustive validation of CIGAR. Note that this method deliberately returns null rather than Collections.emptyList() if there are no validation errors, because callers tend to assume that if a non-null list is returned, it is modifiable.- Parameters:
readName
- For error reporting only. May be null if not known.recordNumber
- For error reporting only. May be -1 if not known.- Returns:
- List of validation errors, or null if no errors.
-
equals
-
fromCigarOperators
build a new Cigar object from a list of cigar operators. This can be used if you have the operators associated to each base in the read. e.g: read length =10 with cigar=[M,M,M,M,M,M,M,M,M,M]
, here fromCigarOperators would generate the cigar '10M' later the user resolved the 'M' to '=' or 'X', the array is now[=,=,=,=,=,X,X,=,=,=]
fromCigarOperators would generate the cigar '5M2X3M' -
fromCigarString
Decode a Cigar from a SAM formatted CIGAR String, usesTextCigarCodec.decode(String)
Only performs minimal validation.- Parameters:
cigarString
- A SAM formatted CIGAR string.- Returns:
- a new Cigar
-
iterator
shortcut togetCigarElements().iterator()
- Specified by:
iterator
in interfaceIterable<CigarElement>
-
containsOperator
returns true if the cigar string contains the given operator -
getFirstCigarElement
returns the first cigar element -
getLastCigarElement
returns the last cigar element -
isLeftClipped
public boolean isLeftClipped()returns true if the cigar string starts With a clipping operator -
isRightClipped
public boolean isRightClipped()returns true if the cigar string ends With a clipping operator -
isClipped
public boolean isClipped()returns true if the cigar is clipped -
hashCode
public int hashCode() -
toString
-