Package htsjdk.samtools
Class Cigar
- java.lang.Object
-
- htsjdk.samtools.Cigar
-
- All Implemented Interfaces:
Serializable
,Iterable<CigarElement>
public class Cigar extends Object implements 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. http://samtools.sourceforge.net/SAM1.pdf for complete CIGAR specification.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description Cigar()
Cigar(List<CigarElement> cigarElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(CigarElement cigarElement)
boolean
containsOperator(CigarOperator operator)
returns true if the cigar string contains the given operatorboolean
equals(Object o)
static Cigar
fromCigarOperators(List<CigarOperator> cigarOperators)
build a new Cigar object from a list of cigar operators.CigarElement
getCigarElement(int i)
List<CigarElement>
getCigarElements()
CigarElement
getFirstCigarElement()
returns the first cigar elementCigarElement
getLastCigarElement()
returns the last cigar elementint
getPaddedReferenceLength()
int
getReadLength()
static int
getReadLength(List<CigarElement> cigarElements)
int
getReferenceLength()
int
hashCode()
boolean
isClipped()
returns true if the cigar is clippedboolean
isEmpty()
boolean
isLeftClipped()
returns true if the cigar string starts With a clipping operatorboolean
isRightClipped()
returns true if the cigar string ends With a clipping operatorList<SAMValidationError>
isValid(String readName, long recordNumber)
Exhaustive validation of CIGAR.Iterator<CigarElement>
iterator()
shortcut togetCigarElements().iterator()
int
numCigarElements()
String
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 Detail
-
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Cigar
public Cigar()
-
Cigar
public Cigar(List<CigarElement> cigarElements)
-
-
Method Detail
-
getCigarElements
public List<CigarElement> getCigarElements()
-
getCigarElement
public CigarElement getCigarElement(int i)
-
add
public void add(CigarElement cigarElement)
-
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
public static int getReadLength(List<CigarElement> cigarElements)
- Returns:
- The number of read bases that the read covers.
-
isValid
public List<SAMValidationError> isValid(String readName, long recordNumber)
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.
-
fromCigarOperators
public static Cigar fromCigarOperators(List<CigarOperator> cigarOperators)
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'
-
iterator
public Iterator<CigarElement> iterator()
shortcut togetCigarElements().iterator()
- Specified by:
iterator
in interfaceIterable<CigarElement>
-
containsOperator
public boolean containsOperator(CigarOperator operator)
returns true if the cigar string contains the given operator
-
getFirstCigarElement
public CigarElement getFirstCigarElement()
returns the first cigar element
-
getLastCigarElement
public CigarElement 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
-
-